Skip to content

[FEATURE]: Per-agent compaction config (disable compaction for specific agents) #16375

@leeweisern

Description

@leeweisern

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

  1. Configure the explore subagent with a codex model (e.g. opencode/codex-spark)
  2. Use explore for codebase exploration until context gets long enough to trigger compaction
  3. 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:

{
  "agent": {
    "explore": {
      "compaction": {
        "auto": false
      }
    }
  }
}

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions