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,submitonly 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
Now let me look for the "no response from subagent" message. It might be in the agent tool.
Assistant
Let me look at
GetLastAssistantMessageContentin the session package.Assistant
Let me look at the agent tool and how the run result is used by the host.
Assistant
Let me look at the runtime loop to understand how tool_calls are detected and handled.
Assistant
Assistant
I found the key code. Let me look at the streaming loop more carefully. I see the early-return on
FinishReasonStophappens BEFORE the tool calls delta in the same chunk are processed.Assistant
Now I understand the bug. When a chunk contains both
FinishReason == "stop"ANDDelta.ToolCalls, the early return fires BEFORE the tool calls delta in that chunk are processed. Let me look at existing streaming tests to confirm.Assistant
No direct tests for handleStream. Let me look at how MessageStream is mocked in tests.
Assistant
Now let me create a temporary reproduction test to confirm the bug — a stream where tool calls and
finish_reason="stop"arrive in the same chunk.Assistant
Let me write a temporary reproduction test directly calling
handleStream.Assistant
defaultTelemetryis unexported. Let me usedefaultTelemetry{}since it's in the same package. Let me update the test.Assistant
Confirmed the bug. The tool call in the same chunk as
finish_reason="stop"is dropped (Stopped=true, 0 tool calls). Now let me fix the streaming code by reordering: process the delta (tool calls/content) BEFORE consulting the finish reason.Assistant
Now I'll restructure. Let me view lines 129 to 250 to get the exact range for editing. Let me open the file and do the edit.
Assistant
Now I'll replace lines 132-237 with the restructured version that processes the delta before consulting the finish reason.
Assistant
Wait! I made a serious mistake. In the content branch, the original code was:
tagIdx := strings.Index(choice.Delta.Content, " immutable")But the original code was
strings.Index(choice.Delta.Content, "<<")(the<<... actually let me re-check). The original was:tagIdx := strings.Index(choice.Delta.Content, "Assistant
I introduced a bug in the
strings.Indexcall — I wrote" immutable"instead of the original tag. Let me check the exact original bytes from git.Assistant
The terminal is rendering special characters oddly. Let me get the exact bytes with
od.Assistant
The original was
"<tool_call>"— wait,od -cshows:" < t o o l _ c a l l > "which is `"Assistant
Let me use sed to fix the search string.
Assistant
Oops, I wrote
"<<tool_call>"instead of `"Assistant
Now the line is
strings.Index(choice.Delta.Content, " immutable")— wait the od shows" < t o o l _ c a l l > "which is `"Assistant
Now the diff is clean. The
strings.Indexline now correctly showsstrings.Index(choice.Delta.Content, " immutable")— wait, the diff showsstrings.Index(choice.Delta.Content, " immutable"). Hmm, but the diff displays it as" immutable"? No, the diff showsstrings.Index(choice.Delta.Content, " immutable")— wait the diff output literally shows" immutable"? No. Let me look at the diff:tagIdx := strings.Index(choice.Delta.Content, " immutable"). Wait, the diff in the output showsstrings.Index(choice.Delta.Content, " immutable")?? Actually it showsstrings.Index(choice.Delta.Content, " immutable"). Hmm, the diff line is:+ tagIdx := strings.Index(choice.Delta.Content, " immutable")Wait no, the displayed diff shows
" immutable". But the od confirmed it's" immutable". There's a discrepancy because the terminal renders<<as something. Actually no. Theod -cclearly showed" < t o o l _ c a l l > "=" immutable". Wait, — that's the characters. The terminal display of is being shown as ? That doesn't make sense.Assistant
The reproduction test now passes. Let me add a couple more edge case checks to my temp test, then run the full runtime test suite.
Assistant
All edge cases pass. Now let me run the full runtime test suite to ensure nothing is broken.
Assistant
There's a failure. Let me find which test failed.
Assistant
Let me check whether this test was already failing before my change by stashing.
Assistant
TestDoCompactAfterHookFireswas already failing before my change — it's a pre-existing failure unrelated to my fix. Let me confirm there are no other failures introduced by my change.Assistant
Only the pre-existing failure remains. Let me also run related provider and e2e tests to be safe.
Assistant
TestNewSQLiteSessionStore_DirectoryNotWritableis likely an environment issue (running as root). Let me confirm both failures are pre-existing.Assistant
Both failures are pre-existing (environment-related, running as root). My change introduces no new failures. Now I must remove my temporary test file before submitting.
Assistant
Let me do a final review of the modified streaming.go file.
Assistant
The display renders the tag oddly. Let me re-verify the actual bytes one final time to be 100% sure.
Assistant
`. Let me run the build and the runtime tests one final time without the temp test file.
Assistant
Build passes and vet is clean. Now let me run the runtime tests one final time to confirm only the pre-existing failure remains.
Assistant
Only the pre-existing
TestDoCompactAfterHookFiresfailure remains (confirmed it fails without my change too, due to environment). Let me also run a broader sanity check across the openai provider tests since they relate to streaming.Assistant
All provider tests pass. Let me do a final review of the complete diff.
Assistant
The change is confined to
pkg/runtime/streaming.go. Let me review the complete final diff once more.Assistant
The diff is clean and correct. Let me verify there are no leftover temp files and submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.