Conversation
gr2m
approved these changes
Jan 30, 2026
|
Thanks for the quick fix! |
4 tasks
felixarntz
added a commit
that referenced
this pull request
Feb 20, 2026
…ntext editing (#12547) ## Background Anthropic context management support (`clear_tool_uses`, `clear_thinking`) was added in #10540 (with a related fix in #12154), and compaction support (`compact`) was added in #12384. ## Summary With the complexities of handling these features correctly (including how `clear_tool_uses` and `clear_thinking` can be combined), I think it makes sense to add some more tests and also examples around this. - Adds fixture based tests for context editing (tool uses, thinking, and both combined), each for `generateText` and `streamText` - Adds examples for thinking, compaction, and thinking and tool uses combined (there already was an example for tool uses alone, which I renamed for consistency) - Expands docs, adding "Context Editing" grouping section for both `clear_thinking` and `clear_tool_uses` ## Manual Verification All examples were run against the live Anthropic API to verify correct behavior, and the fixture data was captured from those real API responses. ## Checklist - [x] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) - [ ] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] I have reviewed this pull request (self-review) ## Future Work N/A ## Related Issues N/A
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.
background
the
contextManagementfield inproviderMetadatawas alwaysnullwhen usingstreamTextwith the Anthropic provider, even though the API correctly returnscontext_managementin the response.the issue was twofold:
context_managementinside thedeltaobjectvalue.delta.context_managementbut Anthropic's API returns
context_managementat the root level of themessage_deltaevent (sibling todeltaandusage):{ "type": "message_delta", "delta": {"stop_reason": "end_turn"}, "usage": {...}, "context_management": {"applied_edits": [...]} }see Anthropic's context management docs
summary
context_managementin the streaming schema from insidedeltato the root level ofmessage_deltavalue.context_managementinstead ofvalue.delta.context_managementverification
before fix
after fix
checklist
pnpm changesetin root)related issues
fixes #12148