Subagent toolcalls not handled when using LiteLLM proxy Summary When using cagent with a…
- User
Subagent tool_calls not handled when using LiteLLM proxy
Summary
When using cagent with a LiteLLM proxy (OpenAI-compatible API), a subagent can return a valid
tool_callsresponse, but the host agent reports “no response from subagent” and does not execute the tool call.Environment
- cagent: v1.19.7
- OS: Linux (WSL2) x86_64
- LLM: gemini-pro via LiteLLM proxy (OpenAI-compatible)
Expected
Host agent receives the subagent response and executes the tool call(s), then continues the conversation with the tool result.
Actual
Host agent reports there is “no response from subagent” even though the subagent response contains a valid
tool_callsentry. The requested tool call is not executed.Minimal reproduction
- Configure cagent to use LiteLLM as the model provider (OpenAI-compatible API).
- Run a workflow where the subagent is asked to use tools.
- The subagent returns a tool call (e.g.,
company_searchwith JSON arguments) and finishes withfinish_reason: "stop". - The host agent logs “no response from subagent” and does not invoke the tool.
Notes
- The subagent response includes a valid tool call object (
type: function,name: company_search,arguments: {"datasources": ["confluence", "github", "gdrive"], "query": "LiteLLM usage teams integrations standards"}). - I can reproduce consistently with LiteLLM as the proxy in front of an OpenAI-compatible endpoint.
Please let me know if you want a sanitized example payload or a minimal agent config.
Interface
No new interfaces are introduced.
- Assistant
Now let me look at how the runtime decides whether to execute tool calls — likely based on
finish_reason. - Assistant
Now let me check the chat types and the OpenAI-compatible adapter to see how chunks are delivered:
- Assistant
Now replace the
continueafter tool-call handling and add the finish check at the end of the iteration: - Assistant
Now let me check what's needed to unit test
handleStreamdirectly — Telemetry and EventSink: - Assistant
Now I'll write unit tests for
handleStream. Let me checkagent.Newandsession.Newusage quickly: - Assistant
The build hit process limits. Let me retry with limited parallelism:
- Assistant
All green. Here's the final diff:
- Assistant
Fixed. Summary of the change:
Root cause
In
handleStream(pkg/runtime/streaming.go), thefinish_reason: "stop"/"length"early-return ran at the top of each chunk iteration — before that chunk'sDelta.ToolCalls(and content) were processed.LiteLLM proxying an OpenAI-compatible model (notably Gemini) delivers the complete tool call and
finish_reason: "stop"in a single chunk — either directly, or via , which stamps the finish reason onto of the final usage-bearing chunk (), a chunk that can also carry tool-call deltas. The result: the sub-agent's tool call was silently dropped, came back , the turn ended with an empty assistant message, and 's result () was empty — which the host model reported as "no response from subagent".
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.