Skip to content

feat: return 1M context for Claude Opus 4.6/4.7/4.8 families#3267

Merged
dgageot merged 2 commits into
docker:mainfrom
dgageot:worktree-board-0b6d1c967d87b212
Jun 26, 2026
Merged

feat: return 1M context for Claude Opus 4.6/4.7/4.8 families#3267
dgageot merged 2 commits into
docker:mainfrom
dgageot:worktree-board-0b6d1c967d87b212

Conversation

@dgageot

@dgageot dgageot commented Jun 26, 2026

Copy link
Copy Markdown
Member

DefaultClaudeContextLimit in pkg/modelinfo/modelinfo.go returned the 200k fallback for Claude Opus 4.6, 4.7, and 4.8 when models.dev had no catalogue entry, even though these models expose a 1,000,000-token context window. That fallback feeds the Anthropic client's max_tokens clamping on the context-overflow retry path, so a stale 200k value could clamp max_tokens too aggressively on models that can handle much more.

DefaultClaudeContextLimit now returns 1,000,000 for the claude-opus-4-6, claude-opus-4-7, and claude-opus-4-8 families, matching the existing claude-fable handling. Bedrock-style inference-profile IDs (e.g. global.anthropic.claude-opus-4-8-...) are also recognised by stripping the profile prefix before the family check.

As a small follow-on, the Opus 4.6/4.7/4.8 prefix matching that was previously duplicated between RejectsTokenThinking and DefaultClaudeContextLimit is extracted into a shared unexported helper isClaudeOpus46To48, backed by a package-level claudeOpus46To48Prefixes slice. Adding support for a future Opus version now requires a single-line change in one place.

dgageot added 2 commits June 26, 2026 13:43
Bedrock-style inference profile IDs are resolved via bedrockClaudeModelName
before the prefix check, so both direct and global Bedrock IDs are covered.

Assisted-By: Claude
@dgageot dgageot requested a review from a team as a code owner June 26, 2026 11:57

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The isClaudeOpus46To48 helper extraction is clean and the prefix-boundary check (== prefix || HasPrefix(prefix+"-")) correctly rejects false positives like claude-opus-4-60. Both RejectsTokenThinking and DefaultClaudeContextLimit now delegate to the shared helper consistently. Bedrock inference-profile ID stripping works correctly. Test coverage is thorough.

No high- or medium-severity issues found.

ℹ️ Low-severity observations (no action required)

pkg/modelinfo/modelinfo.go:294 — Double Bedrock prefix strip is harmless but redundant

DefaultClaudeContextLimit calls bedrockClaudeModelName to strip the Bedrock prefix into m, then passes m to isClaudeOpus46To48, which internally calls bedrockClaudeModelName again. The double-strip is a no-op with current model naming conventions (a bare claude-* name will never look like a Bedrock profile ID), but it creates a subtle coupling: if a future bedrockClaudeModelName could produce output matching the Bedrock pattern, the inner call would strip further. Consider either passing the already-stripped bare name directly, or documenting that isClaudeOpus46To48 accepts both raw and pre-stripped IDs.

@aheritier aheritier added area/models LLM model integrations and model providers kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Jun 26, 2026
@dgageot dgageot merged commit 5b5192c into docker:main Jun 26, 2026
10 checks passed
@dgageot dgageot deleted the worktree-board-0b6d1c967d87b212 branch June 26, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/models LLM model integrations and model providers kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants