#17015: fix: correct Claude 4.5 context limits in model registry
agents
stale
size: XS
Cluster:
Context Window and Model Updates
Fixes #16955
## Problem
OpenClaw's model registry had incorrect context limits for Claude 4.5 models:
- **Claude Sonnet 4.5**: 195k (should be 1M) ❌
- **Claude Opus 4.5**: Correct at 200k ✅
- **Claude Opus 4.6**: Missing (should be 1M) ❌
This caused session deadlocks when context grew beyond 195k tokens, even though Anthropic's API supports up to 1M for Sonnet 4.5.
## Root Cause
pi-ai library has outdated context limits. OpenClaw was using these stale defaults without overrides.
## Solution
Added an Anthropic provider config that overrides context limits for Claude 4.5 models with correct values from [Anthropic's official documentation](https://docs.anthropic.com/en/docs/about-claude/models):
- Claude Sonnet 4.5: **1,000,000 tokens**
- Claude Opus 4.5: **200,000 tokens**
- Claude Opus 4.6: **1,000,000 tokens**
## Impact
- Fixes session deadlocks for long-running conversations
- Allows Sonnet 4.5 to use full 1M context window
- Prevents premature compaction/truncation
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes incorrect context window limits for Claude 4.5 models by adding an Anthropic provider configuration that overrides pi-ai's outdated defaults. The changes correctly update Claude Sonnet 4.5 from 195k to 1M tokens and add Claude Opus 4.6 with 1M tokens. The implementation follows existing patterns in the codebase for provider overrides and is unconditionally applied to ensure all users benefit from the correct limits regardless of API key configuration.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are straightforward and follow established patterns in the codebase. The fix addresses a real issue (session deadlocks due to incorrect context limits) with correct values from Anthropic's documentation. The implementation uses partial model definitions consistent with other providers in the same file, and the unconditional application ensures all users benefit from the fix.
- No files require special attention
<sub>Last reviewed commit: 13e500d</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#10831: fix(agents): set Opus 4.6 context window to 1M in forward-compat fa...
by slawt · 2026-02-07
81.4%
#20747: feat(copilot): support Claude models with correct context windows (...
by yuf1011 · 2026-02-19
80.6%
#12220: fix: forward-compat models now respect user-configured contextWindow
by Batuhan4 · 2026-02-09
77.5%
#23279: fix: show correct context limit in status when runtime model differs
by Imccccc · 2026-02-22
77.4%
#20866: fix: disable prompt caching for non-Anthropic Bedrock models
by pierreeurope · 2026-02-19
76.9%
#22303: fix: extend cacheRetention auto-injection and runtime pass-through ...
by snese · 2026-02-21
76.8%
#2806: [AI-Assisted] Fix: Repair tool_use/tool_result pairing for Claude o...
by Arthur742Ramos · 2026-01-27
76.5%
#15632: fix: use provider-qualified key in MODEL_CACHE for context window l...
by linwebs · 2026-02-13
76.3%
#20095: fix(model-forward-compat): extend claude-sonnet-4.6 forward-compat ...
by SeeYangZhi · 2026-02-18
76.1%
#17604: fix(context): use getAvailable() to prevent cross-provider model ID...
by aldoeliacim · 2026-02-16
76.1%