Skip to content

feat(llm): support Claude 1M token context window beta header#1684

Merged
bug-ops merged 2 commits intomainfrom
feat-llm-support-claude-1m-tok
Mar 13, 2026
Merged

feat(llm): support Claude 1M token context window beta header#1684
bug-ops merged 2 commits intomainfrom
feat-llm-support-claude-1m-tok

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 13, 2026

Summary

  • Add opt-in enable_extended_context: bool to CloudLlmConfig (default false)
  • When enabled, injects anthropic-beta: context-1m-2025-08-07 header into all Claude API requests
  • context_window() returns 1_000_000 for Opus 4.6 / Sonnet 4.6 when enabled (Haiku excluded with warning)
  • Compatible with interleaved-thinking beta via comma-separated header values

Configuration

[llm.cloud]
# Enable Claude 1M token context window (Opus 4.6 / Sonnet 4.6 only).
# Note: long context pricing applies above 200K tokens.
# See: https://www.anthropic.com/pricing
enable_extended_context = true

Changes

  • crates/zeph-core/src/config/types.rs: enable_extended_context field on CloudLlmConfig
  • crates/zeph-llm/src/claude.rs: beta header injection, context_window() fix, 7 new unit tests
  • crates/zeph-core/src/bootstrap/provider.rs: all 4 Claude construction sites wired
  • config/default.toml: documented option with pricing note
  • src/init.rs: wizard prompt under Claude provider arm
  • CHANGELOG.md: entry in [Unreleased]

Test plan

  • cargo nextest run --workspace --features full --lib --bins — 5278 tests pass
  • Unit tests: header absent when disabled, present when enabled, combined with interleaved thinking, context_window 1M (opus/sonnet), context_window 200K (haiku + warn)
  • Manual: set enable_extended_context = true in config, run with Claude Sonnet 4.6, verify beta header in debug dump

Closes #1649

Add opt-in `enable_extended_context` flag to `CloudLlmConfig`. When
enabled, injects `anthropic-beta: context-1m-2025-08-07` into all
Claude API requests, unlocking the 1M token context window for
Opus 4.6 and Sonnet 4.6.

- `context_window()` returns 1_000_000 for opus/sonnet when enabled
- Haiku is excluded (200K cap retained) with a tracing::warn!
- All 4 Claude construction sites in bootstrap/provider.rs wired
- Summary provider intentionally skipped (capped at 4096 max_tokens)
- beta_header() supports comma-separated multiple betas (compatible
  with interleaved-thinking)
- --init wizard prompts for extended context under Claude provider arm
- config/default.toml documents the option with pricing note
- 7 new unit tests covering enabled/disabled/haiku/combined scenarios

Closes #1649
@github-actions github-actions bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate config Configuration file changes enhancement New feature or request size/M Medium PR (51-200 lines) labels Mar 13, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 13, 2026 20:45
@bug-ops bug-ops merged commit 6506495 into main Mar 13, 2026
15 checks passed
@bug-ops bug-ops deleted the feat-llm-support-claude-1m-tok branch March 13, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(llm): support Claude 1M token context window beta header

1 participant