hive-agent: let an agent compact from 40% context usage instead of 66%
This commit is contained in:
parent
c7580ac3dd
commit
183e55dd80
1 changed files with 20 additions and 4 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue