fix(beta): omit compaction encrypted_content on request round-trip - #1859
Open
lllakshit wants to merge 1 commit into
Open
fix(beta): omit compaction encrypted_content on request round-trip#1859lllakshit wants to merge 1 commit into
lllakshit wants to merge 1 commit into
Conversation
The Messages API rejects encrypted_content on request compaction blocks even though response blocks include it. Strip the field during request serialization so messages.append(response.content) works without a 400. Fixes anthropics#1828
lllakshit
force-pushed
the
fix/1828-omit-compaction-encrypted-content
branch
from
August 23, 2026 18:26
14f95eb to
b99719f
Compare
Author
|
Hi @anthropics/sdk, this is a small request-side fix for #1828: compaction blocks include encrypted_content in responses, but sending it back on the next request 400s. The strip lives in src/anthropic/lib so it should survive Stainless regeneration, with regression tests for the round-trip and for blocks that should keep encrypted_content. I just rebased onto current main. Happy to adjust if you want a different approach. |
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
encrypted_contentfrom compaction blocks during request serialization somessages.append(response.content)no longer 400s withExtra inputs are not permitted.src/anthropic/lib/_compaction.py(non-generated) and hook it intotransform/async_transformafter Stainless TypedDict handling.encrypted_content.Fixes #1828.
Test plan
uv run pytest tests/lib/test_compaction_request.py tests/lib/streaming/test_beta_messages.py tests/test_transform.py::test_transform_skipping -quv run ruff checkon changed filesuv run pyright/uv run mypyon changed files