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 the "no response from subagent" message.
- Assistant
It's a Go project called cagent. Let me search for the "no response from subagent" message and related subagent handling code.
- Assistant
rg is not available, let me use grep instead.
- Assistant
Let me look at the agent_delegation.go and related runtime files.
- Assistant
Let me read the agent_delegation.go file more carefully, especially the part about "no response".
- Assistant
The issue seems related to GetLastAssistantMessageContent returning empty when subagents only have tool_calls. Let me investigate further.
- Assistant
Let me examine GetLastAssistantMessageContent and the LiteLLM/OpenAI provider tool call handling.
- Assistant
The issue mentions finish_reason "stop" with tool_calls — LiteLLM may not use "tool_calls". Investigating how the runtime handles that.
- Assistant
Let me search more carefully for the exact error message and agent tool handling.
- Assistant
Let me look at the CHANGELOG for related fixes, and also look at the OpenAI streaming adapter for tool call handling - maybe LiteLLM sends tool calls differently.
- Assistant
Let me look at the streaming code more carefully and also git log for recent commits related to this. Also search git history or issues.
- Assistant
I suspect tool_calls on the same chunk as finish_reason "stop" are dropped. Verifying that and related provider streaming code.
- Assistant
Let me carefully review the oaistream adapter and any existing tests covering tool_calls combined with finish_reason stop.
- Assistant
Checking when trackUsage is enabled and whether tool calls can arrive with finish_reason on the same chunk.
- Assistant
I think the bug is processing finish_reason before tool_call deltas on the same chunk. Let me confirm and check related tests.
- Assistant
Let me check the recent Gemini parallel tool-response fix and presentations around empty amounts of subagent response.
- Assistant
Let me search for more related message strings and transfer_task handling.
- Assistant
I'll write a temporary reproduction test for handleStream when tool_calls arrive with finish_reason stop on the same chunk.
- Assistant
I'll create a temporary test to reproduce the same-chunk tool_calls + finish_reason stop issue.
- Assistant
Let me check how agent.New works and write a proper temp testinside thepackage.
- Assistant
Let me write the test file in the package and run it.
- Assistant
Need to set GOPATH or GOMODCACHE.
- Assistant
Reproduced: tool_calls on the same chunk as finish_reason "stop" are dropped. Fixing handleStream to process tool-call deltas before the early finish_reason return.
- Assistant
I'll reorder the stream loop so all deltas are applied before handling finish_reason.
- Assistant
Checking whether the edit left any duplicate code.
- Assistant
The for-loop closing brace is missing. Fixing that.
- Assistant
Rerunning the reproduction test and related runtime tests.
- Assistant
Reproduction passes. Running more edge cases and existing runtime tests, then removing the temporary test file.
- Assistant
Some tests failed. Checking which ones.
- Assistant
Only one failure. Checking if it was pre-existing.
- Assistant
The failure is pre-existing. Removing the temporary test and verifying the final diff.
- Assistant
Running tool-call related tests and a build to verify nothing broke.
- Assistant
There's something weird with openai package tests - panic relatedسيا to desktop. Let me check the exit status更多 carefully and if build succeeded.
- Assistant
Confirming the final file is clean, then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.