Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue. The issue is about subagent tool_calls not being handled when using LiteLLM proxy. Let me explore the repository first.

    The repository seems to be "cagent" (or "cagent" could be "cagent" - the C implementation of an AI agent). Let me explore the structure.

    Actually, looking at the issue description more carefully:

    • cagent: v1.19.7
    • The subagent returns a valid tool_calls response but the host agent reports "no response from subagent"

    Let me explore the repository structure first.

  3. DeepSeek Assistant

    This is a Go project. Let me explore the structure more. The issue mentions "subagent" and "tool_calls". Let me search for relevant code.

  4. DeepSeek Assistant

    I need to make only one tool call at a time. Let me search for "no response from subagent" first.

  5. DeepSeek Assistant

    Let me try broader searches - case-insensitive and partial matches

  6. DeepSeek Assistant

    Let me search for "subagent" related code:

  7. DeepSeek Assistant

    Let me search for the exact error message or similar messages:

  8. DeepSeek Assistant

    Let me look at the agent_delegation.go file - this seems central to the issue

  9. DeepSeek Assistant

    Now let me look at the session package, particularly GetLastAssistantMessageContent

  10. DeepSeek Assistant

    Let me look at the GetLastAssistantMessageContent function and the flow around it. Also, the issue mentions tool_calls and the "no response from subagent" message. Let me also look at how tool calls are handled in the session loop.

  11. DeepSeek Assistant

    Let me see the getLastMessageContentByRole function.

  12. DeepSeek Assistant

    Let me see the full function.

  13. DeepSeek Assistant

    Let me search for "no response from subagent" more broadly - it might be constructed dynamically.

  14. DeepSeek Assistant

    Let me look at the RunStream function and how tool calls flow.

  15. DeepSeek Assistant

    Let me look at the loop.go to understand how RunStream handles tool calls and end conditions

  16. DeepSeek Assistant

    Let me see the full runStreamLoop function - the middle part was truncated

  17. DeepSeek Assistant

    Let me look at the builtin agent tool package - this is where "run_agent" or similar tool is defined

  18. DeepSeek Assistant

    Let me look at how the stream processing handles finish_reason and tool_calls

  19. DeepSeek Assistant

    Let me look at the OpenAI stream adapter

  20. DeepSeek Assistant

    Let me look at how the loop processes tool calls and handles finish_reason

  21. DeepSeek Assistant

    Let me find the runTurn function

  22. DeepSeek Assistant

    Let me look at the runTurn function.

  23. DeepSeek Assistant

    Let me look at how streamResult and Stopped are determined in the model streaming

  24. DeepSeek Assistant

    Let me look at the streaming.go file to understand how Stopped is determined

  25. DeepSeek Assistant

    Let me look at the OpenAI response handler for non-streaming responses

  26. DeepSeek Assistant

    Let me search for where the result of a subagent is processed and where "no response" would be generated

  27. DeepSeek Assistant

    Let me look at the transfertask tool

  28. DeepSeek Assistant

    Let me find the file.

  29. DeepSeek Assistant

    Let me look at the transfertask.go file.

  30. DeepSeek Assistant

    Let me look at how the model call is made and how the response is parsed

  31. DeepSeek Assistant

    Let me look at the OpenAI client's CreateChatCompletionStream function

  32. DeepSeek Assistant

    Let me look at the fallback.go to understand the model call flow

  33. DeepSeek Assistant

    Let me look at the non-streaming chat completion path

  34. DeepSeek Assistant

    Let me search for non-streaming completion

  35. DeepSeek Assistant

    Let me look at lines around 940 in client.go for the non-streaming path

  36. DeepSeek Assistant

    Let me look at the trackUsage variable and how it's set

  37. DeepSeek Assistant

    Let me search for where "no response" message is generated more broadly

  38. DeepSeek Assistant

    Let me search for "no response" in all files including non-Go files

  39. DeepSeek Assistant

    Let me look at the non-streaming chat completion path in the OpenAI client

  40. DeepSeek Assistant

    Let me look at the processToolCalls function

  41. DeepSeek Assistant

    Let me look at the tool_dispatch.go file

  42. DeepSeek Assistant

    Let me look at the toolexec dispatcher

  43. DeepSeek Assistant

    Let me look at the git log for recent changes related to this issue

  44. DeepSeek Assistant

    Let me look at the oaistream adapter test to understand the expected behavior

  45. DeepSeek Assistant

    Let me look at the SSE comment test

  46. DeepSeek Assistant

    Let me check the git log for changes to the oaistream adapter and handleStream

  47. DeepSeek Assistant

    Let me look at the commit "fallback on stream end

  48. DeepSeek Assistant

    Let me look at the diff for this commit

  49. DeepSeek Assistant

    Let me check the recent commit about message merging in oaistream

  50. DeepSeek Assistant

    Let me look at the chat.FinishReason type definition

  51. DeepSeek Assistant

    Let me search for any LiteLLM-related code or comments

  52. DeepSeek Assistant

    Let me look at the tool_choice code around line 286 in client.go

  53. DeepSeek Assistant

    Let me look at the tests for handleStream

  54. DeepSeek Assistant

    Let me try a different approach. Let me look at the handleStream function more carefully and see if there's a case where tool calls are not accumulated when trackUsage is true.

    Let me look at the full handleStream function one more time, focusing on the interaction between trackUsage, the early return, and the EOF path.

  55. DeepSeek Assistant

    Now I think I understand the issue. Let me trace through a specific scenario:

    When LiteLLM returns a response with tool_calls AND finish_reason: "stop" AND usage data in a single chunk, the adapter:

    1. Extracts tool calls from the delta
    2. Clears the "stop" finish_reason (because trackUsage is true)
    3. Then the usage block sets FinishReason: "stop" on the choice

    In handleStream, the FinishReason: "stop" triggers the early return BEFORE the tool calls in choice.Delta.ToolCalls are processed. The accumulated toolCalls is empty, so Stopped is true, and the loop exits without executing the tool calls.

    Let me verify this theory by looking at the code flow more carefully:

  56. DeepSeek Assistant

    Now I can see the bug clearly. In handleStream, the early return check for FinishReason: "stop" happens BEFORE the tool call processing. When LiteLLM (or any provider) sends a chunk with both tool calls in the delta AND finish_reason: "stop" (or when the adapter's usage chunk sets FinishReason: "stop" on a choice that still has tool calls), the tool calls are never accumulated into the toolCalls slice. The early return then sees len(toolCalls) == 0 and sets Stopped: true, causing the loop to exit without executing the tool calls.

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

  57. DeepSeek Assistant

    Let me use the special open command to view the file

  58. DeepSeek Assistant

    Now I can see the issue. The tool call processing (lines 158-212) happens AFTER the finish reason check (lines 132-149). When a chunk has both tool calls in the delta AND finish_reason: "stop" (which can happen with LiteLLM or when the adapter's usage chunk sets the finish reason on a choice that still has tool calls), the early return is triggered before the tool calls are processed, causing len(toolCalls) to be 0 and Stopped to be true.

    The fix is to move the tool call processing BEFORE the finish reason check. Let me implement this:

  59. DeepSeek Assistant

    I need to use the << 'EOF' syntax for multi-line edits. Let me try again:

  60. DeepSeek Assistant

    Good, the edit looks correct. Now let me verify it compiles and the tests pass:

  61. DeepSeek Assistant

    Let me check the Go

  62. DeepSeek Assistant

    Let me set up the Go environment and try building

  63. DeepSeek Assistant

    Let me set up the Go environment properly

  64. DeepSeek Assistant

    The code compiles. Now let me run the tests for the runtime package:

  65. DeepSeek Assistant

    Good, the tests pass. Let me run the full test suite for the runtime package:

  66. DeepSeek Assistant

    There's a test failure. Let me check which tests failed

  67. DeepSeek Assistant

    Let me get the test results summary more specifically

  68. DeepSeek Assistant

    Let me check if the test failure is pre-existing by reverting my change temporarily and running the test

  69. DeepSeek Assistant

    Good, the test failure is pre-existing and not caused by my change. Let me restore my changes:

  70. DeepSeek Assistant

    Good. The pre-existing test failure is not related to my change. Let me verify the final state of my changes

  71. DeepSeek Assistant

    The diff looks correct. Let me also run the oaistream tests to make sure nothing is broken there:

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