fix: use non-cancellable context for reasoning goroutine
The reasoning content goroutine was using the turn-scoped context which gets cancelled when the turn ends, racing with the publish. Use context.WithoutCancel to ensure reasoning is delivered. Also fix gci field alignment and golines indentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d8a18daa11
commit
ed23705af1
1 changed files with 9 additions and 4 deletions
|
|
@ -444,9 +444,9 @@ func (al *AgentLoop) runAgentLoop(ctx context.Context, agent *AgentInstance, opt
|
||||||
Iteration: iteration,
|
Iteration: iteration,
|
||||||
}
|
}
|
||||||
al.emitEvent(EventKindTurnEnd, abortMeta, TurnEndPayload{
|
al.emitEvent(EventKindTurnEnd, abortMeta, TurnEndPayload{
|
||||||
Status: TurnEndStatusAborted,
|
Status: TurnEndStatusAborted,
|
||||||
Duration: time.Since(turnStart),
|
Duration: time.Since(turnStart),
|
||||||
})
|
})
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
|
|
@ -1068,7 +1068,12 @@ func (al *AgentLoop) runLLMIteration(
|
||||||
if reasoningText == "" {
|
if reasoningText == "" {
|
||||||
reasoningText = response.ReasoningContent
|
reasoningText = response.ReasoningContent
|
||||||
}
|
}
|
||||||
go al.handleReasoning(ctx, reasoningText, opts.Channel, al.targetReasoningChannelID(opts.Channel))
|
go al.handleReasoning(
|
||||||
|
context.WithoutCancel(ctx),
|
||||||
|
reasoningText,
|
||||||
|
opts.Channel,
|
||||||
|
al.targetReasoningChannelID(opts.Channel),
|
||||||
|
)
|
||||||
|
|
||||||
logger.DebugCF("agent", "LLM response",
|
logger.DebugCF("agent", "LLM response",
|
||||||
map[string]any{
|
map[string]any{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue