Watch
0
0
Fork
You've already forked hyperhive
0

hive-agent: no hard-coded context window sizes, the window is what the API reports

This commit is contained in:
damocles 2026-11-15 20:11:26 +01:00 • committed by mara
commit 1bfee54414

View file

@ -273,15 +273,18 @@ pub fn record_swarm_queue_publish_skipped(site: &'static str) {
.add(1, &[KeyValue::new("site", site)]);
}
/// Record the context window's fill at turn end: `used` tokens of `size`,
/// the two numbers the web UI's ctx% divides. No-op when OTEL isn't
/// configured, same as [`record`].
pub fn record_context(used: u64, size: u64) {
/// Record the context window's fill at turn end: `used` tokens, and the
/// window's `size` once the API has reported one (until then there is nothing
/// to divide by, so no size is recorded rather than a guessed one). No-op when
/// OTEL isn't configured, same as [`record`].
pub fn record_context(used: u64, size: Option<u64>) {
let Some(inst) = INSTRUMENTS.get_or_init(build).as_ref() else {
return;
};
inst.context_used.record(used, &[]);
inst.context_size.record(size, &[]);
if let Some(size) = size {
inst.context_size.record(size, &[]);
}
}
/// Add what an ACP agent reported spending since the last call. No-op when