fix(ai): preserve Anthropic server tool replay#48
Merged
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
Fix Anthropic same-model replay for assistant messages that contain provider-native server tool blocks and signed thinking.
The failing session
019ed4f0-2914-701d-9614-dd0f58c0b103ended with Anthropic rejecting the next request becausethinkingblocks had been modified. The local replay serializer preserved signed thinking text, but it dropped same-model AnthropicproviderNativeblocks such asserver_tool_useandweb_search_tool_result. That changed the protected assistant content sequence before the follow-up tool-result request.This patch keeps replayable Anthropic provider-native raw blocks only for the same provider/api/model, while continuing to drop non-portable cross-provider native blocks.
QA Evidence
Evidence directory:
local-ignore/qa-evidence/20260617-thinking-session-fix/red-anthropic-provider-native.txtshowed same-model provider-native server blocks were dropped from the Anthropic replay payload.green-anthropic-provider-native-replay-after-review.txtpassedtest/anthropic-provider-native-replay.test.tswith the real failure shape: server native blocks + signed thinking + text + tool call + tool result.green-focused-ai-tests-hermetic.txtpassed 13 tests with 1 live Anthropic E2E skipped.npm-run-check-after-install.txtpassednpm run checkafternpm install --ignore-scriptshydrated already-declared local@typespackages.senpi-qa-mock-loop-anthropic-self.txtandsenpi-qa-mock-loop-anthropic-tool.txtpassed the Anthropic mock loop and multi-turn tool loop with zero real provider calls and real auth unchanged.Summary by cubic
Fixes Anthropic same-model replay to keep server-native tool blocks around signed thinking so follow-up tool-result requests are accepted. Restores stable multi-turn tool flows and scopes PR530 benchmark suites by package for faster CI.
server_tool_use,web_search_tool_result); continue dropping cross-provider native blocks.Written for commit 856288b. Summary will update on new commits.