feat: add context management support and corresponding beta handling - #1080
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe Anthropic adapter adds ChangesAnthropic context management
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change adds the required beta handling for context management and includes targeted tests; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant ModelOptions
participant AnthropicTextAdapter
participant AnthropicAPI
ModelOptions->>AnthropicTextAdapter: Provide context_management
AnthropicTextAdapter->>AnthropicTextAdapter: Compute context-management beta
AnthropicTextAdapter->>AnthropicAPI: Send context_management and beta header
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for the PR, @harshlocham! 🙌 @AlemTuzlak will take a look. Automated pre-review checks
Automated triage — a human review follows. |
85ce43a to
7aada67
Compare
7aada67 to
baa97ea
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Maintainer sweep: rebased onto |
|
View your CI Pipeline Execution ↗ for commit e6b5f24
☁️ Nx Cloud last updated this comment at |
- Updated `computeAnthropicBetas` to include a new `context_management` option, which adds the `context-management-2025-06-27` beta when set. - Enhanced the `buildServerToolResultBlock` documentation to reflect the new context management feature. - Added tests to verify the correct forwarding of `context_management` and the attachment of the required beta in the adapter. - Ensured that the beta is not added when `context_management` is null. Closes issue TanStack#1074.
294318e to
e6b5f24
Compare
|
Maintainer sweep: rebased onto |
@tanstack/ai
@tanstack/ai-acp
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-bedrock
@tanstack/ai-byteplus
@tanstack/ai-claude-code
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-snippets
@tanstack/ai-codex
@tanstack/ai-cohere
@tanstack/ai-devtools-core
@tanstack/ai-durable-stream
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-grok-build
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-daytona
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-isolate-quickjs-bun
@tanstack/ai-mcp
@tanstack/ai-memory
@tanstack/ai-mistral
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-opencode
@tanstack/ai-openrouter
@tanstack/ai-perplexity
@tanstack/ai-persistence
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-sandbox
@tanstack/ai-sandbox-cloudflare
@tanstack/ai-sandbox-daytona
@tanstack/ai-sandbox-docker
@tanstack/ai-sandbox-local-process
@tanstack/ai-sandbox-sprites
@tanstack/ai-sandbox-vercel
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vercel-gateway
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
🎯 Changes
Fixes #1074.
modelOptions.context_managementwas typed and forwarded on the Anthropic Messages body, butcomputeAnthropicBetasnever attached the requiredcontext-management-2025-06-27beta. Context editing therefore typechecked and could not work.context-management-2025-06-27whencontext_management != null(treatnullas unset)computeAnthropicBetasbetasare both sent✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Bug Fixes
Documentation