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
I'll search for the "no response from subagent" message and related tool_calls handling.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Hmm, the grep didn't find anything. Let me try broader searches.
- Assistant
I'll dig into the tools and runtime packages where subagent delegation and response handling live.
- Assistant
Agent delegation looks central — I'll inspect that and search for the error message.
- Assistant
I'll keep reading the delegation logic and hunt for the specific "no response" wording.
- Assistant
I'll inspect how last assistant content is extracted and how LiteLLM/OpenAI tool_calls are parsed.
- Assistant
I'll read GetLastAssistantMessageContent and the subagent result path next.
- Assistant
I'll locate the "no response from subagent" user-facing string next.
- Assistant
I'll inspect the agent tool and how tool_calls vs content are finalized in the OpenAI provider.
- Assistant
I'll examine how finish_reason interacts with tool_calls during streaming.
- Assistant
I'll read the full stream loop where finish_reason can cause an early return.
- Assistant
Same-chunk tool_calls with finish_reason:stop may never be processed — checking the stream adapter next.
- Assistant
I'll check recent changelog/history and LiteLLM gemini-related code for known tool_call bugs.
- Assistant
I'll check git history and tests around tool_calls with finish_reason stop.
- Assistant
Let me look more carefully at the tool call ID handling. When Gemini/LiteLLM streams tool calls, they might use index-based tool calls where ID is only on the first chunk. Looking at streaming.go agai...
- Assistant
Looking at session_test for "assistant with empty content but tool calls is kept" - and perhaps GetLastAssistantMessageContent returns empty when only tool_calls. That would cause "no response from su...The issue is that LiteLLM (via OpenAI-compatible proxy) is returning the full tool call in a single non-streaming chunk, so the streaming parser never sees the
delta.tool_callsand therefore never populatesstreamResult.Calls. - Assistant
I'll re-read the finish_reason+usage path and any related streaming tests carefully.
- Assistant
I'll check how custom OpenAI-compatible endpoints (LiteLLM) are configured and routed.
- Assistant
I think finish_reason stop is handled before tool_calls on the same chunk — verifying with a focused repro.
- Assistant
I'll confirm the same-chunk finish_reason vs tool_calls bug with a temporary unit test.
- Assistant
I'll write a temporary test that feeds finish_reason stop and tool_calls in one chunk.
- Assistant
Let me check EventSink and Telemetry interfaces completely, and fix the test.
- Assistant
I'll fix the test file and run it.
- Assistant
Need to set GOPATH or GOMODCACHE
- Assistant
There's already a mockStream in runtime_test.go. Let me look at it.
- Assistant
Confirmed: finish_reason stop is handled before same-chunk tool_calls. Fixing that ordering in
handleStream. - Assistant
I'll reorder the stream loop so tool-call and content deltas are applied before the finish_reason early return.
- Assistant
I'll check for leftover duplicate code below the edit.
- Assistant
The for-loop close and
recordUsage()call were dropped — restoring them. - Assistant
Running the reproduction tests and related runtime tests.
- Assistant
Temporary tests passed. I'll remove them and run the full runtime package suite.
- Assistant
I'll identify which runtime and OpenAI provider tests failed.
- Assistant
I'll inspect the compacting hook test failure next.
- Assistant
I'll check whether the compaction failure is unrelated by comparing against HEAD.
- Assistant
I'll confirm the diff is limited to the streaming fix and re-run the key stream/tool scenarios.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.