Skip to main content

safe_cut

Function safe_cut 

Source
pub fn safe_cut(ctx: &[AgentMessage], initial_cut: usize) -> usize
Expand description

Earliest index at which ctx may be split so the kept suffix ctx[cut..] has no orphaned tool result.

initial_cut is the caller’s preferred split (e.g. ctx.len() - keep); the result is always <= initial_cut (clamped to ctx.len()). Returns 0 — keep everything — when walking all the way back still can’t pair a kept result with its call.