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.
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,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted. - Assistant
I’ll trace the subagent response handling and tool-call normalization, identify where a non-empty
tool_callsresponse is treated as empty, then patch that path and run focused tests (plus relevant broader tests if available). I’ll first inspect the repository structure and search for the “no response from subagent” message and tool-call handling. - Assistant
rgis unavailable in the container, so I’ll usegrep/findinstead. The repository is a Go project; I’m narrowing the search to the subagent and model packages before inspecting the relevant control flow. - Assistant
The failure is in
handleStream: it checksFinishReason == "stop"and returns before processing tool-call deltas in that same chunk. LiteLLM can legally emit the completetool_callspayload together withfinish_reason: "stop"(rather than"tool_calls"), so the accumulated call remains empty and the subagent appears to have no response. I’ll make the stream handler process tool-call deltas first and then finalize that same response, preserving the existing behavior for ordinary stop chunks. - Assistant
The patch now handles the LiteLLM shape without changing the normal stop path: a stop/length chunk with tool calls is aggregated and returned as
FinishReasonToolCalls, while a stop/length chunk without tool calls still returns immediately. I’ll run the runtime tests and OpenAI stream adapter tests, then inspect for formatting/static issues. - Assistant
The focused test command is currently blocked by the environment rather than the code: Go reports that neither
GOMODCACHEnorGOPATHis configured. The diff is clean, and the downstream loop already dispatches any non-emptyres.Calls; I’ll retry with a temporary cache location so dependencies can be downloaded without modifying the repository. - Assistant
Focused tool-call/XML runtime tests pass, and the OpenAI-compatible adapter tests pass. The broader package run reached the code successfully but has two unrelated environment-sensitive failures: a runtime context-window test and a root-owned-directory writability test; no failures implicated this change. I’ve also verified
gofmt/git diff --checkand will submit the single-source-file fix.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.