# Add built-in /compact slash command to the native agent \(\#58663\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/e5052961af01e6810f961d6b217376edbe02b106)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: e5052961af01e6810f961d6b217376edbe02b106

Requested commit: e5052961af01e6810f961d6b217376edbe02b106

Commit: e5052961af01e6810f961d6b217376edbe02b106

Tree: 54e4f05e20772b7f0247870e80fb59329ee21f97

Author: Richard Feldman

Committer: GitHub

## Message

```
Add built-in /compact slash command to the native agent (#58663)

<img width="851" height="315" alt="Screenshot 2026-06-09 at 2 15 51 AM"
src="https://github.com/user-attachments/assets/958f2d2f-db7d-4afb-b4b3-ed11f36b00e7"
/>

<img width="644" height="260" alt="Screenshot 2026-06-09 at 2 16 04 AM"
src="https://github.com/user-attachments/assets/e6a74c6b-aba5-4fbb-991c-25842ced5832"
/>

<img width="619" height="128" alt="Screenshot 2026-06-09 at 2 18 08 AM"
src="https://github.com/user-attachments/assets/ba7fa303-852b-4a17-b8df-ea5bd4df7c11"
/>


Adds an always-available `/compact` slash command to Zed's native agent
that forces a summary-based context compaction of the current
conversation, regardless of token usage. This reuses the agent's
existing compaction logic (always the summary strategy, never
provider-native), bypassing the automatic-compaction token threshold and
minimum-context-window guard since the user explicitly asked to compact.
The command lives entirely in `NativeAgent`/`NativeAgentConnection`, so
external (ACP) agents are untouched and keep their own `/compact`
implementations.

The command is gated behind the `handoff` feature flag, matching the
gate on automatic compaction, so it's only advertised and dispatched
when that flag is enabled. When the flag is off, typing `/compact` is
treated as an ordinary prompt.

Because the agent panel always renders the typed `/compact` as a user
message, the manual compaction records a matching zero-content user
message in the model thread (skipped when building model requests) so
that rewinding/truncating that message works instead of erroring, while
keeping the command itself out of the model's context.

The slash-command popup now groups commands into separate sections by
source — "Commands" (built-in, e.g. `/compact`), "MCP Server Commands",
and "ACP Agent Commands" — so same-named commands from different sources
show up as distinguishable duplicates. The source category travels on
each command's ACP `_meta`.

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
```

## Parents

- [c680755ae06538e81dc618b6b0311a0fcf101d8d](https://git.cafe/gitcafe/zed/commit/c680755ae06538e81dc618b6b0311a0fcf101d8d?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/e5052961af01e6810f961d6b217376edbe02b106?format=markdown)
