mirror of
https://github.com/block/buzz.git
synced 2026-11-12 04:12:21 +00:00
Review finding (Wren): `should_handoff()` still routed its measured-usage
arm through `projected_handoff_input_tokens()`, which added a 1-byte/token
estimate of history appended since the usage was recorded. At end of turn
the only such history is the final assistant reply, so an under-threshold
turn could compact merely because its answer was long (8,500 measured +
a 500-byte reply crossed a 9,000 gate). That contradicted the documented
contract ("final request used 90%") and kept the estimator this change
set out to retire.
- handoff.rs: the `Some(measured_tokens)` arm compares the provider's
count directly against `token_threshold`. `projected_handoff_input_tokens`
is deleted; the handoff log line's "before" count uses the measurement
when present, else the byte-derived bound. The `None` byte fallback is
unchanged. Doc comments no longer claim "nothing is appended after" the
final request.
- agent.rs / lib.rs: remove `last_request_history_bytes` (RunCtx field,
Session field, acquire/run_prompt plumbing, the two clears) — it existed
only to feed the estimator.
- tests/regressions.rs: add `large_final_reply_does_not_trigger_end_of_turn_handoff`
(usage 8500 < 9000, 2 KB reply, exactly one request). Fails on the
parent commit; passes here. Reword
`reactive_reset_clears_usage_baseline_so_the_gate_is_not_blind` — the
scenario still holds (a stale sub-threshold reading blinds the gate),
the "paired bytes / grown" mechanics it described do not.
Co-authored-by: Meli <5aaa86bce934fc3445fc254aab560a40923f10252f92107e665073dede0e04d3@buzz.block.builderlab.xyz>
Signed-off-by: Meli <5aaa86bce934fc3445fc254aab560a40923f10252f92107e665073dede0e04d3@buzz.block.builderlab.xyz>