This commit is contained in:
OpenClaw-User 2026-03-14 17:12:19 +08:00
commit e456715dd8
2 changed files with 11 additions and 2 deletions

View file

@ -1168,9 +1168,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),
)
@ -1181,7 +1182,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,
})

View file

@ -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"`