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 uses to get the changes that need to be submitted. Assistant
Let me start by understanding the repository structure and the issue. The issue is about subagent
tool_callsnot being handled when using LiteLLM proxy. The host agent reports "no response from subagent" even though the subagent response contains validtool_calls.Let me explore the repository first.
Assistant
Let me search for the error message "no response from subagent" to find the relevant code
Assistant
Let me search more broadly for the error message:
Assistant
Let me search for "no response" and "tool_calls" in the code
Assistant
I need to combine these into a single command.
Assistant
Let me search for "no response from subagent" across all files
Assistant
Let me look at the agent_delegation.go file which handles subagents
Assistant
Let me search for "no response" more broadly in all files
Assistant
Let me look at streaming.go and loop.go where subagent responses are likely
Assistant
Now let me look at the loop.go file to see how subagent responses
Assistant
Let me see the rest of loop.go, particularly the message loop iteration
Assistant
Let me look at the middle part of loop.go which I didn't see.
Assistant
Let me continue reading the runTurn function and look for where tool calls from subagents could be missed.
Assistant
Let me search for "no response" in a case-insensitive manner and also look at the chatserver code
Assistant
Let me search more carefully
Assistant
Let me look at the Gemini adapter since the issue involves LiteLLM proxy and gem
Assistant
Let me look at the gemini adapter
Assistant
Let me look at the gemini adapter.go
Assistant
Let me look at the tools/builtin/agent package and how agent results are handled
Assistant
Let me look at agent.go to see how results are processed.
Assistant
Let me look at the OpenAI provider to understand how tool_calls responses are processed
Assistant
Let me look at the OpenAI adapter.go
Assistant
Let me look at the oaistream package
Assistant
Let me look at the oaistream adapter.go
Assistant
Let me search for more variations of the error message
Assistant
Let me look at the GetLastAssistantMessageContent function
Assistant
Let me look at the session.go implementation
Assistant
Let me look at processToolCalls
Assistant
Let me look at tool_dispatch.go
Assistant
Let me look at the toolexec dispatcher
Assistant
Let me search for where "no response" appears more carefully across the whole project
Assistant
Let me check where the stream adapter is created with trackUsage
Assistant
Let me look at the response_stream.go for OpenAI
Assistant
Let me check the CHANGELOG for related fixes and also look more at how finish_reason is handled in streaming
Assistant
Let me look at the full EOF path in
Assistant
Let me look at how the OpenAI client creates the stream and sets usage options
Assistant
Let me look at a specific potential issue - what happens when tool_calls arrive in the same chunk as the finish_reason. Let me trace through the code very carefully
Assistant
Let me look at the OpenAI client's stream creation code more carefully
Assistant
Let me check the FinishReason values
Assistant
Let me look at the oaistream adapter tests
Assistant
Let me search the entire codebase with broader terms
Assistant
Now I have a good understanding of the issue. Let me trace through the specific scenario that causes the bug. The problem is in
pkg/runtime/streaming.go: the early return onfinish_reason == "stop"happens BEFORE the tool_calls from the current delta are processed. When a single chunk contains both tool_calls AND a finish_reason (which happens when the OpenAI adapter bundles usage + finish_reason "stop" with tool_calls delta), the tool_calls are lost.Let me verify this by looking at the exact code flow one more time
Assistant
Now I can clearly see the bug. The issue is in
pkg/runtime/streaming.go. When a chunk has bothFinishReason == "stop"(or"length") ANDDelta.ToolCalls, the early return at lines 132-148 fires BEFORE the tool_calls from that chunk are processed (lines 159-213). This means tool_calls are lost and the subagent finishes with no output.The fix is to reorder the processing: tool_calls from the delta should be accumulated BEFORE checking for finish_reason.
Let me implement
Assistant
Now I'll implement the fix. The key change is to reorder the processing: tool_calls must be accumulated BEFORE the early return check.
Assistant
I see some typos in my edit. Let me
Assistant
Let me fix both typos in a single command
Assistant
Let me verify the file looks correct
Assistant
Let me see the rest of the file to make sure everything is correct
Assistant
I see a duplicate line. Let me fix that.
Assistant
Let me fix the comment indentation issue
Assistant
Now let me try to build and run
Assistant
Let me check the Go
Assistant
Let me set up Go paths and try to build
Assistant
Let me set all required Go environment variables
Assistant
The build succeeds. Let me run the runtime
Assistant
Let me see which tests are failing
Assistant
Let me see the specific failures
Assistant
Let me check if this test failure is pre-existing by looking at it
Assistant
Let me verify if this test was failing before my change by checking
Assistant
The test failure is pre-existing and not related to my change. Let me restore my fix
Assistant
Now let me also verify my understanding of the oaistream adapter to see if there's a related issue there. Let me check if the adapter's blanking logic could be improved for the case where finish_reason "stop" arrives with tool_calls and usage in the same chunk.
Assistant
Let me also check the Anthropic adapter for a similar issue
Assistant
Now let me run the streaming-related tests to make sure my change doesn't break them
Assistant
All streaming tests pass. Let me also run the oaistream adapter tests
Assistant
Let me run the OpenAI
Assistant
Let me do a final review of the complete streaming.go file
Assistant
Let me verify the build and run all tests
Assistant
Let me see the final diff of my changes
Assistant
Let me fix the minor typo in the comment
Assistant
Let me do a final build check
Assistant
All tests pass. My fix is complete. Let me provide a summary of the changes:
Summary
Issue: Subagent
tool_callsnot handled when using LiteLLM proxy (OpenAI-compatible API). The host agent reports "no response from subagent" because tool_calls are silently dropped.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.