Two related problems cause forge to under-utilize large context windows on Claude Opus 4.x (1M) models.
1. get_context_length() returns 200K for 1M-token Opus models
crates/forge_app/src/dto/anthropic/response.rs:96-101 matches the prefix claude-opus-4- and returns 200_000, incorrectly capturing claude-opus-4-6/4-7/4-8, which are 1M-token models per crates/forge_repo/src/provider/provider.json ("id": "claude-opus-4-8", "context_length": 1000000).
This affects the native Anthropic /models path (the vertex_ai_anthropic path is unaffected since it reads context_length from provider.json).
Suggested fix: return 1_000_000 for the claude-opus-4-6-/4-7-/4-8- prefixes before the generic 200K branch; update the test at response.rs:713-722.
2. Default compaction token_threshold (100K) ignores large windows
The effective compaction trigger is min(configured_token_threshold, context_window * token_threshold_percentage) (crates/forge_domain/src/agent.rs:255-271). The embedded default token_threshold = 100000 (crates/forge_config/.forge.toml) makes the trigger min(100K, 0.7 x 1M) = 100K on a 1M-token model — only ~10% of the window, firing compaction far too early and leaving ~900K tokens unused.
Suggestion: let the percentage cap drive the threshold on large windows (drop the hard 100K default, or make it window-relative).
Two related problems cause forge to under-utilize large context windows on Claude Opus 4.x (1M) models.
1.
get_context_length()returns 200K for 1M-token Opus modelscrates/forge_app/src/dto/anthropic/response.rs:96-101matches the prefixclaude-opus-4-and returns200_000, incorrectly capturingclaude-opus-4-6/4-7/4-8, which are 1M-token models percrates/forge_repo/src/provider/provider.json("id": "claude-opus-4-8", "context_length": 1000000).This affects the native Anthropic
/modelspath (thevertex_ai_anthropicpath is unaffected since it readscontext_lengthfromprovider.json).Suggested fix: return
1_000_000for theclaude-opus-4-6-/4-7-/4-8-prefixes before the generic 200K branch; update the test atresponse.rs:713-722.2. Default compaction
token_threshold(100K) ignores large windowsThe effective compaction trigger is
min(configured_token_threshold, context_window * token_threshold_percentage)(crates/forge_domain/src/agent.rs:255-271). The embedded defaulttoken_threshold = 100000(crates/forge_config/.forge.toml) makes the triggermin(100K, 0.7 x 1M) = 100Kon a 1M-token model — only ~10% of the window, firing compaction far too early and leaving ~900K tokens unused.Suggestion: let the percentage cap drive the threshold on large windows (drop the hard 100K default, or make it window-relative).