agent-message-window
Sliding window of recent LLM conversation turns with paired-protection: never drop a tool_use message without also dropping its tool_result sibling.
The Anthropic API rejects conversations where a tool_result block references a tool_use ID that is no longer in the message history. A naive "drop the oldest" window breaks the next request silently. This crate fixes that.
Usage
use MessageWindow;
use json;
let mut win = new;
win.add.unwrap;
win.add.unwrap;
win.add.unwrap;
// Pass win.messages_owned() to the next API call.
Features
max_turnscap with oldest-first eviction- Paired protection: evicting a
tool_usecascades to orphanedtool_resultmessages paired_protect = falsefor raw oldest-first eviction- Zero dependencies beyond
serde_json
License
MIT OR Apache-2.0