diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 235d42fcc..249d1fc3e 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -1091,9 +1091,10 @@ func (al *AgentLoop) runLLMIteration( return "", iteration, fmt.Errorf("LLM call failed after retries: %w", err) } + effectiveReasoning := response.EffectiveReasoning() go al.handleReasoning( ctx, - response.Reasoning, + effectiveReasoning, opts.Channel, al.targetReasoningChannelID(opts.Channel), ) @@ -1104,7 +1105,7 @@ func (al *AgentLoop) runLLMIteration( "iteration": iteration, "content_chars": len(response.Content), "tool_calls": len(response.ToolCalls), - "reasoning": response.Reasoning, + "reasoning": effectiveReasoning, "target_channel": al.targetReasoningChannelID(opts.Channel), "channel": opts.Channel, }) diff --git a/pkg/providers/protocoltypes/types.go b/pkg/providers/protocoltypes/types.go index 194c1aa6f..d83657ba9 100644 --- a/pkg/providers/protocoltypes/types.go +++ b/pkg/providers/protocoltypes/types.go @@ -34,6 +34,14 @@ type LLMResponse struct { ReasoningDetails []ReasoningDetail `json:"reasoning_details"` } +// EffectiveReasoning returns Reasoning if non-empty, otherwise ReasoningContent. +func (r *LLMResponse) EffectiveReasoning() string { + if r.Reasoning != "" { + return r.Reasoning + } + return r.ReasoningContent +} + type ReasoningDetail struct { Format string `json:"format"` Index int `json:"index"`