Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Subagent toolcalls not handled when using LiteLLM proxy Summary When…

  1. 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_calls response, 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_calls entry. The requested tool call is not executed.

    Minimal reproduction

    1. Configure cagent to use LiteLLM as the model provider (OpenAI-compatible API).
    2. Run a workflow where the subagent is asked to use tools.
    3. The subagent returns a tool call (e.g., company_search with JSON arguments) and finishes with finish_reason: "stop".
    4. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /docker-agent, current file: none) bash-$

  2. Claude Assistant

    Downloading deps - let's wait and check build result.

  3. Claude Assistant

    Build succeeds. Now let's run existing tests related to streaming.

  4. Claude Assistant

    Let's see which test failed specifically.

  5. Claude Assistant

    Good - this test fails even without my changes (pre-existing flaky/failing test unrelated to my change). Not something I introduced. Now let's run the streaming-specific tests to be thorough.

  6. Claude Assistant

    All relevant tests pass. Now let's write a quick reproduction script to verify the fix directly targets the reported bug: a mock stream where the chunk carrying tool_calls also carries finish_reason "stop".

  7. Claude Assistant

    Good, ToolCallEvent exists. Let's run this repro test with the fix, then temporarily revert the fix to confirm it fails without it.

  8. Claude Assistant

    Confirmed: PartialToolCallEvent and ToolCallResponseEvent fire — meaning the tool call was processed and dispatched (with an error because "company_search" isn't a real tool in this fake team, but that's expected). The fix works. Let's update the repro test's assertion to look for ToolCallResponseEvent, then verify it fails without the fix.

  9. Claude Assistant

    Now let's confirm this fails without the fix (i.e., before our change).

  10. Claude Assistant

    Confirmed: the bug reproduces without the fix and is resolved with it. Now let's clean up the temporary test file and re-run the full test suite for the runtime package.

  11. Claude Assistant

    Same pre-existing failure (confirmed earlier unrelated to our change, exists on baseline too). Let's run broader test suite across related packages (chat, model providers) to be safe.

  12. Claude Assistant

    All passing. Let's view the final diff for review.

  13. Claude Assistant

    This is a clean, minimal, behavior-preserving refactor that fixes the bug. Let's double check git status to ensure no leftover temp files.

  14. Claude Assistant

    Clean. Now let's run gofmt / goimports check on the modified file.

  15. Claude Assistant

    Formatting is clean. Now let's go through the checklist.

  16. Claude Assistant

    Checklist review

    • If an error was reported in the issue description, I have successfully reproduced it. Yes. I traced the bug to pkg/runtime/streaming.go's handleStream function: it checked choice.FinishReason == stop/length and returned before processing that same chunk's Delta.ToolCalls. Vanilla OpenAI splits the final tool-call delta and the finish_reason into two separate chunks, so this ordering normally works — but LiteLLM (proxying Gemini) sends the last tool-call delta together with finish_reason: "stop" in the same chunk. I wrote a temporary test (zz_repro_test.go, removed afterward) with a mock stream chunk carrying both Delta.ToolCalls and FinishReason: chat.FinishReasonStop in one response, ran it against the original code, and confirmed no ToolCallResponseEvent was emitted — i.e., the tool call was silently dropped, matching "the requested tool call is not executed."

    • If an error was reported in the issue description, I have confirmed that my fix resolves the error. Yes. After extracting the tool-call-delta processing into a processToolCallDeltas closure and invoking it before the finish-reason check (instead of after), the same repro test now passes: the tool call is recorded, a PartialToolCallEvent and ToolCallResponseEvent are emitted, and the dispatcher attempts to execute it. I re-verified by stashing the fix (test fails) and popping it back (test passes).

    • I have thought about edge cases and made sure my fix handles them as well. Yes:

      • Chunks that split tool-calls and finish_reason across two separate messages (the normal OpenAI behavior) still work identically, since processToolCallDeltas just returns false for chunks with no tool-call deltas and behavior falls through unchanged.
      • Chunks with FinishReason: "tool_calls" (not stop/length) are unaffected — they still fall through to the providerFinishReason tracking and continue when they carry a tool-call delta.
      • The applyXMLFallback / EOF path (post-loop) is untouched.
      • The Stopped/FinishReason conversion logic (stop + tool calls present → tool_calls) still applies correctly since toolCalls is now populated before that check runs.
      • I confirmed via go build ./... and package-wide tests that nothing else regressed.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. Yes. Ran go test ./pkg/runtime/..., ./pkg/model/..., ./pkg/chat/.... All passed except a pre-existing failure (TestDoCompactAfterHookFires) that I confirmed also fails on the unmodified baseline (via git stash), so it's unrelated to this change and outside the scope of this fix.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.