Skip to content

feat(config): make the auto-compaction threshold configurable (compaction_threshold) #3433

Description

@aheritier

Summary

The proactive auto-compaction trigger is currently a hardcoded constant contextThreshold = 0.9 in pkg/compaction. Make it configurable, and expose an explicit on/off knob for session compaction.

Motivation

Roo Code exposes a configurable condense threshold. docker-agent's threshold is not tunable, and the existing WithSessionCompaction(bool) runtime option is not surfaced in YAML/CLI at all.

Proposed behavior

  • New compaction_threshold config key, range 0 < x <= 1, default 0.9 (behavior unchanged unless set).
  • Decision: place it per-agent, with an optional per-model override (next to compaction_model).
  • Also surface an explicit enable/disable knob (e.g. session_compaction: false) mapping to the existing WithSessionCompaction runtime opt.

Implementation notes (starting points)

  • Replace the package const in pkg/compaction/compaction.go; thread the value as a parameter through ShouldCompact
  • pkg/runtime/loop.go (~line 501 proactive trigger; ~1107-1122 compactIfNeeded), pkg/runtime/runtime.go (opts)
  • pkg/agent/agent.go + pkg/agent/opts.go, pkg/teamloader wiring
  • Config additions go ONLY to pkg/config/latest/types.go + validate.go (schema is versioned), plus agent-schema.json and a new example YAML
  • Extend pkg/runtime/compaction_trigger_test.go

Complexity: S–M.

Background: shared plan context-management-gap-analysis (Phase 1, item 2).

Dependencies / Relationships

Metadata

Metadata

Assignees

Labels

area/agentFor work that has to do with the general agent loop/agentic features of the apparea/configFor configuration parsing, YAML, environment variablesarea/runtimeRuntime engine, agent loop execution, tool dispatch, loop detectionarea/sessionsFor features/issues/fixes related to session lifecycle (resume, persistence, export)kind/featPR adds a new feature (maps to feat:). Use on PRs only.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions