You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A user's ~/.forge/.forge.toml[compact] settings (notably token_threshold) are silently discarded at runtime. No matter what value the user sets, the embedded default (token_threshold = 100000) is what actually takes effect. This makes compaction behavior uncontrollable via user config.
This is distinct from #3518 / #3519, which concern how the threshold is computed (context-window resolution and the min(token_threshold, 0.7 × window) cap). This bug is about config precedence — the user's value is never even read into the effective config, so those other fixes can't be tuned by users anyway.
Root cause
When the agent config is assembled, the agent's compact settings are merged on top of the workflow/user (.forge.toml) settings:
crates/forge_app/src/agent.rs:148 — merged_compact.merge(agent.compact.clone()) applies the agent's compact config over the user/workflow config, so the agent value wins.
This is even documented in the source comment at crates/forge_app/src/agent.rs:277-279:
CURRENT BEHAVIOR: When agent has compact settings, they override workflow settings. This means user's .forge.toml compact settings are ignored if agent has ANY compact config.
Because the embedded default agent/config carries token_threshold = 100000 (crates/forge_config/.forge.toml:67), the user's value is always overridden.
Reproduction / Evidence
I built an instrumented binary from main with a debug print inside compaction_threshold (crates/forge_domain/src/agent.rs) that logs the resolved window, the configured threshold, and the effective threshold.
Steps:
Set ~/.forge/.forge.toml → [compact] token_threshold = 424242 (a distinctive sentinel value).
Run a single turn through the instrumented binary on the vertex_ai_anthropic provider (model claude-opus-4-8).
I set 424242; the binary loaded 100000. The user-configured token_threshold is never applied.
Impact
Users cannot raise (or lower) token_threshold (or any [compact] field) via ~/.forge/.forge.toml.
On large-context models (e.g. Opus 4.x at 1M), the effective trigger is permanently pinned at 100K. Any turn whose prompt exceeds ~100K (e.g. a large tool/MCP output) triggers compaction, producing repeated per-turn compaction (a ~95K–100K "sawtooth") regardless of the user's intended threshold.
User-provided .forge.toml [compact] settings should take precedence over (or at least be merge-able with) the embedded/agent defaults. A user-set token_threshold should win over the embedded default. At minimum, the merge order in crates/forge_app/src/agent.rs:148 should not let an agent's default compact config silently override an explicit user value.
Suggested fix
Invert/adjust the merge precedence so user/workflow [compact] config overrides agent-default compact config (or only let agent compact override when it was explicitly set, not when it's the embedded default).
Location: crates/forge_app/src/agent.rs:148 (and the documented behavior at :277-279).
Environment
forge v2.13.11 (released binary reproduces the symptom; instrumented build from main produced the debug evidence above)
Provider: vertex_ai_anthropic, model claude-opus-4-8 (context_length 1,000,000 in provider.json)
Summary
A user's
~/.forge/.forge.toml[compact]settings (notablytoken_threshold) are silently discarded at runtime. No matter what value the user sets, the embedded default (token_threshold = 100000) is what actually takes effect. This makes compaction behavior uncontrollable via user config.This is distinct from #3518 / #3519, which concern how the threshold is computed (context-window resolution and the
min(token_threshold, 0.7 × window)cap). This bug is about config precedence — the user's value is never even read into the effective config, so those other fixes can't be tuned by users anyway.Root cause
When the agent config is assembled, the agent's compact settings are merged on top of the workflow/user (
.forge.toml) settings:crates/forge_app/src/agent.rs:148—merged_compact.merge(agent.compact.clone())applies the agent's compact config over the user/workflow config, so the agent value wins.This is even documented in the source comment at
crates/forge_app/src/agent.rs:277-279:Because the embedded default agent/config carries
token_threshold = 100000(crates/forge_config/.forge.toml:67), the user's value is always overridden.Reproduction / Evidence
I built an instrumented binary from
mainwith a debug print insidecompaction_threshold(crates/forge_domain/src/agent.rs) that logs the resolved window, the configured threshold, and the effective threshold.Steps:
~/.forge/.forge.toml→[compact] token_threshold = 424242(a distinctive sentinel value).vertex_ai_anthropicprovider (modelclaude-opus-4-8).Observed debug output:
I set
424242; the binary loaded100000. The user-configuredtoken_thresholdis never applied.Impact
token_threshold(or any[compact]field) via~/.forge/.forge.toml.Expected behavior
User-provided
.forge.toml [compact]settings should take precedence over (or at least be merge-able with) the embedded/agent defaults. A user-settoken_thresholdshould win over the embedded default. At minimum, the merge order incrates/forge_app/src/agent.rs:148should not let an agent's default compact config silently override an explicit user value.Suggested fix
[compact]config overrides agent-default compact config (or only let agent compact override when it was explicitly set, not when it's the embedded default).crates/forge_app/src/agent.rs:148(and the documented behavior at:277-279).Environment
v2.13.11(released binary reproduces the symptom; instrumented build frommainproduced the debug evidence above)vertex_ai_anthropic, modelclaude-opus-4-8(context_length 1,000,000 inprovider.json)