Skip to content

Feature: allow /compact to be invoked by the agent (programmatic compaction) #3916

Description

@dfrysinger

Summary

/compact is currently a user-only slash command. The agent itself should be able to invoke compaction when it detects it's running short on context or when a long task naturally hits a phase boundary.

Use cases

  • Multi-phase workflows (e.g. plan → implement → review pipelines) where the agent knows when a phase is complete and the prior context can be safely summarized.
  • Long-running autonomous sessions where the user isn't present to trigger /compact manually.
  • Skill / plugin authors who want to script a compaction step at a known-safe boundary.

Proposal

Expose /compact as a callable tool (e.g. compact_context) so the agent can invoke it programmatically, with the same effect as the user typing the slash command. Permission-gate it the same way other state-changing tools are gated.

Out of scope

Auto-compaction policy (when to fire, what to summarize) is separate; this issue is only about exposing the existing capability to the agent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agentsSub-agents, fleet, autopilot, plan mode, background agents, and custom agentsarea:context-memoryContext window, memory, compaction, checkpoints, and instruction loading
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions