# anthropic: Preserve request context during explicit compaction \(\#62745\) · gitcafe/zed

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

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

Visibility: public

Requested revision: dbf7f63875b4662308335dd95951569d0f661b0a

Requested commit: dbf7f63875b4662308335dd95951569d0f661b0a

Commit: dbf7f63875b4662308335dd95951569d0f661b0a

Tree: 6950f20d45ec20d27646ba26b44a7665c6ccc2ef

Author: Anant Goel

Committer: GitHub

## Message

```
anthropic: Preserve request context during explicit compaction (#62745)

Explicit compaction currently removes tool definitions before sending
the request. That changes the prompt-cache prefix and can lower the
effective input size below Anthropic's minimum compaction trigger,
causing the request to complete without producing replacement context.

Keep tool definitions in explicit compaction requests while setting
`tool_choice` to `none`, preserving the input context without allowing
tool calls. Also append a user turn when the conversation ends with an
assistant message, since current Anthropic models reject that shape as
unsupported assistant prefill.

Testing:

- `cargo test -p anthropic`
- `cargo fmt --check`
- `./script/clippy -p anthropic`

Release Notes:

- N/A
```

## Parents

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

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