Skip to content

Per-agent compaction and contextPruning overrides in agents.list #52732

Description

@adrijc93

Problem

Currently compaction and contextPruning settings can only be configured globally in agents.defaults. When using agents.list with per-agent overrides (e.g., model, workspace), these two settings are rejected as unrecognized keys:

agents.list.0: Unrecognized keys: "compaction", "contextPruning"

Use Case

In a multi-agent setup with different models (e.g., Opus for complex reasoning agents + Sonnet for task execution agents), each model benefits from different context management:

  • Opus agents (1M context): Can handle larger history shares (maxHistoryShare: 0.8) and more recent tokens (keepRecentTokens: 80000), with longer cache TTLs (2h)
  • Sonnet agents (200K context): Need more aggressive compaction (maxHistoryShare: 0.5, keepRecentTokens: 30000, cache TTL 30m) to avoid context pollution and drift

With the current global-only config, we have to compromise on settings that are suboptimal for both tiers.

Proposed Solution

Allow compaction and contextPruning as optional per-agent overrides in agents.list[*], merging with agents.defaults (same pattern already used for model, workspace, heartbeat, etc.):

{
  "agents": {
    "defaults": {
      "compaction": { "maxHistoryShare": 0.5, "keepRecentTokens": 30000 },
      "contextPruning": { "mode": "cache-ttl", "ttl": "30m" }
    },
    "list": [
      {
        "id": "main",
        "compaction": { "maxHistoryShare": 0.8, "keepRecentTokens": 80000 },
        "contextPruning": { "ttl": "2h" }
      },
      {
        "id": "worker-agent",
        "model": "anthropic/claude-sonnet-4-6"
      }
    ]
  }
}

Environment

  • OpenClaw 2026.3.13
  • 8 agents (2 Opus, 6 Sonnet) with different context management needs

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions