Skip to content

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

refactor(inference): simplify context window projection logic

Steven Enamakel2015d2a1b15b
diff --git a/crates/openhuman-core/src/inference/context_window.rs b/crates/openhuman-core/src/inference/context_window.rs
index 248477123f..2b7aa8794e 100644
--- a/crates/openhuman-core/src/inference/context_window.rs
+++ b/crates/openhuman-core/src/inference/context_window.rs
@@ -37,11 +37,6 @@ fn resolver() -> &'static ContextWindowResolver {
RESOLVER.get_or_init(ContextWindowResolver::new)
}
-/// The last provider-sourced window remembered for a route/model projection.
-pub(crate) fn remembered_window(provider: &str, model: &str) -> Option<u64> {
- resolver().remembered_window(provider, model)
-}
-
/// Resolves the window for `model` on the role's selected provider route.
pub(crate) async fn resolve_context_window(
role: &str,
@@ -252,9 +247,9 @@ pub(crate) fn project_context_window(
/// or usage display from borrowing a learned limit from an unrelated provider.
pub(crate) fn project_context_window_for_model(
model: &str,
- extensions: Option<&crate::core::slots::Extensions>,
+ extensions: Option<Option<&crate::core::slots::Extensions>>,
) -> ResolvedWindow {
- let route = static_route_facts(model, extensions.map(Some));
+ let route = static_route_facts(model, extensions);
resolver().project_for_route("", model, None, route)
}
diff --git a/crates/openhuman-core/src/inference/model_context.rs b/crates/openhuman-core/src/inference/model_context.rs
index c32c1b8f23..ad6b5c9358 100644
--- a/crates/openhuman-core/src/inference/model_context.rs
+++ b/crates/openhuman-core/src/inference/model_context.rs
@@ -28,7 +28,8 @@ pub(crate) fn static_context_window_for_model_in(
extensions: Option<&crate::core::slots::Extensions>,
model: &str,
) -> Option<u64> {
- crate::inference::context_window::project_context_window_for_model(model, extensions).window
+ crate::inference::context_window::project_context_window_for_model(model, Some(extensions))
+ .window
}
/// Whether the model resolved for a chat hint/agent/profile accepts image input