Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging 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.

    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. Assistant

    I'll start by exploring the repository to understand its structure and locate relevant code. Let's first get an overview.

  3. Assistant

    The repository seems to be a Rust project. Let me look at the overall structure.

  4. Assistant

    This is a Go project. Let me explore further to understand the structure, especially related to LiteLLM proxy, subagent tool calls, and the OpenAI-compatible API handling. Let me look at the README and main packages.

  5. Assistant

    Let me explore the repository structure more and look for where subagents and tool_calls handling happens.

  6. Assistant

    This is a Go project. The issue is about subagent tool_calls not being handled when using LiteLLM proxy. Let me look at the agent and subagent-related code.

  7. Assistant

    Let me look at the agent delegation code since that's likely where the subagent tool calls are processed.

  8. Assistant

    Let me search for related terms.

  9. Assistant

    Let me search more broadly.

  10. Assistant

    The error message mentioned in the issue description is "no response from subagent". Let me search more broadly.

  11. Assistant

    So the issue is about "No response from agent" messages. Let me look at these files to understand the flow.

  12. Assistant

    Now let me look at the error message in the issue description: "no response from subagent". Let me search for that pattern more broadly.

  13. Assistant

    The issue is about tool_calls from subagents not being handled when using LiteLLM proxy. The key part is that the subagent returns a valid tool_calls response, but the host agent reports "no response from subagent" and does not execute the tool call.

    Let me look at the model/provider layer to understand how responses are processed, particularly around tool_calls handling.

  14. Assistant

    The error message is "No response from agent", not "no response from subagent". Let me look at how the tool_calls are handled. The issue says that subagent returns valid tool_calls response but the host agent reports "no response from subagent". Let me search for how the response content is extracted.

  15. Assistant

    Let me look at the session.go file to understand how GetLastAssistantMessageContent works.

  16. Assistant

    Let me look at the GetLastAssistantMessageContent method to understand how it works:

  17. Assistant

    Let me check that function to see what it does.

  18. Assistant

    Now I see the issue! The GetLastAssistantMessageContent() returns Content field only, not ToolCalls. When the subagent returns only tool_calls (empty Content), this function returns an empty string.

    Let me look at the runtime loop to understand how tool calls are processed.

  19. Assistant

    Let me look at the runtime loop more closely to see where tool calls are handled. Let me look at the main loop structure.

  20. Assistant

    Let me look at the rest of the loop to understand how tool calls are handled. Y

  21. Assistant

    Let me look at the loop code to understand how tool calls are handled.

  22. Assistant

    Let me see the rest of the loop to understand how tool calls are processed.

  23. Assistant

    Let me continue reading the runTurn function to understand how tool calls are handled.

  24. Assistant

    Let me continue reading the runTurn function to see how tool calls are processed.

  25. Assistant

    Now let me look at the MCP server to understand the "No response from agent" message:

  26. Assistant

    Now I understand the issue better. Looking at the flow:

    1. The subagent returns a response with tool_calls (and empty text content)
    2. The tool calls should be executed within the subagent's own loop
    3. After the subagent completes, GetLastAssistantMessageContent() returns the last assistant message's text content

    But the issue says the host agent reports "no response from subagent" and does not execute the tool call. This suggests that the subagent's tool calls are NOT being executed. Let me check how res.Stopped is determined, because if the model reports finish_reason: "stop" even when there are tool calls, the loop might stop before executing them.

  27. Assistant

    Now let me look at the streamResult type and how Stopped is set:

  28. Assistant

    Let me look at the streamResult type and how Stopped is set.

  29. Assistant

    Now let me look at how the OpenAI provider handles streaming and check for LiteLLM-specific issues:

  30. Assistant

    Now let me look at the OpenAI adapter to understand how tool calls are processed:

  31. Assistant

    Let me look at the streaming adapter to see how it converts OpenAI responses to chat.Message.

  32. Assistant

    Let me look at the streaming adapter:

  33. Assistant

    Now let me understand the key flow. Let me check the response_stream.go for non-streaming responses:

  34. Assistant

    Let me now look at how Stopped is used in the runTurn function more carefully:

  35. Assistant

    Now I need to understand the flow. The key issue is likely around how finish_reason is handled. Let me look at how FinishReasonStop is defined:

  36. Assistant

    Now let me look at processToolCalls to understand how tool calls are executed:

  37. Assistant

    Let me look at the tool dispatch code:

  38. Assistant

    Let me look at the handleStream function more carefully to understand when it sets Stopped to true when tool calls are present. The key issue may be in the OpenAI adapter's handling of finish_reason: "stop" with tool calls:

  39. Assistant

    Now I understand the issue! Let me trace through the exact flow. In handleStream (streaming.go), the finish_reason is checked BEFORE tool calls are processed from the current chunk. When LiteLLM sends tool calls and finish_reason: "stop" in the SAME chunk, the tool calls from that chunk are never processed because the early return fires first.

    Let me verify this by looking at the exact ordering in handleStream:

  40. Assistant

    Now I have a clear understanding of the bug. Let me look at the full handleStream function to see the exact order of operations:

  41. Assistant

    Now I understand the root cause. In handleStream (streaming.go), when a chunk contains BOTH tool_calls AND finish_reason: "stop", the finish reason check fires BEFORE the tool call processing, causing the tool calls to be lost. This is exactly what happens with LiteLLM proxy.

    Let me first create a reproduction script to confirm the bug:

  42. Assistant

    Let me examine more closely what happens when LiteLLM sends a response. Let me look at how the OpenAI SDK handles the conversion:

  43. Assistant

    Let me look at the exact flow in handleStream more carefully. The key issue is the ordering - when LiteLLM sends both tool_calls and finish_reason: "stop" in the SAME streaming chunk, the finish_reason check happens before tool_calls are accumulated:

  44. Assistant

    Now I can see the bug clearly. When LiteLLM sends a chunk with BOTH tool_calls in choice.Delta.ToolCalls AND finish_reason: "stop" in the SAME chunk, the code hits the FinishReason == "stop" check FIRST (line 132) and returns immediately. The tool calls from that chunk (line 155) are NEVER processed because they come AFTER the early return. Since len(toolCalls) == 0 at that point, Stopped is set to true and the tool calls are lost.

    The fix is to process tool calls BEFORE checking the finish reason. Let me implement this:

  45. Assistant

    Now I understand the bug completely. The fix is to move the tool call processing BEFORE the finish reason check. Let me implement the fix:

  46. Assistant

    The indentation is wrong - it's missing the leading tab for the loop body. Let me fix it:

  47. Assistant

    I need to fix the indentation. The code inside the for loop needs two tabs. Let me fix this:

  48. Assistant

    Good. Now let me verify the rest of the file is clean - there should be no duplicate tool call processing code after the new blocks:

  49. Assistant

    There's a duplicate - the old code was left behind. I need to remove the old blocks (lines 215-292):

  50. Assistant

    I see there's broken code around lines 212-215. Let me fix the leftover junk:

  51. Assistant

    I still see a structural issue. Lines 203-212 have the return statement with missing }, nil and there's leftover code. Let me fix the remaining issue:

  52. Assistant

    Now the file looks correct. Let me verify the full file structure is correct:

  53. Assistant

    Good. The file looks clean. Now let me verify the changes compile correctly:

  54. Assistant

    Let me set up the Go environment:

  55. Assistant

    Let me try to set up the Go environment properly.

  56. Assistant

    Let me set up the environment properly:

  57. Assistant

    Good, the build succeeds. Now let me run the existing tests to make sure the changes don't break anything:

  58. Assistant

    Let me run the full test suite for the streaming module:

  59. Assistant

    Let me check if there are specific handleStream tests:

  60. Assistant

    Let me search for tests that test handleStream directly:

  61. Assistant

    Let me look at the streaming-related tests:

  62. Assistant

    Let me search for the handleStream tests:

  63. Assistant

    Let me search for existing tests related to handleStream with tool calls:

  64. Assistant

    Let me check the existing tests to see if any test the streaming tool_calls behavior:

  65. Assistant

    Now let me run the full test suite for the runtime package to verify my changes don't break anything:

  66. Assistant

    Let me see which tests failed:

  67. Assistant

    The test TestDoCompactAfterHookFires is failing. Let me check if this is related to my change:

  68. Assistant

    This test failure looks like it might be pre-existing or related to session compaction. Let me check if it was already failing before my change:

  69. Assistant

    Good - this test was already failing before my change (pre-existing issue). Let me restore my changes and run all other tests:

  70. Assistant

    Let me run all the runtime tests excluding the pre-existing failing one:

  71. Assistant

    The ! in the regex is causing bash issues. Let me escape it.

  72. Assistant

    All tests pass (except the pre-existing failure). Let me also run the streaming-specific tests:

  73. Assistant

    Good. Let me now also check that the existing tests that specifically test tool_calls and handleStream behavior pass:

  74. Assistant

    All tool-call related tests pass. Let me also run tests for the full project (excluding slow tests):

  75. Assistant

    Let me check if the config failure is pre-existing:

  76. Assistant

    Good - the config failure is pre-existing (failing without my changes too). Let me restore my changes:

  77. Assistant

    Good. Now let me run the streaming-related tests specifically to make sure my changes work correctly:

  78. Assistant

    All tool-call related tests pass. Let me also run the oaistream adapter tests:

  79. Assistant

    All tests pass. Let me now review the final state of my changes:

  80. Assistant

    The diff looks clean and correct. Let me now verify the full file is syntactically correct by building:

  81. Assistant

    Good, build succeeds. Let me also run the full runtime tests one more time to be sure:

  82. Assistant

    Let me verify the only failure is the pre-existing one:

  83. Assistant

    The only failure is the pre-existing TestDoCompactAfterHookFires. My change is clean.

    Now let me verify the complete diff one more time and review the logic:

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