Skip to content

fix(beta): omit compaction encrypted_content on request round-trip - #1859

Open
lllakshit wants to merge 1 commit into
anthropics:mainfrom
lllakshit:fix/1828-omit-compaction-encrypted-content
Open

fix(beta): omit compaction encrypted_content on request round-trip#1859
lllakshit wants to merge 1 commit into
anthropics:mainfrom
lllakshit:fix/1828-omit-compaction-encrypted-content

Conversation

@lllakshit

Copy link
Copy Markdown

Summary

  • Strip encrypted_content from compaction blocks during request serialization so messages.append(response.content) no longer 400s with Extra inputs are not permitted.
  • Add src/anthropic/lib/_compaction.py (non-generated) and hook it into transform / async_transform after Stainless TypedDict handling.
  • Clarify compaction block docstrings and add respx-backed regression tests for dict/model round-trips, batch params, and web-search/advisor blocks that legitimately keep 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 -q
  • uv run ruff check on changed files
  • uv run pyright / uv run mypy on changed files

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
lllakshit force-pushed the fix/1828-omit-compaction-encrypted-content branch from 14f95eb to b99719f Compare August 23, 2026 18:26
@lllakshit

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BetaCompactionBlockParam.encrypted_content accepted by SDK types but rejected by the live API with "Extra inputs are not permitted"

1 participant