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 handling.
- Assistant
Searching for the error message and subagent tool call handling logic.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Hmm the grep for the error message returned nothing. Let me try broader searches.
- Assistant
Let me dig into transfer/task tools and how subagent responses are processed.
- Assistant
Looking at agent delegation and transfer task handling next.
- Assistant
Let me continue reading the file.
- Assistant
Continue reading
- Assistant
Looking for how empty subagent responses are reported and how last assistant content is extracted.
- Assistant
I'll inspect GetLastAssistantMessageContent and LiteLLM/tool-call finish_reason handling.
- Assistant
The finish_reason "stop" with tool_calls path looks suspicious — inspecting the stream adapters and runtime loop.
- Assistant
Reading the rest of the stream adapter and runtime streaming logic for tool-call handling.
- Assistant
Checking recent changelog entries and tests about LiteLLM and tool_calls.
- Assistant
There's a session test about "assistant with empty content but tool calls is kept". And the changelog mentions "Fixes finish_reason stop when tracking usage in OpenAI streams". Let me look at recent g...
- Assistant
This looks like a race between finish_reason stop and tool_call deltas in the same chunk — checking tests and history to confirm.
- Assistant
Found a commit removing a LiteLLM hack — inspecting that next.
- Assistant
Tracing how stream results with empty content and tool calls flow through the runtime loop.
- Assistant
Let me look at line 656 and around processToolCalls when empty. Also check if there's something about messages being stored without tool_calls when stop happens.
- Assistant
Checking trackUsage defaults and whether non-stream responses land tool_calls with finish_reason stop.
- Assistant
Reproducing the bug with a temporary test: tool_calls and finish_reason stop in the same chunk.
- Assistant
Inspecting the mock stream builder patterns used in tests.
- Assistant
Writing a temporary program to reproduce tool_calls arriving with finish_reason stop in one chunk.
- Assistant
Creating a temporary test to confirm the reproduction.
- Assistant
I need to check the mass of Telemetry interface methods.
- Assistant
I'll check agent.New's signature and fix the temporary test.
- Assistant
Fixing the temporary test to match agent/telemetry signatures.
- Assistant
Setting up the Go module cache next.
- Assistant
Confirmed: tool_calls in the same chunk as finish_reason stop are dropped. Fixing handleStream to process deltas before handling the finish reason.
- Assistant
Refactoring the stream loop so deltas are processed before finish_reason stop.
- Assistant
Verifying the rest of the file for leftover or duplicate code.
- Assistant
The for-loop closing brace was lost during the edit — restoring it.
- Assistant
Running the reproduction test and related streaming tests.
- Assistant
Repro passes. Running a broader set of runtime tests, then removing the temporary test file.
- Assistant
Some tests failed — identifying which ones.
- Assistant
Only one failed test - TestDoCompactAfterHookFires. Checking whether it's related to my change or flaky.
- Assistant
Checking whether that test fails on clean HEAD without my changes.
- Assistant
The compaction failure is pre-existing. I'll harden a few more edge cases in the temp test, then remove it.
- Assistant
All edge cases pass. Cleaning up the temp test and running gofmt plus transfer-task related tests.
- Assistant
Verifying final state before submit.
- Assistant
Re-running the reproduction once more to confirm cleanup.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.