fix(anthropic): support code execution tool results#2158
Merged
gold-silver-copper merged 2 commits intoJul 16, 2026
Conversation
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
code_execution_tool_resultcontent blocksweb_search_20260209Closes #2154.
Root cause
Anthropic's
web_search_20260209tool uses hosted code execution for dynamic filtering. Responses can therefore include top-levelcode_execution_tool_resultblocks containing eithercode_execution_resultorencrypted_code_execution_resultpayloads.Rig's tagged Anthropic
Contentenum did not recognize that top-level variant, causing response deserialization to fail before callers received the completion.Implementation
code_execution_tool_resultexplicitly with itstool_use_idand provider-native JSONcontentanthropic_contentmetadata conventioncontent_block_starteventsThe implementation deliberately avoids a catch-all unknown-content fallback so unrelated future Anthropic variants still fail visibly instead of being silently discarded.
Regression coverage
The cassette was recorded against Anthropic with
web_search_20260209and contains both normal and encrypted code-execution results. The enabled regression test verifies that the request succeeds and that acode_execution_tool_resultblock remains available in the normalized response metadata.Focused unit tests cover:
code_execution_resultdeserializationencrypted_code_execution_resultdeserializationVerification
cargo fmt --checkgit diff --checkcargo test -p rig-core code_execution_tool_result -- --nocapture— 3 passedenv -u ANTHROPIC_API_KEY cargo test -p rig --all-features --test anthropic web_search_with_dynamic_filtering_succeeds -- --nocapture --test-threads=1— passedcargo test -p rig --all-features --test anthropic cassette_safety -- --nocapture --test-threads=1— 2 passedenv -u ANTHROPIC_API_KEY cargo test -p rig --all-features --test anthropic anthropic::cassette -- --nocapture --test-threads=1— 66 passedcargo clippy --all-targets --all-features -- -D warnings— passedcargo test— passedAll required GitHub checks pass: formatting, WASM check, clippy, tests, documentation, and doctests.
Review
An independent review of the complete diff found no P0/P1 or lower-severity correctness or security issues. Cassette safety checks pass, the fixture contains no credentials, and there are no unresolved review threads.