Repository navigation
fix: Preserve Anthropic continuation through extra_content - #92
Merged
Merged
Conversation
This was referenced Oct 30, 2026
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
provider_metadata.anthropicResponses extension withextra_content.anthropic. Search sources retain Anthropic encrypted content and source details; URL citations retain encrypted indices and original excerpts so serialized Responses output can continue against the same Anthropic Messages upstream.extra_bodyis unchanged. The old unmerged envelope is not retained as an alias.amer-hosted-web-search(PR feat: support hosted web search across Responses and Messages #74). Implements the Anthropic continuation slice of Establish tested provider compatibility for Bedrock, OpenRouter, Together AI, Gemini, and Fireworks #78; Gemini support remains tracked there.Problem, symptoms, and diagnosis
Problem
Anthropic hosted-search continuation needs the original source
encrypted_contentand citationencrypted_index, together with the source details and citation excerpt. Standard Responses URL sources and annotations cannot carry all of that state. PR #74 already preserved it underprovider_metadata.anthropic, but the required public extension contract isextra_content.anthropic, following the provider-namespaced convention tracked in #78. This change aligns the existing continuation mechanism with that contract.Symptoms
provider_metadatainstead ofextra_content. Consumers retaining the expectedextra_contentenvelope would not retain the Anthropic continuation state.extra_contentwas absent."N/A"placeholders, cannot restore Anthropic search context and is rejected before an Anthropic follow-up request. Renaming the envelope preserves real state; it does not make placeholders usable. The existingprovider_metadataroute already supported continuation when clients retained that envelope, so this was a public contract mismatch rather than evidence that all existing continuation was broken.Steps taken to diagnose
extra_bodyand content-levelextra_contentextension surfaces with Establish tested provider compatibility for Bedrock, OpenRouter, Together AI, Gemini, and Fireworks #78 and PR feat: support hosted web search across Responses and Messages #74 atc55a6b860fc4ff222a5b6e008a11aa1068277614.WebSearchSourceandWebCitation; no new IR container was needed.extra_contentand ran the focused recorded-search parity tests before implementation. Both modes failed on the missing field, identifying the Responses boundary as the change location.extra_content.anthropic, directly asserting ciphertext, citation indices, source details, excerpts, and call/result linkage. Verification results are listed below; provider traffic was offline replay only.Verification
PYTHONPATH=python /home/akk/jiahuei/molto/.venv/bin/python -m pytest -q tests/core/test_anthropic_web_search.py -k translates_sdk_semantics: both updated assertions failed before implementation becauseextra_contentwas absent.PYTHONPATH=python /home/akk/jiahuei/molto/.venv/bin/python -m pytest -q tests/core/test_anthropic_web_search.py tests/core/test_web_search.py tests/types/test_openai_responses.py: 405 passed after implementation.PYTHONPATH=python /home/akk/jiahuei/molto/.venv/bin/python -m pytest -q -o addopts='': 2,293 passed on Python 3.12.9, offline replay only. No live provider calls or cassette changes.uv run --extra lint ruff check --output-format github --config pyproject.toml .: passed.uv run --extra lint ruff format --diff --config pyproject.toml .: passed, 99 files already formatted. Initial changed-file formatting check identified two files, corrected withuv run --extra lint ruff format --config pyproject.toml python/molto/types/openai_responses.py tests/core/test_web_search.py.npx prettier@3.8 --check .: passed. Initial changed-document check identifieddocs/web-search.md, corrected withnpx prettier@3.8 --write docs/web-search.md.git diff --check: passed.git status --short -- tests/cassettes: empty.PYTHONPATH=python /home/akk/jiahuei/molto/.venv/bin/python -m pytest -q tests/adapters/test_openai_search.py tests/core/test_anthropic_web_search.py: 55 passed after adding direct IR assertions. Repository-wide Ruff and Prettier checks also passed for this test-only update; the full-suite result above predates this additional parameterized case.