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
I’ll first map the repository and search for subagent response handling, LiteLLM/OpenAI adapters, and the “no response from subagent” message. Then I’ll trace and reproduce the response conversion path before changing code.
- Assistant
rgis unavailable, so I’ll usegrep/find. I’ll also read the repository’s contribution instructions before narrowing the relevant Go packages and tests. - Assistant
The user-visible phrase may be model-generated rather than a literal. The likely path is the built-in agent delegation tool plus runtime streaming and OpenAI-compatible response conversion, so I’ll inspect those implementations and their tests together.
- Assistant
The previous combined output was truncated. I’ll focus on model-provider architecture and the delegation result assembly, especially where a final assistant message is selected and whether tool-call-only messages are treated as empty.
- Assistant
The runtime already has safeguards for providers that emit
finish_reason=stopwith tool calls, so the key is whether the OpenAI-compatible adapter preserves those calls. I’ll inspect the exact aggregation logic and adapter code, then compare tests around malformed/nonstandard finish reasons. - Assistant
The shared adapter is the critical boundary. The reported payload is a chat-completions stream where LiteLLM incorrectly/noncanonically labels a tool-call chunk with
stop. I’ll read the adapter without truncation and the runtime’s final consistency rules to establish whether the calls are dropped at adaptation or merely not executed. - Assistant
I’ve reproduced the bug at code level:
handleStreamchecksfinish_reasonbefore processing that same chunk’sdelta.tool_calls. LiteLLM’s valid combined chunk (tool_callsplusfinish_reason: "stop") therefore returns with zero calls. The adapter preserves the payload; aggregation drops it. I’ll inspect test helpers and adjacent aggregation tests so the fix follows existing patterns, without modifying tests per the environment constraint. - Assistant
The minimal general fix is to process every delta before honoring a terminal finish reason. This also correctly preserves content if an OpenAI-compatible endpoint combines content and termination in one chunk. I’ll move—not duplicate—the terminal-return block to after delta aggregation, retaining the existing normalization from
stoptotool_callswhenever calls were observed. - Assistant
The diff exposes one stale comment that still says stop/length are handled “above”; I’ll correct it. Then I’ll run the focused runtime and shared OpenAI-stream test suites. Existing runtime tests exercise split tool-call chunks and the full execution loop, while the adapter tests verify payload conversion.
- Assistant
The focused tests did not start because this environment has neither
GOPATHnorGOMODCACHEconfigured. I’ll supply a temporary standard Go cache location and rerun; this changes no repository files. - Assistant
Compilation succeeded and three focused packages passed, but the broad runtime/OpenAI run hit two unrelated environment/test issues: an existing compaction assertion failed, and OpenAI tests panic when
$HOMEis unset. I’ll now run only the runtime tool-stream tests that exercise the modified function, with a temporaryHOME, plus the provider suites again. I’ll also inspect the changed logic for an edge case: multiple calls, fragmented arguments, and combined content/tool deltas. - Assistant
The changed path now aggregates all call entries and arguments before normalization; multiple calls remain keyed by their IDs, and fragmented calls continue to use the adapter’s index-to-ID restoration. I’ll run the focused tests with
HOMEset, including tool-call sequence/variation, response API handling, and all shared adapter/background-agent tests. - Assistant
Focused tests all pass. Before finalizing, I’ll run the repository’s standard build target and inspect the exact final diff. I’ll also check whether the standard test task supplies environment isolation that avoids the unrelated broad-test failure seen with raw
go test.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.