Watch
0
0
Fork
You've already forked hyperhive
0

hive-agent: let an agent compact from 40% context usage instead of 66%

This commit is contained in:
damocles 2026-11-14 12:35:27 +01:00
commit 183e55dd80

View file

@ -39,7 +39,7 @@ use crate::todos::{Todo, Todos};
/// effective context window, an agent-initiated compact is refused (nothing
/// meaningful to reclaim yet, and it'd just burn a compaction pass on a
/// near-empty session).
const COMPACT_MIN_USAGE_FRACTION: f64 = 0.66;
const COMPACT_MIN_USAGE_FRACTION: f64 = 0.40;
/// Pause after a failed `accept`, so a failure that persists (fd exhaustion)
/// does not turn the accept loop into a busy spin.
@ -982,6 +982,22 @@ mod tests {
assert!(low.take_compact().is_none(), "a refusal queues nothing");
}
#[test]
fn the_compact_floor_is_forty_percent_of_the_window() {
let (_dir, todos, _) = stores();
let wake = Notify::new();
let under = bus_with_context(39);
let resp = dispatch(compact_req(None), &todos, &wake, None, &under);
assert!(
matches!(&resp, Response::Err { message } if message.contains("40%")),
"{resp:?}"
);
let at = bus_with_context(40);
let resp = dispatch(compact_req(None), &todos, &wake, None, &at);
assert!(matches!(resp, Response::Ok), "{resp:?}");
assert!(at.take_compact().is_some(), "the floor itself is allowed");
}
#[test]
fn compact_above_the_floor_queues_the_request_with_its_wake_prompt() {
let (_dir, todos, _) = stores();