# Add auto_compact agent settings \(\#58883\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 9baefe701e3c342a74e0aaad562e9503a790adee

Requested commit: 9baefe701e3c342a74e0aaad562e9503a790adee

Commit: 9baefe701e3c342a74e0aaad562e9503a790adee

Tree: f2dc6029a7a226c10b5ae9788c9f9839f29f67be

Author: Richard Feldman

Committer: GitHub

## Message

```
Add auto_compact agent settings (#58883)

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>
```

## Parents

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

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