mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
ead5672e16
## Summary Compaction currently bills the entire context window as input tokens instead of cached input tokens, because tool definitions change during compaction requests. Compaction here is separate from native provider compaction. Closes #59528 The fix is only able to be applied to providers which have a way of disabling tools without changing the tool definitions. This notably does not include Anthropic. This PR adds a compaction strategy enum, which describes whether a provider supports disabling tools without causing a cache miss. The new variant checks whether the model supports `tool_choice: none` and includes it in the request, while keeping the tool definitions the same. A provider may support `tool_choice: none`, but still bust the cache, or have models which don't support it. So we need both the enum and `tool_choice: none` check. ## Testing I've added tests for checking request prefix equality during compaction, where this new fix is applied. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Fixed compaction being billed as un-cached input tokens