Skip to content

fix(anthropic): strip stream-only metadata from compaction blocks#36979

Closed
Humayun Saeed (mhumayunsaeed) wants to merge 1 commit intolangchain-ai:masterfrom
mhumayunsaeed:humay/fix-anthropic-compaction-messages
Closed

fix(anthropic): strip stream-only metadata from compaction blocks#36979
Humayun Saeed (mhumayunsaeed) wants to merge 1 commit intolangchain-ai:masterfrom
mhumayunsaeed:humay/fix-anthropic-compaction-messages

Conversation

@mhumayunsaeed
Copy link
Copy Markdown

Fixes #36976


Strip stream-only metadata from Anthropic compaction blocks before replaying them into follow-up requests. Added a unit regression test for streamed compaction blocks and verified the original live reproduction now succeeds on the second print_mode=messages invoke.

Verified locally with the focused Anthropic unit tests, the original live Anthropic reproduction, and uv ruff/mypy on the touched files.

This contribution was prepared with AI-agent assistance and manually validated.

@github-actions github-actions Bot added anthropic `langchain-anthropic` package issues & PRs fix For PRs that implement a fix integration PR made that is related to a provider partner package integration size: XS < 50 LOC labels Apr 24, 2026
@github-actions
Copy link
Copy Markdown

This PR has been automatically closed because you are not assigned to the linked issue.

External contributors must be assigned to an issue before opening a PR for it. Please:

  1. Comment on the linked issue to request assignment from a maintainer
  2. Once assigned, your PR will be reopened automatically

Maintainers: reopen this PR or remove the missing-issue-link label to bypass this check.

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

Labels

anthropic `langchain-anthropic` package issues & PRs external fix For PRs that implement a fix integration PR made that is related to a provider partner package integration missing-issue-link new-contributor size: XS < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using compaction causes Anthropic's API to fail when agent invoked with print_mode="messages" or when streaming with stream_mode="messages"

1 participant