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 loop consumes
streamResultand check the existing tests: - Assistant
Now I understand the structure. Let me confirm the root cause by examining how the loop consumes the result, and check
chattypes: - Assistant
Now I need to remove the
continueafter tool-call handling and move the finish-reason check after all delta processing: - Assistant
Now let me verify the full function reads correctly and build:
- Assistant
The restructured function looks right. Now build and check how tests construct agents so I can add a regression test:
- Assistant
The build hit process-limit errors (fork/exec resource exhaustion). Retrying with limited parallelism:
- Assistant
Build passes. Now let me check the pieces needed for a direct
handleStreamregression test: - Assistant
Now I'll write a regression test in a new
streaming_test.go: - Assistant
Let me check whether this failure is pre-existing by testing at HEAD without my changes:
- Assistant
All checks pass. The fix is complete.
Summary
Root cause —
pkg/runtime/streaming.go:handleStreamcheckedchoice.FinishReasonat the top of the chunk-processing loop and returned immediately onstop/length, before processing that same chunk'sDelta.ToolCallsandDelta.Content. Most providers send the finish reason in a trailing chunk with an empty delta, so this worked — but LiteLLM (notably in front of Gemini) delivers the entire response in a single chunk carrying both thetool_callsdelta andfinish_reason: "stop". The early return dropped the tool calls, leaving an empty assistant message, so the host agent saw "no response from subagent" and never executed the tool.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.