ISSUE DESCRIPTION Subagent toolcalls not handled when using LiteLLM proxy Summary When…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I'll start by exploring the repository structure and searching for code related to subagent tool_calls and LiteLLM handling.
- Assistant
Searching for the "no response from subagent" message and related subagent handling code.
- Assistant
rg is not available, let me use grep instead.
- Assistant
No results for "no response from subagent". Let me try broader searches.
- Assistant
Looking into the runtime and how responses from subagents/tool transfers are handled.
- Assistant
Let me look at the transfer_task / agent tools related to subagents more carefully.
- Assistant
Inspecting the transfer task and agent delegation code for how responses are handled.
- Assistant
Let me look at the agent tool which is likely what executes subagents and returns their response.
- Assistant
Let me look at GetLastAssistantMessageContent and the transfer task tool.
- Assistant
The notes mention finish_reason "stop" with tool_calls — investigating how the streaming path treats that combination.
- Assistant
Looking at how the OpenAI-compatible provider parses stream and non-stream responses for tool_calls.
- Assistant
Checking recent changes and the oaistream package that was recently modified.
- Assistant
The empty-content tool_calls case looks promising — checking how subagent results are collected when the last message is tool-only.
- Assistant
Searching more carefully for result messages related to missing subagent responses.
- Assistant
Inspecting how OpenAI-compatible streams parse tool_calls — LiteLLM may format them differently.
- Assistant
Inspecting the stream adapter and oaistream package next.
- Assistant
Reading the oaistream package carefully for tool-call parsing.
- Assistant
Looking at recent commits related to message merging and tool calls.
- Assistant
Looking at chatserver tool call handling and recent tool_choice fixes.
- Assistant
I think I found it: the stream handler may return early on finish_reason "stop" before processing tool_calls in the same chunk. Verifying that path.
- Assistant
Let me look at the test fixtures in runtime_test.go around lines 109-137 to see how tool calls with finish stop are tested.
- Assistant
Checking git history for the early-return logic and whether same-chunk tool_calls are handled.
- Assistant
Writing a small reproduction to confirm the same-chunk finish_reason/tool_calls bug.
- Assistant
Writing a temporary test to reproduce the same-chunk tool_calls + finish_reason stop issue.
- Assistant
Let me create a temporary Go program to test handleStream behaviour.
- Assistant
Need to fix the agent.New call.
- Assistant
Need to set GOPATH and GOMODCACHE.
- Assistant
Confirmed the bug: same-chunk tool_calls with finish_reason stop are dropped. Fixing
handleStreamto process deltas before handling finish reason. - Assistant
I'll restructure the loop so all delta content is processed before checking finish reason.
- Assistant
Re-running the reproduction test and cleaning up.
- Assistant
The fix works. Cleaning up the temporary test and running the existing streaming/runtime tests.
- Assistant
There are test failures. Identifying which tests failed.
- Assistant
Only one test failed. Let me see the full failure output.
- Assistant
Checking if this failure is unrelated to my change.
- Assistant
Pre-existing failure. Running tool-call related tests to confirm they still pass.
- Assistant
Re-verifying the fix end-to-end and reviewing the final streaming code.
- Assistant
All verification passed. Submitting the fix.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.