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
Now let's view the rest of the tool-calls block to insert finish-reason handling and the
continueproperly after it.Assistant
Now let's view the full function to verify correctness:
Assistant
This looks correct. Now let's build and run tests for the runtime package.
Assistant
Build succeeds. Now let's run the runtime and streaming-related tests.
Assistant
Good, this test fails pre-existing (unrelated to my change), confirming it's not something I broke. Let's run the full runtime test suite again with my changes to make sure only this pre-existing failure occurs.
Assistant
Same pre-existing failure only. Now let's write a quick reproduction test using a mock stream to confirm the fix works, mimicking a single chunk with tool_calls + finish_reason "stop".
Assistant
Now let's write a quick temp test script to verify handleStream behavior with a single-chunk tool_calls+stop scenario.
Assistant
There's
defaultTelemetry{}I can use. Let's fix the test and check agent.New / NewChannelSink signatures.Assistant
Now let's verify the fix actually matters by testing against the old code (git stash) to confirm the test fails without the fix.
Assistant
Confirmed: without the fix, the tool call is dropped (0 calls) exactly matching the reported bug. With the fix, it's correctly captured. Now let's remove the temp test file and run full test suite once more.
Assistant
Only the pre-existing unrelated failure remains. Let's also run the oaistream and openai provider tests, and broader test suite for good measure.
Assistant
All good. Let's do a final review of the diff.
Assistant
This diff is clean and minimal, addressing the root cause. Let's also double check
git statusto ensure no stray files remain.Assistant
Clean. Now let's go through the checklist.
Checklist Review
- [x] If an error was reported in the issue description, I have successfully reproduced it.
I traced the bug to
pkg/runtime/streaming.go'shandleStreamfunction. I wrote a temporary reproduction test simulating a LiteLLM-style single chunk that carries both a fully-formedtool_callsdelta andfinish_reason: "stop"in the same chunk (matching the issue's described payload). Running this test against the original (unmodified) code confirmed the bug: the tool call was silently dropped (Calls: [],Stopped: true), exactly matching the "no response from subagent" / tool call not executed symptom described in the issue.
- [x] If an error was reported in the issue description, I have successfully reproduced it.
I traced the bug to
Assistant
- [x] If an error was reported in the issue description, I have confirmed that my fix resolves the error.
After reordering the logic so tool-call deltas are processed before the
finish_reason == stop/lengthearly-return check, the same reproduction test passed: the tool call was correctly captured (Callshas 1 entry) and the finish reason was correctly promoted totool_calls(since a stop reason with pending tool calls is inferred as a tool-call finish), withStopped: falseso the runtime loop proceeds to execute the tool.
- [x] If an error was reported in the issue description, I have confirmed that my fix resolves the error.
After reordering the logic so tool-call deltas are processed before the
Assistant
- [x] I have thought about edge cases and made sure my fix handles them as well.
- Normal OpenAI-style streaming (tool-call deltas spread across multiple chunks, with a final empty-delta chunk carrying
finish_reason: tool_callsorstop): behavior unchanged, since the finish-reason chunk normally carries noDelta.ToolCalls, sotoolCallsInChunkis false and thecontinueis skipped as before, falling through to reasoning/content handling (which is empty), same as before my change. - A chunk that carries tool-call deltas and a non-terminal (e.g., empty or some other value): tool calls are processed, is updated, and then we still since is true — same as the original code.
- Normal OpenAI-style streaming (tool-call deltas spread across multiple chunks, with a final empty-delta chunk carrying
- [x] I have thought about edge cases and made sure my fix handles them as well.
Assistant
- [x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
Ran
go build ./...(succeeds),go vet ./pkg/runtime/...(clean),go test ./pkg/runtime/...andgo test ./pkg/model/.... All tests pass exceptTestDoCompactAfterHookFires, which I verified fails identically on the unmodifiedmainbranch (viagit stash) — i.e., it is a pre-existing, unrelated failure, not something introduced by my change.
Let's do one final full diff review and confirm no leftover temp files before submitting.
- [x] I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
Ran
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.