pub struct ToolResultPolicy {
pub max_bytes: Option<usize>,
pub dedupe_repeats: bool,
}Expand description
A ceiling on how much of one tool result reaches the context.
A single call can return more than the whole conversation: a lock file, a
SELECT *, an MCP tool the framework does not control. Measured on a real
run, “search these files for a word” cost 53,487 input tokens because one
read_file returned a lock file — the model then paid for it on every
subsequent turn, and compaction started throwing away real history to make
room. A per-result ceiling is the only place to stop that: the tools cannot
all be trusted (third-party MCP), and the compactor only runs after the
damage is in the context.
Fields§
§max_bytes: Option<usize>Max serialized bytes of a single tool result. None disables the guard.
Default ~24 KiB — roughly 6k tokens of English, generous for a file page
or a query result, far below what blows a window.
dedupe_repeats: boolReplace the payload of a read-only call that exactly repeats an earlier one in the same run, when nothing has modified the world in between.
StuckPolicy only sees consecutive identical rounds. Reading a file
at iteration 1 and again at iteration 5 is not that, and looks like
progress — but the same bytes land in the context twice and the model
learns nothing the second time. Measured on a real run, model wait was
36.7s against 3ms of tool execution: a repeat costs context, not time,
so what is suppressed is the payload, not the call.
Only ToolRisk::ReadOnly qualifies (Network is a separate risk, and an
external endpoint may answer differently), and any non-read-only call
clears the record — after a write, re-reading is the correct move.
Trait Implementations§
Source§impl Clone for ToolResultPolicy
impl Clone for ToolResultPolicy
Source§fn clone(&self) -> ToolResultPolicy
fn clone(&self) -> ToolResultPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more