-
Notifications
You must be signed in to change notification settings - Fork 575
UN-3130 [FEAT] - Add Support for 1M context for Anthropic LLM adapters #1732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughExtended Anthropic adapter support: added enable_extended_context to schema and updated AnthropicLLMParameters.validate to detect and enable 1M-token context from headers, manage related metadata exclusions, and append the appropriate anthropic-beta context header when active. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
unstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json (1)
56-61: Consider adding model validation to enforce compatibility with 1M context feature.The description correctly states this feature is available for Claude Sonnet 4 and Sonnet 4.5 models and requires Usage Tier 4 organizations. The implementation properly uses the beta header
context-1m-2025-08-07per Anthropic's API documentation.However, the schema currently allows any model to enable this feature without restrictions. Since
enable_extended_contextis only compatible with specific Sonnet models, consider adding JSON schema validation using conditional rules (viaallOfwithif/thenstatements), similar to howbudget_tokensis conditionally enforced whenenable_thinkingis enabled. This would prevent misconfiguration and improve user experience.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (2)
unstract/sdk1/src/unstract/sdk1/adapters/base1.pyunstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
unstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json (1)
54-55: LGTM! Documentation reference improves clarity.The updated description now references Anthropic's official documentation, which is more maintainable and provides users with authoritative information about extended thinking.
unstract/sdk1/src/unstract/sdk1/adapters/base1.py (2)
571-580: LGTM! Field exclusion logic is correct.The validation metadata correctly excludes control fields (
enable_extended_context,extra_headers) before Pydantic validation, then conditionally adds backextra_headersto the final result when extended context is enabled. This mirrors the existing pattern for thinking configuration.
588-591: Verify the beta header value and clarify temperature handling.The hardcoded beta header value
"context-1m-2025-08-07"should be verified against Anthropic's current API documentation. If this value is incorrect, all API calls with extended context enabled will fail.Additionally, unlike the thinking mode (which sets
temperature = 1on line 568), extended context mode doesn't modify the temperature. Please clarify whether this is intentional or if temperature should also be adjusted for extended context mode.The beta header value can be confirmed using the web search already requested for the schema file. If temperature adjustment is required, please update the logic:
if enable_extended_context: validated["extra_headers"] = {"anthropic-beta": "context-1m-2025-08-07"} # Add this if temperature should be modified: # validated["temperature"] = 1
chandrasekharan-zipstack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - left a minor comment
| "type": "boolean", | ||
| "title": "Enable Extended Context (1M)", | ||
| "default": false, | ||
| "description": "Enables 1 million token context window. Available for Claude Sonnet 4 and Sonnet 4.5 models. Currently in beta for Usage Tier 4 organizations." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: Consider linking any relevant docs from Anthropic so that we future proof ourselves if they decide to add / remove support for other models
gaya3-zipstack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Test ResultsSummary
Runner Tests - Full Report
SDK1 Tests - Full Report
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @unstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json:
- Around line 56-61: Update the "description" value for the JSON property
"enable_extended_context" to use the correct Anthropic docs domain: replace the
link host platform.claude.com with docs.anthropic.com so the URL becomes
https://docs.anthropic.com/en/docs/build-with-claude/context-windows#1-m-token-context-window;
modify only the string for the "description" key under "enable_extended_context"
to reflect this corrected URL, keeping the rest of the text unchanged.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to Reviews > Disable Cache setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
unstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
unstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json (1)
54-55: LGTM!The enhanced description with documentation link improves user guidance for the extended thinking feature.
| "enable_extended_context": { | ||
| "type": "boolean", | ||
| "title": "Enable Extended Context (1M)", | ||
| "default": false, | ||
| "description": "Enables 1M token context window (beta). Available for Sonnet 4 and 4.5. [Learn more](https://platform.claude.com/docs/en/build-with-claude/context-windows#1-m-token-context-window)" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, let's examine the file to see both enable_thinking and enable_extended_context properties
cat -n unstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json | sed -n '48,65p'Repository: Zipstack/unstract
Length of output: 958
🌐 Web query:
Anthropic 1M token context window documentation URL official
💡 Result:
Here are the official Anthropic docs pages for the 1M‑token context window:
- https://docs.anthropic.com/en/docs/build-with-claude/context-windows [1]
- https://docs.claude.com/en/docs/build-with-claude/context-windows [2]
Sources: [1] Anthropic Docs — Context windows; [2] Claude Docs — Context windows.
🌐 Web query:
Anthropic Claude Sonnet 4 4.5 1M token context window support models
💡 Result:
Short answer: Yes — Claude Sonnet 4 and Claude Sonnet 4.5 support a 1,000,000‑token context window (beta). Use the beta header context-1m-2025-08-07; access is limited to eligible orgs (usage tier 4 / custom rate limits) and is available on Anthropic’s API and cloud partners (Bedrock, Vertex). [1][2]
Sources:
- Anthropic docs: Context windows (Sonnet 4 — 1M token beta + beta header and tier requirements). [1]
- Claude docs: Sonnet 4 and Sonnet 4.5 1M context details and context‑awareness notes. [2]
Correct the documentation URL domain.
The documentation link uses platform.claude.com, which is not an official Anthropic documentation domain. Change it to docs.anthropic.com to match the enable_thinking property and align with official Anthropic documentation. The model availability claim for Sonnet 4 and 4.5 is accurate.
Suggested fix:
"description": "Enables 1M token context window (beta). Available for Sonnet 4 and 4.5. [Learn more](https://docs.anthropic.com/en/docs/build-with-claude/context-windows#1-m-token-context-window)"
🤖 Prompt for AI Agents
In @unstract/sdk1/src/unstract/sdk1/adapters/llm1/static/anthropic.json around
lines 56 - 61, Update the "description" value for the JSON property
"enable_extended_context" to use the correct Anthropic docs domain: replace the
link host platform.claude.com with docs.anthropic.com so the URL becomes
https://docs.anthropic.com/en/docs/build-with-claude/context-windows#1-m-token-context-window;
modify only the string for the "description" key under "enable_extended_context"
to reflect this corrected URL, keeping the rest of the text unchanged.



What
Why
How
Enable Extended Contextin our adapter creation form.extra_headers={"anthropic-beta": "context-1m-2025-08-07"}to the anthropic LLM instance.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist
I have read and understood the Contribution Guidelines.