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 usesgit diffto get the changes that need to be submitted. - Assistant
I’ll first map the repository and search for subagent response handling, especially logic that equates empty textual content with “no response” and may overlook
tool_calls. Then I’ll reproduce the behavior with the narrowest existing test path, patch it, and run relevant tests. - Assistant
rgis unavailable, so I’ll use recursivegrepand focus on Go sources. I’ll also inspect repository guidance before editing. - Assistant
The likely failure boundary is the OpenAI-compatible streaming adapter: LiteLLM emits a valid tool-call delta but may end with
finish_reason: "stop"rather than"tool_calls". I’ll inspect the adapter and stream accumulator to see whether calls are discarded or the response is classified as empty based on that inconsistent finish reason. - Assistant
The adapter does preserve tool-call deltas, so the next key is finish-reason handling in runtime sampling. If runtime only finalizes accumulated calls on
tool_calls, LiteLLM’s nonstandardstopwill explain the exact symptom. I’ll inspect that code and existing adapter/runtime tests for a suitable regression scenario. - Assistant
The runtime loop consumes a normalized
streamResultproduced by the fallback/stream processor, notsampling.go. I’ll locate that accumulator and its treatment ofFinishReasonStop, then make the fix at the most provider-specific or general layer appropriate. - Assistant
The current branch already contains normalization from
stoptotool_callswhen calls were accumulated, suggesting the remaining bug may be earlier: LiteLLM can return tool calls in a non-streaming-shaped payload or with missing indices, causing the accumulator to lose them. I’ll read the full accumulator and its tests/history context before deciding. - Assistant
Normalization is already present in
handleStream, but there is no regression test for a structured tool call followed bystop. More importantly, the accumulator keys calls solely bydelta.ID; OpenAI-compatible proxies often stream all fragments with IDs handled, and adapter fills IDs. The issue explicitly says a complete valid tool-call object andstop, which should now work. I’ll inspect the commit that introduced “fallback on stream end” to determine whether this checkout already has an incomplete attempted fix and identify what remains untested/broken—particularly whether a tool call and finish reason can occur in the same chunk. - Assistant
I found a concrete reproduction path:
handleStreamchecks terminalstopbefore reading that chunk’sDelta.ToolCalls. LiteLLM can place the complete tool call andfinish_reason: "stop"in the same response/chunk; runtime immediately returns with zero calls and empty content, producing exactly “no response from subagent.” I’ll reorder aggregation so every terminal chunk’s payload is consumed before its finish reason is acted on. This also safely preserves terminal content/reasoning deltas. - Assistant
The fix is in place. I noticed a nearby comment now incorrectly says terminal reasons are handled “above”; I’ll update that wording, then run the runtime and OpenAI-compatible provider test suites. Existing
TestToolCallSequencealready covers the separate-chunk LiteLLM shape, while code inspection establishes the same-chunk reproduction that was previously dropped. - Assistant
Tests are blocked only because this environment has neither
GOMODCACHEnorGOPATHconfigured. I’ll set an isolated writable GOPATH under/tmpand rerun the relevant suites; this does not alter repository files. - Assistant
Dependencies downloaded successfully, but Go also requires a build cache and this stripped environment has no
HOME. I’ll configure both temporary cache variables and rerun; downloaded modules in/tmp/gopathwill be reused. - Assistant
Compilation and all six provider suites passed. The broad runtime suite had one unrelated pre-existing compaction-hook failure (
TestDoCompactAfterHookFires, expected hook summary but got empty); the tool-call tests themselves progressed through execution paths. I’ll rerun only affected runtime tests to get a clean signal, including plain stop/content behavior and tool-call variants. - Assistant
The affected runtime tests pass, provider suites pass, formatting is clean, and only the intended source file is modified. I’ll perform a repository-wide build as the final technical check. If successful, I’ll review the checklist explicitly and submit.
- Assistant
The full repository build passes. For an executable confirmation of the exact same-chunk LiteLLM shape without adding or changing tests, I’ll run a temporary external Go probe that links to the stream aggregator, feeds one response containing both a complete
tool_callsdelta andfinish_reason: stop, and asserts it returns one executable call normalized totool_calls. The probe lives only in/tmp. - Assistant
The aggregator’s dependencies can be supplied without network or session runtime. I’ll now execute the temporary probe; if Go’s linker blocks access to an unexported symbol, I’ll rely on the passing affected tests and direct control-flow verification rather than weakening production visibility just for testing.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.