Add built-in /compact slash command to the native agent - #58663
Merged
Conversation
Force-prefix MCP prompts that collide with the built-in /compact, defer the rewind marker so cancelled/failed/no-op compactions leave no trailing message, queue text typed after /compact instead of dropping it, and order slash-command completion groups by relevance so an exact prefix match is the default selection.
rtfeldman
marked this pull request as ready for review
June 9, 2026 06:21
rtfeldman
requested review from
bennetbo and
danilo-leal
and removed request for
danilo-leal
June 9, 2026 06:21
bennetbo
reviewed
Jun 9, 2026
| /// it as a follow-up message. The queued remainder auto-processes when the | ||
| /// command turn stops, so e.g. `/compact do X` compacts and then runs `do X` | ||
| /// rather than discarding it. | ||
| fn send_command_queueing_remainder( |
Member
There was a problem hiding this comment.
Not sure if we really need this. I feel like we can get away with typing /compact something something doing nothing (treat it as normal text). Seems like this is what all the other tools are doing too
bennetbo
approved these changes
Jun 9, 2026
bennetbo
enabled auto-merge
June 9, 2026 09:05
This was referenced Jun 18, 2026
Closed
This was referenced Jul 8, 2026
jonx
pushed a commit
to jonx/zed-aros
that referenced
this pull request
Jul 17, 2026
…es#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>
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
…es#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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an always-available
/compactslash 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 inNativeAgent/NativeAgentConnection, so external (ACP) agents are untouched and keep their own/compactimplementations.The command is gated behind the
handofffeature 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/compactis treated as an ordinary prompt.Because the agent panel always renders the typed
/compactas 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: