Repository navigation
fix: Add automatic citation buffering and preserve point citations - #89
Merged
Merged
Conversation
- Project a reason-less Responses incomplete as unknown instead of inferring pause, and keep pause for sources that report it. - Replace the client-side citation prediction with an explicit citation_policy on the Messages adapter, defaulting to drop, and never emit empty or whitespace-only text blocks when splitting at citation boundaries. - Never drop reasoning that Chat cannot represent; fail at the signature boundary. - Make the hosted search request count a normalized Usage field. - Treat extra_body and extra_headers as opaque transport extensions. - Drop unrelated churn and document the new contracts.
- citation_policy=buffer now withholds text parts only when the normalized request declares a hosted-search tool or carries search or citation history, falling back to the drop outcome otherwise. - Document that extra_body is opaque while extra_headers is filtered once at the credential boundary, and that neither is validated or used for translation.
Anthropic decrypts web_search_result.encrypted_content and web_search_result_location.encrypted_index on later turns and rejects a request where either is missing or modified. Translated history cannot supply those values, so request construction now rejects it with UnsupportedInput instead of sending an N/A placeholder, and the docs stop recommending replay of translated Messages responses.
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
Molto.messages(..., citation_policy="auto")for conditional citation buffering on translated Responses routes. It buffers text when normalized tools or history signal possible citations; otherwise text streams immediately and unexpected citations are dropped."buffer"always buffers each text part,"drop"remains the default, and opaque transport extensions do not select automatic buffering. Native Messages and Chat upstream behavior remain unchanged.cited_text. Existing offset validation, blank-text rejection, provider metadata, and SDK-compatible text deltas remain intact.amer-hosted-web-search, retaining its Anthropic continuation metadata, provider-specific missing/empty/placeholder ciphertext rejection, and recorded continuation coverage. No cassette contents differ from that branch.Removal of output-only missing reasoning-signature checks is tracked independently in PR #90.
Verification
.venv/bin/python -m pytest: 2,293 passed in 35.78 seconds on Python 3.12.9 after separating the reasoning-output work. Tests used offline replay only.uv run --extra lint ruff check --output-format github --config pyproject.toml .: passed.uv run --extra lint ruff format --diff --config pyproject.toml .: passed.npx prettier@3.8 --check .: passed.git diff 4235d01 HEAD --exit-code: passed; the final tree exactly matches the verified hosted-search-only merge. Cassettes remain unchanged relative toamer-hosted-web-search.main, so PR fix: Add automatic citation buffering and preserve point citations #89 relies on the local suite above while its base remainsamer-hosted-web-search.