Skip to content

Add auto_compact agent settings - #58883

Merged
bennetbo merged 6 commits into
mainfrom
agent-auto-compact-settings
Jun 9, 2026
Merged

Add auto_compact agent settings#58883
bennetbo merged 6 commits into
mainfrom
agent-auto-compact-settings

Conversation

@rtfeldman

@rtfeldman rtfeldman commented Jun 9, 2026

Copy link
Copy Markdown
Contributor
Screenshot 2026-06-09 at 1 59 50 AM

Adds two new agent settings nested under auto_compact, enabled and threshold, which control automatic compaction of the agent's context window as part of the handoff feature. Both surface in the settings UI under Agent Configuration, gated behind the handoff feature flag so they only appear for users on that flag.

The threshold accepts three forms: a percentage string ending in % (e.g. "80%" or "95.5%") measured against the model's context window, a positive integer to compact after that many tokens have been used, or a negative integer to compact once that many tokens remain in the window. 0 and bare non-integer numbers are rejected. It deserializes from either a JSON string or integer and resolves to a typed enum, falling back to the "80%" default (with a logged warning) when the configured value is invalid. In the settings UI the threshold is a free-form text field so all three forms can be entered.

Release Notes:

  • N/A

@rtfeldman rtfeldman self-assigned this Jun 9, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 9, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 9, 2026
@rtfeldman
rtfeldman force-pushed the agent-auto-compact-settings branch from 5dd2757 to bced27b Compare June 9, 2026 01:31
@rtfeldman
rtfeldman requested a review from bennetbo June 9, 2026 06:18
@rtfeldman
rtfeldman marked this pull request as ready for review June 9, 2026 06:18
@rtfeldman
rtfeldman force-pushed the agent-auto-compact-settings branch from 160e155 to 96c6103 Compare June 9, 2026 06:22
@bennetbo
bennetbo added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit 9baefe7 Jun 9, 2026
32 checks passed
@bennetbo
bennetbo deleted the agent-auto-compact-settings branch June 9, 2026 10:56
NsdHSO pushed a commit to NsdHSO/zed that referenced this pull request Jun 17, 2026
…ustries#59469)

Follow up to zed-industries#58883

This makes sure that we subtract the max output tokens before checking
the threshold for auto compaction was reached, we had that logic before
zed-industries#58883 but we lost it when introducing the settings. Without this GPT
models will run out of tokens before auto-compaction is run

Release Notes:

- (Preview only) Fixed an issue where auto compaction would not be
triggered
zed-zippy Bot added a commit that referenced this pull request Jun 17, 2026
… (cherry-pick to preview) (#59475)

Cherry-pick of #59469 to preview

----
Follow up to #58883

This makes sure that we subtract the max output tokens before checking
the threshold for auto compaction was reached, we had that logic before
#58883 but we lost it when introducing the settings. Without this GPT
models will run out of tokens before auto-compaction is run

Release Notes:

- (Preview only) Fixed an issue where auto compaction would not be
triggered

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
Adds two new agent settings nested under `auto_compact`, `enabled` and
`threshold`, which control automatic compaction of the agent's context
window as part of the handoff feature. Both surface in the settings UI
under Agent Configuration, gated behind the `handoff` feature flag so
they only appear for users on that flag.

The `threshold` accepts three forms: a percentage string ending in `%`
(e.g. `"80%"` or `"95.5%"`) measured against the model's context window,
a positive integer to compact after that many tokens have been used, or
a negative integer to compact once that many tokens remain in the
window. `0` and bare non-integer numbers are rejected. It deserializes
from either a JSON string or integer and resolves to a typed enum,
falling back to the `"80%"` default (with a logged warning) when the
configured value is invalid. In the settings UI the threshold is a
free-form text field so all three forms can be entered.

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
Adds two new agent settings nested under `auto_compact`, `enabled` and
`threshold`, which control automatic compaction of the agent's context
window as part of the handoff feature. Both surface in the settings UI
under Agent Configuration, gated behind the `handoff` feature flag so
they only appear for users on that flag.

The `threshold` accepts three forms: a percentage string ending in `%`
(e.g. `"80%"` or `"95.5%"`) measured against the model's context window,
a positive integer to compact after that many tokens have been used, or
a negative integer to compact once that many tokens remain in the
window. `0` and bare non-integer numbers are rejected. It deserializes
from either a JSON string or integer and resolves to a typed enum,
falling back to the `"80%"` default (with a logged warning) when the
configured value is invalid. In the settings UI the threshold is a
free-form text field so all three forms can be entered.

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
…ustries#59469) (cherry-pick to preview) (zed-industries#59475)

Cherry-pick of zed-industries#59469 to preview

----
Follow up to zed-industries#58883

This makes sure that we subtract the max output tokens before checking
the threshold for auto compaction was reached, we had that logic before
zed-industries#58883 but we lost it when introducing the settings. Without this GPT
models will run out of tokens before auto-compaction is run

Release Notes:

- (Preview only) Fixed an issue where auto compaction would not be
triggered

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ustries#59469)

Follow up to zed-industries#58883

This makes sure that we subtract the max output tokens before checking
the threshold for auto compaction was reached, we had that logic before
zed-industries#58883 but we lost it when introducing the settings. Without this GPT
models will run out of tokens before auto-compaction is run

Release Notes:

- (Preview only) Fixed an issue where auto compaction would not be
triggered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants