Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(context): use route-aware context window lookup in tests

Steven Enamakel470a8b320b0c
diff --git a/crates/openhuman-core/src/inference/context_window_tests.rs b/crates/openhuman-core/src/inference/context_window_tests.rs
index 9c0ebd723b..c0a88f18b1 100644
--- a/crates/openhuman-core/src/inference/context_window_tests.rs
+++ b/crates/openhuman-core/src/inference/context_window_tests.rs
@@ -123,9 +123,13 @@ async fn deepseek_v41_flash_uses_provider_window_not_static_128k() {
assert_eq!(resolved.window, Some(1_048_576));
assert_eq!(resolved.source, WindowSource::ProviderReported);
- // The synchronous lookup (usage meters) now reports the same window.
+ // The route-aware synchronous lookup used by the context breakdown
+ // reports the same provider-specific window.
assert_eq!(
- crate::inference::model_context::context_window_for_model(V41_FLASH),
+ crate::inference::model_context::context_window_for_route(
+ &format!("openrouter:{V41_FLASH}"),
+ V41_FLASH,
+ ),
Some(1_048_576)
);
}
diff --git a/crates/openhuman-core/src/inference/model_context.rs b/crates/openhuman-core/src/inference/model_context.rs
index 599e9e8ec4..f2aefbf1db 100644
--- a/crates/openhuman-core/src/inference/model_context.rs
+++ b/crates/openhuman-core/src/inference/model_context.rs
@@ -21,11 +21,10 @@ const TIER_FLASH_CONTEXT: u64 = 1_000_000;
/// Resolve the context window (in tokens) for a model id or OpenHuman tier alias.
///
-/// Prefers the window a turn last resolved for this model from the provider
-/// (or a config override) — see [`crate::inference::context_window`] — and
-/// otherwise falls back to [`static_context_window_for_model`]. Turns resolve
-/// through the async provider path; this synchronous form serves usage meters
-/// and the context breakdown.
+/// Returns the static model estimate. Call [`context_window_for_route`] when
+/// the provider route is known; provider-discovered values are stored per
+/// route and model. Thread usage prefers its persisted per-turn value before
+/// consulting either lookup.
///
/// Returns `None` when the model is unknown — callers should skip pre-dispatch
/// trimming rather than guess.