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
dbf7f63875Anant Goel committed on 8/17/2026, 8:07:14 AM· committed by GitHubparent90eb566