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
Let me explore the repository structure to understand the codebase.
Assistant
Let me search more broadly.
Assistant
No results. Let me look for "subagent" in the codebase.
Assistant
Let me search for the "no response" message variants.
Assistant
The "No response from agent" message in mcp/server.go is one place. But the issue says "no response from subagent". Let me look at the run_skill and handoff and agent tools more broadly. Let me search for the agent tool builtin.
Assistant
Let me look at the runtime loop and how it processes the model stream, finish_reason, and tool_calls.
Assistant
Let me see the middle part of loop.go that was truncated.
Assistant
Let me look at how
res.Stoppedandres.Callsare populated from the stream, especially the OpenAI-compatible client.Assistant
The
handleStreamalready has logic to reconcilefinish_reason: "stop"with tool calls. But there's a subtle bug: the early-return branch checksfinish_reasonBEFORE processing thedelta.tool_callsin the same chunk. Let me look at the streaming tests to understand expected behavior.Assistant
Let me find the mock stream used in tests to understand chunk structure.
Assistant
Let me look at an existing test that calls
handleStreamdirectly to understand the test setup.Assistant
Now let me find a test that directly calls
handleStreamto set up a quick reproduction. Let me search more broadly.Assistant
Let me see how
handleStreamis called and what parameters it needs.Assistant
Let me look at test helpers for creating sessions, agents, telemetry, and sinks.
Assistant
Let me look at the Telemetry interface and an existing mock for tests.
Assistant
Now let me write a reproduction test. First, let me check the chat message structures.
Assistant
Now let me write a reproduction test in the runtime package.
Assistant
Let me check NewLocalRuntime signature - it might need a team. Let me check.
Assistant
I've reproduced the bug. The tool call delta is dropped because the
finish_reasonearly-return check happens BEFORE the tool call delta is processed. Let me fixhandleStream.Assistant
I've confirmed the bug. Now let me fix
handleStreamby moving the tool-call delta processing BEFORE thefinish_reasonearly-return check, so tool calls in the same chunk asfinish_reason="stop"are not dropped. Let me view the exact lines to replace.Assistant
Now I'll reorder the loop body so tool-call deltas are processed BEFORE the
finish_reasonearly-return check. This ensures tool calls arriving in the same chunk asfinish_reason="stop"(as LiteLLM proxy does) are not dropped.Assistant
Let me reconsider — I'll keep the
continuein the tool-call block to preserve existing behavior, only reordering so tool calls are processed before the finish_reason check. Let me redo the replacement.Assistant
The reorder looks correct. Now let me run the reproduction test again.
Assistant
The build may be slow/timing out fetching modules. Let me check if the module cache is populated.
Assistant
Build succeeds. The test command may have been slow due to vet/compile of the whole test binary. Let me run with a longer timeout.
Assistant
The test binary compilation may be slow. Let me try building the test binary explicitly.
Assistant
The test binary compiled. Now let me run the reproduction test against it.
Assistant
The test is hanging—likely the event sink blocks. Let me check
NewChannelSinkwith a nil channel.Assistant
The
channelSinkblocks on a nil channel. Let me fix my reproduction test to use a no-op sink.Assistant
The fix works. The reproduction test now passes:
Stopped=false Calls=1 FinishReason="tool_calls". Now let me verify I didn't break existing tests by running the broader runtime test suite.Assistant
All those tests pass. Now let me run the full runtime test suite to make sure nothing else broke.
Assistant
There's a FAIL. Let me find which test(s) failed.
Assistant
Let me check whether this test was already failing before my change. Let me stash my changes and run it.
Assistant
This test fails on the original unmodified code too — it's a pre-existing failure unrelated to my change. Let me restore my changes.
Assistant
The pre-existing failure is unrelated. Let me confirm my change doesn't introduce any new failures by running the full suite and listing all failures.
Assistant
Only the pre-existing failure remains. Let me verify a few edge cases to ensure robustness: tool calls split across chunks with
finish_reason="stop"in a separate chunk, and a normal stop with no tool calls.Assistant
All edge cases pass. Let me also check the OpenAI provider's stream construction to ensure non-streaming responses that are converted to a stream put tool_calls and finish_reason in the same chunk (which my fix handles correctly).
Assistant
Let me check how the standard OpenAI chat completions client converts a non-streaming response into a stream, to confirm whether tool_calls and finish_reason land in the same chunk.
Assistant
The fix is in the provider-agnostic
handleStream, covering both the OpenAI chat completions and Responses API paths. Now let me remove the temporary reproduction test (per guidelines, I should not add tests) and do a final build check.Assistant
Let me view the final diff to confirm the change is clean.
Assistant
The diff is clean and minimal. Let me verify the final git status and that no temp files remain.
Assistant
Now let me run the most relevant runtime tests one final time to confirm nothing is broken by my change (excluding the pre-existing unrelated failure).
Assistant
Only the pre-existing, unrelated
TestDoCompactAfterHookFiresfailure remains (it fails identically on the original unmodified code).Let me do a final review of the complete fix.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.