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 the OpenAI-compatible message conversion path, then identify why
tool_callsis discarded when content is empty. I’ll make the smallest compatible fix, run focused tests (and broader relevant tests if available), inspect the diff, and only then submit. - Assistant
The likely failure is in
handleStream: it checksfinish_reason == "stop"before processing that chunk’s delta. LiteLLM can put the completetool_callsdelta and"stop"finish reason in the same choice, so the function returns with zero calls. I’ll reorder handling so every delta is aggregated before honoring a terminal finish reason, while preserving existing stop/tool-call inference. - Assistant
The code change is in place. The first focused test command was blocked by the environment because neither
GOMODCACHEnorGOPATHis configured, rather than by a test failure. I’ll inspect the repository’s expected Go setup, configure a temporary cache if dependencies are available, and rerun the relevant tests. - Assistant
Focused validation passed for the runtime tool-call paths and both OpenAI-compatible stream packages. The broader selected-package run also showed the changed packages passing; its failures were unrelated pre-existing environment-sensitive tests (
TestDoCompactAfterHookFiresand root-permission directory writability). The fix is limited to one runtime file, andgit diff --checkis clean.Checklist:
- Reproduced/analyzed the reported failure: yes—the terminal
stopcheck preceded same-chunk tool-call aggregation. - Confirmed the fix: yes—tool-call/runtime-focused tests and OpenAI adapter tests pass, and the new ordering handles the reported payload shape.
- Considered edge cases: yes—ordinary stop/length chunks retain prior behavior; explicit finish reasons remain tracked; same-chunk calls are converted to
tool_calls. - Ran relevant existing tests: yes; focused tests pass. Broader tests were run, with only unrelated environment-sensitive failures noted above.
I’m submitting the verified change now.
- Reproduced/analyzed the reported failure: yes—the terminal
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.