Skip to content

fix(deepagents): forward subagent results as text#608

Open
Alexander Olsen (aolsenjazz) wants to merge 2 commits into
mainfrom
alex/subagents-server-tool-fix
Open

fix(deepagents): forward subagent results as text#608
Alexander Olsen (aolsenjazz) wants to merge 2 commits into
mainfrom
alex/subagents-server-tool-fix

Conversation

@aolsenjazz

@aolsenjazz Alexander Olsen (aolsenjazz) commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

A deep agent that delegates to a subagent 400s when that subagent uses an Anthropic server-side tool (web search, web fetch, code execution, MCP). The subagent's final-message content blocks e.g. server_tool_use/..._tool_result were forwarded verbatim as the task ToolMessage content. On the parent agent's next request they serialize into a tool_result, which Anthropic rejects:

400 invalid_request_error messages.N.content.0.tool_result.content.0: Input tag 'server_tool_use' found using 'type' does not match any of the expected tags: 'document','image','search_result','text','tool_reference'

Solution

Now matches the Python impl: forward only the subagent's text answer. returnCommandWithStateUpdate now walks back to the last AIMessage with non-empty text and uses that text (a string) as the ToolMessage content.

  • Confirmed the Python deepagents impl is not affected (it forwards .text); this aligns JS with Python.
  • Reproduced the 400 across {web_search, code_execution, web_fetch} × {claude-haiku-4-5, claude-sonnet-4-6} on the latest published packages; all green after the fix.

Tests

@changeset-bot

changeset-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b2daf40

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
deepagents Patch
deepagents-acp Patch
@deepagents/evals Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
deepagentsjs-ui Ready Ready Preview, Comment Jun 20, 2026 11:10pm

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Jun 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

deepagents-acp

npm i https://pkg.pr.new/deepagents-acp@608

deepagents

npm i https://pkg.pr.new/deepagents@608

@langchain/sandbox-standard-tests

npm i https://pkg.pr.new/@langchain/sandbox-standard-tests@608

@langchain/daytona

npm i https://pkg.pr.new/@langchain/daytona@608

@langchain/deno

npm i https://pkg.pr.new/@langchain/deno@608

@langchain/modal

npm i https://pkg.pr.new/@langchain/modal@608

@langchain/node-vfs

npm i https://pkg.pr.new/@langchain/node-vfs@608

@langchain/quickjs

npm i https://pkg.pr.new/@langchain/quickjs@608

commit: b2daf40

@aolsenjazz Alexander Olsen (aolsenjazz) changed the title fix(subagents): forward subagent results as text fix(deepagents): forward subagent results as text Jun 20, 2026

@open-swe open-swe Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Open SWE Review: No issues found

Open SWE reviewed this PR and found no potential bugs to report.

Open in WebView Open SWE trace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant