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

@ -91,8 +91,9 @@ struct AgentStateMsg {
/// on, resolved from that turn's assistant events. `None` before any
/// turn has completed.
resolved_model: Option<String>,
/// Effective context-window token budget for the current model.
context_window_tokens: u64,
/// The context window the API last reported, in tokens; `null` until the
/// first turn of this process completes.
context_window_tokens: Option<u64>,
/// Last-inference token usage from the most recent completed turn — the
/// current context-window occupancy. `None` until the first turn ends.
ctx_usage: Option<hive_claude::TokenUsage>,
@ -178,7 +179,7 @@ fn snapshot(bus: &Bus, login_state: &Mutex<LoginState>) -> AgentStateMsg {
turn_state,
turn_state_since: iso8601_utc(since_unix),
agent_state: observed_state(),
context_window_tokens: bus.effective_context_window(&model),
context_window_tokens: bus.api_context_window(),
inference: Effective {
model,
effort: bus.effort(),
@ -407,7 +408,7 @@ mod tests {
effort_source: Source::AgentNix,
},
resolved_model: Some("claude-sonnet-4-5-20260805".to_owned()),
context_window_tokens: 200_000,
context_window_tokens: Some(200_000),
ctx_usage: Some(usage(&serde_json::json!({
"input_tokens": 11,
"output_tokens": 22,