-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Context limit resolution ignores GOOSE_PREDEFINED_MODELS and config.yaml — falls back to canonical registry 200k default #7839
Description
Describe the bug
When using a model configured in GOOSE_PREDEFINED_MODELS with a custom context_limit (e.g., 1M for Claude Opus 4.6 with the context-1m beta header), the context limit resolves to 200k instead of 1M. This causes auto-compaction to fire at ~160k tokens (80% of 200k), destroying conversation history mid-session.
Two issues combine:
-
GOOSE_CONTEXT_LIMITinconfig.yamlis silently ignored. The code reads it viastd::env::var("GOOSE_CONTEXT_LIMIT")inModelConfig::new_base()(crates/goose/src/model.rs), which checks the process environment — not config.yaml. The desktop app (Electron) doesn't source shell profiles, so the value never reaches the code. -
Canonical registry overrides predefined models. In
ModelConfig::with_canonical_limits(), the canonical registry lookup resolvesgoose-claude-4-6-opus→anthropic/claude-opus-4.6→context: 200000and setsself.context_limit. The predefined models fallback (context_limit: 1000000) is only checked ifself.context_limit.is_none()— but it's already set to 200k by the canonical registry.
Resolution chain:
| Priority | Source | Value | Used? |
|---|---|---|---|
| 1 | GOOSE_CONTEXT_LIMIT env var |
Not set (config.yaml value ignored) | ❌ |
| 2 | Canonical model registry | 200,000 | ✅ Wins |
| 3 | GOOSE_PREDEFINED_MODELS |
1,000,000 | ❌ Never reached |
To Reproduce
- Set
GOOSE_CONTEXT_LIMIT: 1000000in~/.config/goose/config.yaml - Select
goose-claude-4-6-opusas the model (via UI dropdown or config) - Confirm
GOOSE_PREDEFINED_MODELSenv var includes the model withcontext_limit: 1000000andrequest_params: { anthropic_beta: ["context-1m-2025-08-07"] } - Start a session and check the info-msg — context limit reports as 200k, not 1M
- Auto-compaction fires at ~160k tokens
Expected behavior
Context limit should be 1,000,000 tokens. Either:
GOOSE_CONTEXT_LIMITfrom config.yaml should be respected (priority 1), ORcontext_limitfrom the matchingGOOSE_PREDEFINED_MODELSentry should take priority over the canonical registry default
Screenshots
N/A — reproducible via info-msg token reporting.
Please provide the following information
- OS & Arch: macOS (Apple Silicon)
- Interface: UI (desktop app)
- Version: 1.27.2-block
- Extensions enabled: Computer Controller, Memory, Extension Manager
- Provider & Model: Databricks – goose-claude-4-6-opus
Additional context
Suggested fix (Option A — minimal): In with_canonical_limits(), check predefined models BEFORE the canonical registry. Predefined models are explicitly configured by the deployment team and should take priority over generic canonical defaults:
// Check predefined models first (explicit config > generic defaults)
if self.context_limit.is_none() {
if let Some(pm) = find_predefined_model(&self.model_name) {
self.context_limit = pm.context_limit;
}
}
// Fall back to canonical registry
if self.context_limit.is_none() {
if let Some(canonical) = ... {
self.context_limit = Some(canonical.limit.context);
}
}Suggested fix (Option B — also needed): Make GOOSE_CONTEXT_LIMIT in config.yaml work by reading it via Config::global().get_param() (like GOOSE_MAX_TOKENS already does) instead of std::env::var().
Workaround: Set GOOSE_CONTEXT_LIMIT as a real environment variable visible to GUI apps via launchctl setenv GOOSE_CONTEXT_LIMIT 1000000, then restart the app.
Other reports: This was also reported in #goose-help on Slack (March 10, 2026) without resolution. Related: GitHub issue #4357 (closed October 2025) addressed a different surface of the same underlying problem.