-
Notifications
You must be signed in to change notification settings - Fork 12k
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Problem
Compaction is currently only configurable globally via compaction: { auto, prune, reserved }. There is no way to control compaction behavior per-agent.
This causes issues with read-only agents like explore -- when compaction triggers during an explore subagent session, the agent loses its read-only constraints and starts writing code.
Reproduction
- Configure the
exploresubagent with a codex model (e.g.opencode/codex-spark) - Use explore for codebase exploration until context gets long enough to trigger compaction
- After compaction, explore starts making file edits despite being a read-only agent
Proposed solution
Allow compaction to be configured per-agent, consistent with how tools, permission, model, steps, and temperature already support per-agent overrides.
JSON config example:
Markdown agent example:
---
description: Fast codebase exploration
mode: subagent
compaction:
auto: false
---Alternative (minimum fix)
If per-agent compaction config is too broad, at minimum the compaction agent should preserve the invoking agent's tool/permission constraints after compacting. If an agent has write: false and edit: false, those constraints should survive compaction.
Why this makes sense
- The
exploreagent is documented as "A fast, read-only agent for exploring codebases. Cannot modify files." (docs). Compaction breaking this contract is unexpected. - Per-agent config already exists for:
model,prompt,temperature,top_p,steps,tools,permission,mode,hidden,color,disable. Addingcompactionis consistent with this pattern. - Related (but different scope): Experimental compaction improvements (prefix preservation + prompt customization) #11497 (compaction prompt customization), Feature Request: Configurable context limit and auto-compaction threshold #8140 (global compaction threshold).
{ "agent": { "explore": { "compaction": { "auto": false } } } }