Repository navigation
Conversation
`return_trace` is documented on POST /api/v1/agents/chat/completions and
the request struct parsed it, but no code read the value, so the
aggregated response never carried the documented `data.trace`. Mirror the
Python agent_api.py aggregation: each `node_finished` event contributes
{component_id, trace: [data]} and the list is attached to the final
answer when the flag is set.
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Action not completed
|
Summary
return_traceis documented onPOST /api/v1/agents/chat/completionsand the Go handler parses it intoagentChatCompletionsRequest.ReturnTrace, but nothing ever read the value, so the documenteddata.tracewas never returned for non-streaming calls.This mirrors the removed Python implementation (
api/apps/restful_apis/agent_api.py): eachnode_finishedevent contributes{component_id, trace: [<node_finished data>]}, and the list is attached to the final answer when the flag is set. With the flag absent orfalsethe response is unchanged (notracekey), so the change is additive.The trace is also where the Agent component's
tool_invocationslive, so non-streaming callers can now read the agentic tool trace through the documented flag (Relates to #22306).Fixes #22325
Changes
internal/handler/agent.go: collectnode_finisheddata intotraceItemswhenreturn_traceis true, and setdata.traceon the aggregated response.internal/handler/agent_test.go:TestAgentChatCompletions_NonStreamingReturnsTracecovers bothreturn_trace: true(twonode_finishedevents → two entries withcomponent_idand the node data preserved) andreturn_traceabsent (notracekey).Verification
Run in the build sandbox (Linux,
bash build.shtoolchain):Red/green: reverting only the
agent.gohunk makes the new test fail withresponse data has no trace, and it passes with the change.