Files
zed/crates
tidely ead5672e16 agent: Fix compaction being billed as un-cached input tokens (#64938)
## 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
2026-11-04 13:36:23 +00:00
..
…
2026-10-26 11:20:07 +00:00
…
2026-10-29 10:48:05 +00:00
2026-10-26 13:46:57 +00:00
…
…
2026-10-26 10:10:32 +00:00
…
…
…
…
…
…