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.
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 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
Let me start by exploring the repository structure to understand the codebase and find the relevant code that handles subagent responses and tool calls.
Assistant
This is a Go repository. Let me explore more to find the code that handles subagents and tool calls. The issue mentions "no response from subagent", so let me search for that message.
<tool_call> <function=bash_terminal> <parameter=command> grep -r "no response from subagent" /docker-agent/ --include="*.go" 2>/dev/null </tool_call>
Assistant
The grep command didn't return any results. Let me try a broader search for "subagent" related code.
Assistant
Let me search for the "no response from subagent" text more broadly, and also look at the agent_delegation.go file since that seems to handle subagents.
<tool_call> <function=bash_terminal> <parameter=command> grep -ri "no response" /docker-agent/pkg --include="*.go" 2>/dev/null </tool_call>
Assistant
Let me look at the agent_delegation.go file first since it seems to be related to subagent handling.
Assistant
Let me search for where the "no response from subagent" message might be generated. It could be a different phrasing.
<tool_call> <function=bash_terminal> <parameter=command> grep -ri "subagent" /docker-agent/pkg/runtime --include="*.go" -n 2>/dev/null | head -50 </tool_call>
Assistant
Let me search for "tool_calls" handling and how the subagent responses are processed. The issue is about tool_calls not being handled when using LiteLLM proxy.
Assistant
Let me check the model provider code to see how responses are handled, especially for the OpenAI-compatible provider used with LiteLLM.
Assistant
Let me look at the openai provider since LiteLLM uses the OpenAI-compatible API.
Assistant
Let me look at the schema.go file which likely defines how tool_calls are handled in responses.
Assistant
Now let me look at the client.go file to see how responses are processed.
<tool_call> <function=bash_terminal> <parameter=command> cat /docker-agent/pkg/model/provider/openai/client.go </tool_call>
Assistant
The response file was too long, let me view it in chunks.
Assistant
Let me continue reading the client.go file to see how responses are handled, especially for tool_calls.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '200,400p' /docker-agent/pkg/model/provider/openai/client.go </tool_call>
Assistant
The grep is not returning results. Let me try without grep first.
Assistant
Let me read the client.go file in parts using the
catcommand.<tool_call> <function=bash_terminal> <parameter=command> cat /docker-agent/pkg/model/provider/openai/client.go | head -400 | tail -200 </tool_call>
Assistant
The environment seems to be having issues with the commands. Let me try a different approach - let me just search for relevant code related to tool_calls handling.
Assistant
Let me look at the chat package which might have the code that processes responses:
Assistant
Now I see the Message struct has ToolCalls and FinishReason fields. Let me search for where the code handles the response to check if tool_calls exist. The issue says "no response from subagent" - let me find this error message.
Assistant
Let me search for messages related to "subagent" to understand the flow better.
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "subagent" /docker-agent/pkg/runtime --include="*.go" 2>/dev/null </tool_call>
Assistant
The command isn't returning output. Let me try a different approach - let me see if I can get the file contents with proper handling.
Assistant
Now let me look at the session.go file to see how the assistant's response is handled, especially when processing tool_calls.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "ToolCalls|tool_calls|FinishReason" /docker-agent/pkg/session/session.go | head -30 </tool_call>
Assistant
The tool call seems to be working (exit code 0), but the output is empty. Let me try a simpler approach to find the issue.
Assistant
Now let me look at the code around line 1242 in session.go where it checks for empty content and no tool calls:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1230,1260p' /docker-agent/pkg/session/session.go </tool_call>
Assistant
The terminal commands aren't working as expected. Let me try a simpler approach and use the bash_terminal tool properly.
Assistant
Good! Now I see the code. At line 1242, there's a check:
if strings.TrimSpace(msg.Content) == "" && len(msg.ToolCalls) == 0 && msg.FunctionCall == nil { continue }This checks if the message has no content and no tool calls. This is in the
sanitizeMessagesfunction. Now I need to find where the "no response from subagent" error is generated. Let me search for where this might happen when processing a subagent response.Let me look at how the host agent processes the subagent response. The issue is that when using LiteLLM, the subagent returns valid tool_calls but the host doesn't execute them. Let me search for where the assistant message content is used by the host agent.
Assistant
Let me see this function: <tool_call> <function=bash_terminal> <parameter=command> sed -n '544,580p' /docker-agent/pkg/session/session.go </tool_call>
Assistant
The tool call is working but there's no output shown. Let me try a different approach.
Assistant
The issue says "no response from subagent", but the actual text is "No response from agent" (capitalized). However, that doesn't seem to be the root cause. Let me search for where the subagent's response is being processed and where tool_calls might be getting lost.
Let me look at the a2a.go file since it mentions "No response from agent" and the issue is about subagents:
Assistant
Now let me look at the mcp/server.go file where "No response from agent" is also used:
Assistant
The issue description mentions that when using LiteLLM, the subagent returns a valid
tool_callsresponse but the host agent reports "no response from subagent" and doesn't execute the tool call. Let me look more closely at how the runtime handles subagent results.Let me search for how the host agent processes the result from a subagent: <tool_call> <function=bash_terminal> <parameter=command> grep -n "GetLastAssistantMessageContent|AddSubSession|SubSessionCompleted" /docker-agent/pkg/runtime/agent_delegation.go </tool_call>
Assistant
The tool call works but no output is being displayed. Let me try a different approach to read the file.
Assistant
Now I can see the issue. Let me look at the
GetLastAssistantMessageContentfunction:Assistant
Let me look at
getLastMessageContentByRole:Assistant
Let me see the function body:
Assistant
Here's the issue! The
getLastMessageContentByRolefunction only returnsmessage.Message.Content(the text content) - it completely ignoresmessage.Message.ToolCalls.When the subagent returns a tool call (without any text content),
GetLastAssistantMessageContent()returns an empty string because the assistant message only has tool calls, not text content. This causes the host agent to think there was "no response from subagent".Let me verify this understanding by looking at how the response is used in the context of tool calls. Let me see how tool calls from subagents should be handled and if there's any place where ToolCalls should be preserved and used by the host.
Assistant
I see that
sanitizeMessageskeeps assistant messages that have tool calls even when content is empty. But the issue is that whenGetLastAssistantMessageContent()is called, it returns an empty string because it only looks atContentand ignoresToolCalls.Let me search for how the tool calls are used after a subagent session completes:
Assistant
The subagent can return tool calls, but the host agent doesn't process them - it only gets the text content. This is the root cause.
Let me look at how tool calls are normally handled in the main agent loop.
Assistant
Let me look at the loop.go file to see how tool calls are processed:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '590,610p' /docker-agent/pkg/runtime/loop.go </tool_call>
Assistant
Let me try using a different approach to read the file - maybe using cat with specific line numbers.
Assistant
Now I need to understand the complete flow. Let me look at where the session response is created and how it handles tool calls:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "type SessionResponse" /docker-agent/pkg/runtime --include="*.go" -r </tool_call>
Assistant
Let me try a different approach.
Assistant
The issue is that when a subagent returns only tool calls without text content, the host agent doesn't process them. Let me find where the response content is extracted from subagents and used.
Looking at the code in agent_delegation.go:
return tools.ResultSuccess(s.GetLastAssistantMessageContent()), nilThis only extracts the text content from the subagent's last message, ignoring any tool calls. The host agent then sees an empty string (or text content) and doesn't execute the tool calls.
Let me search for how the tool call result is used after being returned from the subagent: <tool_call> <function=bash_terminal> <parameter=command> grep -n "runForwarding|runCollecting" /docker-agent/pkg/runtime/*.go </tool_call>
Assistant
The tool call is working (exit code 0), but the output isn't being displayed. Let me try reading the file with cat.
Assistant
Let me see how handleTaskTransfer uses the result from runForwarding:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '400,450p' /docker-agent/pkg/runtime/agent_delegation.go </tool_call>
Assistant
Let me try a different approach to read the file:
Assistant
Now I understand the issue better. The
runForwardingfunction returns a*tools.ToolCallResultwith just the text content from the subagent. The host agent doesn't process tool calls returned by the subagent.The issue is that when a subagent returns tool calls, they are not being passed back to the host agent for execution. The
runForwardingfunction only returns the text content viaGetLastAssistantMessageContent().Let me look at the tools.ToolCallResult structure to understand how tool calls could be included:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "ToolCallResult" /docker-agent/pkg/tools --include="*.go" -l </tool_call>
Assistant
The tool call is working, but the output isn't being displayed. Let me try to read the tools package to understand the structure.
Assistant
Now I understand the issue. Let me look at the session structure to see how tool calls are stored and how they can be retrieved from a subagent:
Assistant
Now I need to understand the structure better. Let me look at how tool calls are stored in the session messages:
Assistant
Now I understand the problem better. Looking at the code:
-
In
agent_delegation.go, therunForwardingfunction returns:return tools.ResultSuccess(s.GetLastAssistantMessageContent()), nil -
The
GetLastAssistantMessageContent()function insession/session.goonly returnsmessage.Message.Content, ignoringToolCalls:func (s *Session) getLastMessageContentByRole(role chat.MessageRole) string { messages := s.GetAllMessages() for _, message := range slices.Backward(messages) { if message.Message.Role == role { return strings.TrimSpace(message.Message.Content) // Only returns Content, ignores ToolCalls } } return "" }
-
Assistant
The tool call command is working but I'm not seeing the output. Let me try to find the tools package structure.
Assistant
Let me look at the tools.go file to understand how tool results work:
Assistant
Now I understand the structure. Let me look at how the subagent's tool calls should be propagated. The key insight is that
ToolCallResultdoesn't have a field for tool calls, only for the output text. The issue is that when a subagent returns only tool calls (without text content), the host agent doesn't know about them.Let me check how the result from a task transfer is used:
Assistant
Let me understand the issue better. The problem is that when using LiteLLM as a proxy, the subagent returns valid tool_calls but the host agent doesn't process them. Looking at the code flow:
handleTaskTransfercallsrunForwardingrunForwardingexecutes the subagent session and returns the result viaGetLastAssistantMessageContent()GetLastAssistantMessageContent()only returns text content, not tool calls
The issue is that
runForwardingreturns aToolCallResultwith only text content, and the host agent doesn't see the tool calls from the subagent.Looking more carefully, I think the issue might be in how LiteLLM proxies responses. LiteLLM wraps OpenAI-compatible responses, and when a model returns tool calls, the structure might be different from what the OpenAI client expects.
Let me look at the streaming.go file to see how tool calls are extracted from responses:
<tool_call> <function=bash_terminal> <parameter=command> cat /docker-agent/pkg/runtime/streaming.go </tool_call>
Assistant
The tool call is working but not showing output. Let me try a different approach to read the file.
Assistant
The file has 283 lines. Let me try reading the whole file:
Assistant
Assistant
The tool call is working but not showing output. Let me try a different approach.
Assistant
Okay, so
processToolCallsis called inloop.goline 596. Let me see how the host agent would process tool calls from a subagent. The issue is that when a subagent returns tool calls, they're not being processed by the host agent.Looking at the code:
- In
runForwarding, the subagent session runs and events are forwarded to the parent - But when the subagent returns tool calls in its last message, those tool calls are NOT processed by the host agent
- The host agent only receives the text content via
GetLastAssistantMessageContent()
The fix should be to:
- After the subagent session completes, check if the last message has tool calls
- If it does, add those tool calls to the parent session's messages
- Have the host agent process those tool calls
Let me look at how
runForwardingworks and see where we can add this logic:- In
Assistant
Now I see the issue. In
runForwarding, after the subagent session completes, the function returns:return tools.ResultSuccess(s.GetLastAssistantMessageContent()), nilThis only returns the text content. If the subagent's last message has tool calls, those tool calls are not being passed to the host agent.
The fix should be to:
- After the subagent session completes, check if the last assistant message has tool calls
- If it does, add those tool calls to the parent session's messages
Assistant
Let me look at the response_stream.go file to see how responses are parsed:
<tool_call> <function=bash_terminal> <parameter=command> cat /docker-agent/pkg/model/provider/openai/response_stream.go </tool_call>
Assistant
The tool call commands aren't showing output. Let me try a different approach to understand the issue better.
Assistant
Let me continue reading the response_stream.go file to see how tool calls are handled:
Assistant
Now I see how tool calls are handled in the response stream. The code handles
response.output_item.addedandresponse.function_call_arguments.deltaevents.Let me continue reading to see the rest of the handling:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '200,277p' /docker-agent/pkg/model/provider/openai/response_stream.go </tool_call>
Assistant
The tool call is working but the output is being truncated. Let me try a different approach to read the file.
Assistant
Now I see the issue! Look at the code around lines 245-265:
case "response.done", "response.completed": slog.Info("Response done received", "event_type", event.Type) // Extract usage u := event.Response.Usage if u.TotalTokens > 0 { response.Usage = &chat.Usage{ InputTokens: u.InputTokens - u.InputTokensDetails.CachedTokens, OutputTokens: u.OutputTokens, CachedInputTokens: u.InputTokensDetails.CachedTokens, ReasoningTokens: u.OutputTokensDetails.ReasoningTokens, } } // Check if there were any tool calls in the output hasToolCalls := false for _, output := range event.Response.Output { if output.Type == "function_call" { hasToolCalls = true break } } finishReason := chat.FinishReasonStop if hasToolCalls { finishReason = chat.FinishReasonToolCalls } response.Choices = []chat.MessageStreamChoice{ { FinishReason: finishReason, }, }Assistant
The tool call command isn't returning output properly. Let me try a different approach to understand the issue.
Assistant
The file has 167 lines. Let me read it:
<tool_call> <function=bash_terminal> <parameter=command> awk '1' /docker-agent/pkg/model/provider/oaistream/adapter.go </tool_call>
Assistant
Let me search for where the "no response from subagent" message might be generated:
Assistant
The issue description mentions "no response from subagent" but the actual code shows "No response from agent" in the MCP server and A2A tool code. However, looking at the code flow, the real issue is in
runForwardinginagent_delegation.go.Let me now understand the root cause better. When a subagent returns only tool calls (no text content):
GetLastAssistantMessageContent()returns an empty string because it only looks atContent- The host agent sees an empty result and doesn't know about the tool calls
The fix should be to modify
runForwardingto also return tool calls from the subagent's last message. Let me look at how this can be done.First, let me check if there's a way to get the last assistant message's tool calls:
Assistant
I see there's a
GetAllMessages()function that returns all messages. Let me look at how we can get the last assistant message with its tool calls:Assistant
Now I understand the structure. The
GetAllMessages()function returns all messages from the session. Each message hasToolCallsfield. The issue is thatGetLastAssistantMessageContent()only returns the text content, not the tool calls.The fix should be to:
- Add a new function that returns the last assistant message (including its tool calls), OR
- Modify
runForwardingto check for tool calls in the last message
Looking at the code flow:
handleTaskTransfercallsrunForwardingrunForwardingreturns aToolCallResultwith text content- The host agent doesn't process tool calls from subagents
The solution is to modify
runForwardingto propagate tool calls from the subagent's last message to the parent session. This way, the host agent can process them normally.Let me look at how to add messages to the parent session:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "AddMessage|AddSubSession" /docker-agent/pkg/session/session.go | head -20 </tool_call>
Assistant
The tool call command isn't showing output properly. Let me try a different approach.
Assistant
Let me look at the AddMessage function:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '455,470p' /docker-agent/pkg/session/session.go </tool_call>
Assistant
The tool call commands aren't returning output properly. Let me try a different approach to read the file.
Assistant
Assistant
Let me read the specific section where I need to make the fix:
Assistant
Now I understand the issue. The
runForwardingfunction returns the text content from the subagent's last message, but it doesn't process tool calls that might be in that message.The fix should be to:
- Get the last assistant message from the subagent session
- If it has tool calls, add those tool calls to the parent session
- Process those tool calls in the host agent
But looking at the code flow, the issue is more subtle. The
runForwardingfunction returns aToolCallResult, which is then used as the result of thetransfer_tasktool call. The host agent doesn't re-process the tool calls from the subagent.The solution is to modify
runForwardingto:- Get the last assistant message from the subagent session
- If it has tool calls, add those tool calls to the parent session as assistant messages
- Process those tool calls by calling
processToolCalls
But wait, looking at the code more carefully, I realize that is synchronous - it waits for the subagent session to complete. The host agent then receives the result and continues. The tool calls from the subagent should be added to the parent session's messages so that the host agent's loop can process them.
Assistant
Let me try to read the file in a different way to understand how tool calls are processed in the host agent.
Assistant
I can see that in
loop.go, theprocessToolCallsfunction is called withres.Calls(the tool calls from the stream result). The issue is that when a subagent returns tool calls, they are not being processed by the host agent.Now I understand the fix needed:
- In
runForwarding, after the subagent session completes, we need to check if the last assistant message has tool calls - If it does, we need to add those tool calls to the parent session's messages
- Then we need to call
processToolCallsto execute those tool calls
But wait, looking at the code flow,
runForwardingis called fromhandleTaskTransfer, which is a tool handler. The result ofhandleTaskTransferis used as the tool call result, which is then added to the session. The host agent's loop then continues with the next iteration.The issue is that the tool calls from the subagent should be executed BEFORE returning from
handleTaskTransfer, not after. This way, the host agent will see the tool results in the session and continue normally.Let me modify
runForwardingto process tool calls from the subagent's last message:- In
Assistant
Let me read the file line count and understand the structure better.
Assistant
Now let me create a fix. The issue is that
runForwardingreturns only the text content from the subagent's last message, ignoring any tool calls. The fix should:- Get the last assistant message from the subagent session
- If it has tool calls, add the assistant message to the parent session
- Process those tool calls in the host agent
- Return the text result (or empty if there were only tool calls)
Let me first understand the structure of the message by looking at the chat.Message type:
Assistant
Now let me look at the Message struct to understand its fields:
Assistant
Now I understand the structure. The
chat.Messagehas aToolCallsfield. The fix should:- Get the last assistant message from the subagent session
- Check if it has tool calls
- If it does, add the message to the parent session
- Process those tool calls
Let me now create the fix. I'll modify the
runForwardingfunction to:- After the subagent session completes, get the last assistant message
- If it has tool calls, add it to the parent session
- Process those tool calls
Here's my plan:
- Create a helper function to get the last assistant message from a session
- Modify
runForwardingto process tool calls from the subagent's last message
Let me implement the fix:
<tool_call> <function=bash_terminal> <parameter=command> cat > /tmp/fix.go << 'EOF' // getSubagentLastAssistantMessage returns the last assistant message from the subagent session, // or nil if there is no assistant message. func getSubagentLastAssistantMessage(s *session.Session) *session.Message { messages := s.GetAllMessages() for i := len(messages) - 1; i >= 0; i-- { if messages[i].Message.Role == chat.MessageRoleAssistant { return &messages[i] } } return nil } EOF cat /tmp/fix.go </tool_call>
Assistant
Let me try a different approach to make the fix. I'll need to modify the agent_delegation.go file to handle tool calls from subagents.
Assistant
No changes yet. Let me first look at the full
runForwardingfunction to understand where to make the fix:Assistant
Now I understand the issue. The
runForwardingfunction returns only the text content fromGetLastAssistantMessageContent(), which ignores any tool calls. When a subagent returns only tool calls (no text), the result is empty.The fix should:
- After the subagent session completes, check if the last assistant message has tool calls
- If it does, add those tool calls to the parent session and process them
- Return the text content (or empty if there were only tool calls)
Let me implement the fix:
Assistant
Now let me apply this fix using the edit command. First, let me see the exact lines I need to modify:
Assistant
Now I need to insert the tool call processing logic between lines 294 and 296 (after
evts.Emit(SubSessionCompleted(parent.ID, s, callerAgent.Name()))and beforespan.SetStatus(codes.Ok, "sub-session completed")).Let me use the edit command to make this change:
Assistant
I see there's a duplicate line. Let me fix that:
Assistant
Now let me verify the fix looks correct:
Assistant
The fix looks good. Now I need to verify that the code compiles and that the necessary imports are in place. Let me check the imports:
Assistant
I see the import for
chatis missing. Let me add it:Assistant
Let me verify the import was added correctly:
Assistant
The import was added correctly. Now let me verify that the code compiles:
Assistant
Let me try to build the package with the proper Go environment:
Assistant
The build is downloading dependencies. Let me wait for it to complete and check if there are any errors:
<tool_call> <function=bash_terminal> <parameter=command> cd /docker-agent && export GOMODCACHE=/tmp/go-mod-cache && go build ./pkg/runtime/... 2>&1 | tail -50 </tool_call>
Assistant
The build seems to have succeeded (exit code 0). Let me verify the build completed and run the existing tests for the runtime package to ensure my fix doesn't break anything:
Assistant
The build is downloading more dependencies. Let me wait for the tests to complete:
<tool_call> <function=bash_terminal> <parameter=command> cd /docker-agent && export GOMODCACHE=/tmp/go-mod-cache && go test ./pkg/runtime/... -run "Test.*SubAgent|Test.*Delegation" -v 2>&1 | tail -100 </tool_call>
Assistant
The command is running but not showing output. Let me try a simpler test to verify the code compiles and then run a broader set of tests.
Assistant
Let me try to run the full test suite for the runtime package instead, which should compile all necessary files together.
<tool_call> <function=bash_terminal> <parameter=command> cd /docker-agent && export GOMODCACHE=/tmp/go-mod-cache && go list ./pkg/runtime/... 2>&1 </tool_call>
Assistant
Let me check if the code compiles by running go build:
Assistant
The build is failing due to cache issues. Let me set up the cache and try again:
Assistant
Now I can see the compilation errors. Let me fix them:
assistantMsgis a value, not a pointer - I need to use it directlyparentAgent.Tools()requires a context and returns 2 values
Let me fix these issues:
Assistant
Now let me fix the Tools() call to accept context:
Assistant
Now let me verify the fix and check if there are any other compilation errors:
Assistant
The code compiles successfully! Let me verify the changes look correct:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '295,335p' /docker-agent/pkg/runtime/agent_delegation.go </tool_call>
Assistant
The tool call command worked (exit code 0) but didn't show output. Let me try a different approach to verify the changes.
Assistant
The changes look good. Now let me run the existing tests to make sure the fix doesn't break anything:
<tool_call> <function=bash_terminal> <parameter=command> cd /docker-agent && export GOMODCACHE=/tmp/go-mod-cache && export GOCACHE=/tmp/go-cache && go test ./pkg/runtime/... -count=1 2>&1 | tail -50 </tool_call>
Assistant
The command seems to be running but not showing output. Let me wait for it to complete or try a different approach to check if the tests pass.
Assistant
Let me run the tests correctly:
Assistant
The test pattern didn't match any tests. Let me search for the actual test function names:
Assistant
Now let me run the tests for the agent_delegation package:
Assistant
The existing tests pass. Now let me run a broader set of tests to make sure the fix doesn't break anything:
Assistant
The tests are failing. Let me see what test is failing:
Assistant
Let me check what the
TestDoCompactAfterHookFirestest is testing:Assistant
This test failure seems unrelated to my changes - it's about session compaction hooks, not subagent tool calls. Let me verify this by checking if the test was passing before my changes:
Assistant
The test was already failing before my changes! This is a pre-existing issue in the repository, not caused by my fix. Let me restore my changes and verify my fix doesn't introduce any new test failures:
Assistant
My changes are restored. Let me now run the tests excluding the pre-existing failing test to make sure my fix doesn't introduce any new failures:
Assistant
The tests are mostly passing, and the only failure is the pre-existing
TestDoCompactAfterHookFirestest that was already failing before my changes.Let me now also run some more specific tests related to task transfer and subagents to make sure my fix works correctly:
Assistant
Let me search for test functions related to task transfer:
Assistant
Let me run these tests:
<tool_call> <function=bash_terminal> <parameter=command> cd /docker-agent && export GOMODCACHE=/tmp/go-mod-cache && export GOCACHE=/tmp/go-cache && go test ./pkg/runtime/... -run "TestTransferTask" -v 2>&1 | tail -30 </tool_call>
Assistant
The tool call command seems to have issues. Let me try running the tests differently.
Assistant
The transfer task tests pass. Let me also check if there's any test for the
runForwardingfunction or tool call handling:<tool_call> <function=bash_terminal> <parameter=command> grep -n "func Test.*" /docker-agent/pkg/runtime/runtime_test.go | grep -i "runForwarding|runCollecting|handleTask" </tool_call>
Assistant
The test output seems to be working now. Let me search for test functions related to the handleTaskTransfer function:
Assistant
Now let me verify the changes I made by looking at the diff:
Assistant
The changes look correct. Now let me also consider edge cases:
-
What if the subagent returns only tool calls with no text content? - The fix handles this by checking for tool calls and processing them. The
GetLastAssistantMessageContent()will return an empty string if there's no text, but the tool calls will still be processed. -
What if there are errors getting the parent agent or tools? - The fix handles this by falling back to
callerAgentifr.team.Agent(r.CurrentAgentName())fails, and ignoring errors fromparentAgent.Tools(ctx). -
What if
processToolCallsstops the run? - The fix handles this by returning early with the stop message. -
What if the subagent has no assistant messages? - The fix handles this by checking if
lastAssistantIdx >= 0before processing.
However, I noticed one potential issue: the code ignores errors from
parentAgent.Tools(ctx)using_. This could hide important errors. Let me improve this:-
Assistant
Let me verify the change:
Assistant
The fix looks good. Let me verify the code still compiles and the tests pass:
Assistant
The code compiles. Let me run the tests again to make sure everything still works:
Assistant
The tests pass. Let me now run a broader set of tests to ensure the fix doesn't break anything:
Assistant
Let me check which test is failing:
<tool_call> <function=bash_terminal> <parameter=command> cd /docker-agent && go test ./pkg/runtime/... 2>&1 | grep -E "(FAIL|--- FAIL)" | head -10 </tool_call>
Assistant
The tool call command isn't showing output properly. Let me try a different approach to identify the failing test.
Assistant
The only failing test is
TestDoCompactAfterHookFires, which was already failing before my changes (I verified this earlier by stashing my changes and running the test). This is a pre-existing issue in the repository, not caused by my fix.Let me now also verify that my fix handles the case where the subagent returns tool calls correctly by looking at the final code:
Assistant
The fix looks correct. Let me summarize what the fix does:
Summary of the Fix
The issue was that when a subagent returns tool calls without any text content (e.g., when using LiteLLM as a proxy), the host agent didn't process those tool calls and reported "no response from subagent".
Root Cause
The
runForwardingfunction inagent_delegation.goonly returned the text content from the subagent's last message viaGetLastAssistantMessageContent(), completely ignoring any tool calls that might be present.Solution
The fix adds logic to:
- After the subagent session completes, check if the last assistant message has tool calls
- If tool calls exist, add the assistant message (with tool calls) to the parent session
- Process those tool calls in the parent session using
processToolCalls - Handle errors gracefully and return early if tool processing stops the run
Edge Cases Handled
- Empty subagent messages: The fix checks if before processing
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.