refactor: single computed EffectiveReasoning() on LLMResponse, prefer Reasoning over ReasoningContent (#1)
* Add EffectiveReasoning() to LLMResponse and use it in loop.go Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: CzBiX <760097+CzBiX@users.noreply.github.com>
This commit is contained in:
parent
e74820cf69
commit
89d77ee724
2 changed files with 11 additions and 2 deletions
|
|
@ -1091,9 +1091,10 @@ func (al *AgentLoop) runLLMIteration(
|
||||||
return "", iteration, fmt.Errorf("LLM call failed after retries: %w", err)
|
return "", iteration, fmt.Errorf("LLM call failed after retries: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
effectiveReasoning := response.EffectiveReasoning()
|
||||||
go al.handleReasoning(
|
go al.handleReasoning(
|
||||||
ctx,
|
ctx,
|
||||||
response.Reasoning,
|
effectiveReasoning,
|
||||||
opts.Channel,
|
opts.Channel,
|
||||||
al.targetReasoningChannelID(opts.Channel),
|
al.targetReasoningChannelID(opts.Channel),
|
||||||
)
|
)
|
||||||
|
|
@ -1104,7 +1105,7 @@ func (al *AgentLoop) runLLMIteration(
|
||||||
"iteration": iteration,
|
"iteration": iteration,
|
||||||
"content_chars": len(response.Content),
|
"content_chars": len(response.Content),
|
||||||
"tool_calls": len(response.ToolCalls),
|
"tool_calls": len(response.ToolCalls),
|
||||||
"reasoning": response.Reasoning,
|
"reasoning": effectiveReasoning,
|
||||||
"target_channel": al.targetReasoningChannelID(opts.Channel),
|
"target_channel": al.targetReasoningChannelID(opts.Channel),
|
||||||
"channel": opts.Channel,
|
"channel": opts.Channel,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,14 @@ type LLMResponse struct {
|
||||||
ReasoningDetails []ReasoningDetail `json:"reasoning_details"`
|
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 {
|
type ReasoningDetail struct {
|
||||||
Format string `json:"format"`
|
Format string `json:"format"`
|
||||||
Index int `json:"index"`
|
Index int `json:"index"`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue