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,
|
||||
}
|
||||
al.emitEvent(EventKindTurnEnd, abortMeta, TurnEndPayload{
|
||||
Status: TurnEndStatusAborted,
|
||||
Duration: time.Since(turnStart),
|
||||
})
|
||||
Status: TurnEndStatusAborted,
|
||||
Duration: time.Since(turnStart),
|
||||
})
|
||||
return "", nil
|
||||
}
|
||||
return "", err
|
||||
|
|
@ -1068,7 +1068,12 @@ func (al *AgentLoop) runLLMIteration(
|
|||
if reasoningText == "" {
|
||||
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",
|
||||
map[string]any{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue