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 first map the repository and locate the subagent/OpenAI-compatible response handling paths, then reproduce the mismatch with the closest existing tests or a temporary harness before changing code.
- Assistant
The project is Go-based and clean. I’ll now search for the exact “no response” behavior, subagent execution, and OpenAI/LiteLLM conversion code to identify where tool calls are being discarded.
- Assistant
rgis unavailable, so I’ll use recursivegrepto perform the same search without altering the environment. - Assistant
The likely fault is in the streaming adapter: LiteLLM may emit tool calls while labeling the terminal chunk
finish_reason: "stop". I’ll inspect OpenAI response types, stream adaptation, and runtime extraction to see whether processing is incorrectly gated on the finish reason. - Assistant
I found a concrete ordering bug in
handleStream: it returns immediately uponstop/lengthbefore processing that same chunk’sDelta.ToolCalls. LiteLLM commonly places a complete tool call andfinish_reason: "stop"in one chunk, so the result is empty and the subagent appears silent. I’ll inspect adjacent tests and stream abstractions, then build a temporary focused reproducer againsthandleStream(inside the package if necessary) before implementing an order-safe fix. - Assistant
The reproducer condition is confirmed directly by control flow: any terminal chunk’s deltas—including text as well as tool calls—are skipped. The robust fix is to aggregate every field in a received choice first, then honor its finish reason. I’ll inspect the loop’s interpretation of
Stopped/FinishReasonand the test stream builder so the refactor preserves iteration semantics and can be verified through an end-to-end runtime harness. - Assistant
processToolCallsruns before the loop checksres.Stopped, so preservingStopped=falsewhenever calls exist is correct. I’ll now move terminal handling after all delta aggregation and remove the tool-call branch’scontinue, allowing a single chunk to carry tool calls, content/reasoning, usage, and a terminal reason without losing any field. - Assistant
The source now handles the problematic shape, but one nearby comment still says terminal reasons are handled “above”; I’ll correct that. For verification without adding repository tests, I’ll create a standalone temporary Go program under
/tmpusing the public runtime API and a synthetic stream whose first response contains both a complete tool call andfinish_reason: stop, followed by a normal completion. This will demonstrate whether the tool is actually invoked. - Assistant
I’ll inspect the minimal
tools.Tooland agent option constructors needed by the standalone harness, then run it against the patched code. - Assistant
The harness can use the public
Agent,Team, and runtime stream APIs. I’ll check the model-store interface and runtime options, then generate the smallest compileable/tmp/repro.go. - Assistant
I need the exact
ModelStoremethods; after that I can compile and execute the standalone reproduction. - Assistant
The harness will provide both model-store methods, a queue provider (tool-call turn then final text turn), and a counter-backed
company_searchhandler. I’ll run it with non-interactive mode so no permission prompt can block execution. - Assistant
The standalone reproducer is ready, but Go is configured with neither
GOMODCACHEnorGOPATH. I’ll rerun with an isolated/tmpGOPATH (without changing repository configuration); dependencies may download into that temporary cache. - Assistant
Dependencies downloaded successfully, but this stripped environment also lacks
GOCACHE/HOME. I’ll point the build cache to/tmp/gocacheand rerun. - Assistant
The first cached build exceeded the command timeout after startup logs; it may have spent most of the interval compiling or may be waiting in runtime lifecycle cleanup. I’ll rerun now that compilation is cached, with a shell timeout to distinguish a runtime hang and capture its exit status.
- Assistant
The harness reaches model selection but hangs, suggesting the runtime’s permission flow is waiting despite non-interactive mode. I’ll inspect permission checking and event types, then either explicitly allow the tool on the team or simplify verification to observable assistant-session state.
- Assistant
WithNonInteractiveonly affects MCP elicitation, not tool authorization. I’ll explicitly attach a permission checker allowingcompany_searchto the temporary team, then rerun the reproduction. - Assistant
The patched standalone workflow succeeds: the tool runs exactly once and the model continues for a second turn. To explicitly confirm the reported failure rather than relying only on control-flow inspection, I’ll temporarily save the patched source, restore just
streaming.goto HEAD, run the same harness (expecting zero invocation/panic), and immediately restore the patch. - Assistant
The unpatched code reproduces the issue exactly (
tool_invocations=0, only one model call), while the patch gives one invocation and a continuation turn. I’ll update the now-stale finish-reason comment and then run focused runtime/provider tests plus broader package tests. - Assistant
The combined run exposed environment-dependent baseline failures:
$HOMEis unset (OpenAI test panic), and a compaction test cannot resolve its provider/model in this stripped environment. The directly relevant runtime tool-call tests reached the changed path without reported failures. I’ll rerun focused tests with a temporaryHOME, separately, so results are clear and not obscured by unrelated package-wide failures. - Assistant
Focused tests pass. I’ll investigate the one package-wide runtime failure in isolation to determine whether it is an existing/environmental flake or a regression; then I’ll inspect the final diff and repository status for unintended changes.
- Assistant
The isolated compaction failure is unchanged by scope and reports
Unknown provider type type="", confirming it is unrelated to stream aggregation. The final diff is limited tostreaming.go. I’ll perform one final patched reproduction, focused test run, formatting/diff validation, and verify no temporary artifacts entered the repository.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.