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
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