Repository navigation
🧱 fix: Keep Anthropic Server Tool Result Blocks in the Final Message - #731
Open
roman-redl wants to merge 1 commit into
Open
roman-redl wants to merge 1 commit into
roman-redl wants to merge 1 commit into
Conversation
modifyContent turns every block whose type is not in the provider's allowed list into a text block. The Anthropic list lacked code_execution_tool_result, web_fetch_tool_result, bash_code_execution_tool_result, text_editor_code_execution_tool_result and tool_search_tool_result, so these results never reached the replayed history and Anthropic rejected the request after next with a missing code_execution_tool_result 400. Allow those types, and cover modifyDeltaProperties with tests.
This was referenced Nov 22, 2026
roman-redl
added a commit
to roman-redl/parley
that referenced
this pull request
Nov 22, 2026
…layed With Anthropic web search dynamic filtering (web_search_20260209 and later) the model calls code_execution and the nested web_search calls carry caller. @librechat/agents 4.2.7 dropped code_execution_tool_result (stream parser, replay and modifyContent) and stripped caller, so a later request of the turn failed with 400. patch-agents-servertools.sh ports LibreChat-AI/agents#720 to the compiled code and adds the allowed block types fix (LibreChat-AI/agents#731).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keep Anthropic server tool result blocks (
code_execution_tool_result,web_fetch_tool_result,bash_code_execution_tool_result,text_editor_code_execution_tool_result,tool_search_tool_result) in the final Anthropic message instead of converting them totextblocks.Refs #690. Complements #720 and #732 (code execution container). #720 fixes
_formatContent/_makeMessageChunkFromAnthropicEventbut not this step (so this isRefs, notFixes: #690 needs both).Problem
With Anthropic dynamic filtering (
web_search_20260209/web_search_20260318) the model callscode_executionas a server tool. When the same turn continues after a client (MCP) tool call, the request after next fails:It shows up when a turn takes several requests (Anthropic re-sends a missing result once, the request after that fails).
Root cause
After the stream, the graph passes the final message through
modifyDeltaProperties->modifyContent, which turns every block whose type is not inallowedTypesByProvider[provider]into atextblock. The Anthropic list hadserver_tool_use,web_search_tool_resultandweb_search_result, but none of the other server tool result types, so acode_execution_tool_resultnever reached the replayed history, regardless of whatmessage_inputsdoes with it.Fix
Add the five missing server tool result types to
allowedTypesByProvider[Providers.ANTHROPIC]insrc/messages/core.ts(grouped withweb_search_tool_resultin one constant). Other providers are unchanged.Tests
New
src/messages/modifyDeltaProperties.test.ts:code_execution_tool_resultblock withencrypted_code_execution_resultcontent survives for Anthropic (content andlc_kwargs.content);text;Without the fix 7 of the 10 tests fail.
npx jest src/messages: 36 suites, 1108 passed, 1 skipped. Full suite: identical set of 22 failing suites as onmain(not related to this change).npx tscdiagnostics andnpx eslinton the touched files: no new findings.Verification
Found and verified live on LibreChat v0.8.9 with
web_search_20260318,claude-opus-5-5and MCP client tools, using the same change applied as a build-time patch to the compiled 4.2.7 dist: 6/6 runs without errors including 6-request turns, plus a 4-turn session with 4 researcher subagents and 70 searches with 0 errors (together with the #720 changes).