Skip to content

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

refactor(inference): clean up context window routing logic

Steven Enamakel2c1395c154f2
diff --git a/crates/openhuman-core/src/inference/context_window.rs b/crates/openhuman-core/src/inference/context_window.rs
index d88ccfa9bc..248477123f 100644
--- a/crates/openhuman-core/src/inference/context_window.rs
+++ b/crates/openhuman-core/src/inference/context_window.rs
@@ -157,11 +157,9 @@ fn route_input(
});
route.discovery = match local_kind {
None => match extensions {
- Some(extensions) => {
- crate::inference::provider::factory::model_limits_request_for(
- role, provider, model, config, extensions,
- )
- }
+ Some(extensions) => crate::inference::provider::factory::model_limits_request_for(
+ role, provider, model, config, extensions,
+ ),
None => crate::inference::provider::factory::model_limits_request(
role, provider, model, config,
),
@@ -185,8 +183,7 @@ fn static_route_facts(
let provider = crate::inference::provider::factory::PROVIDER_OPENHUMAN;
let managed_default = match extensions {
Some(extensions) => crate::inference::registry::provider_default_model_for(
- extensions,
- provider,
+ extensions, provider,
)
.and_then(|managed_model| {
crate::inference::registry::provider_model_context_window_for(
@@ -199,15 +196,15 @@ fn static_route_facts(
window,
})
}),
- None => crate::inference::registry::provider_default_model(provider).and_then(
- |managed_model| {
+ None => {
+ crate::inference::registry::provider_default_model(provider).and_then(|managed_model| {
crate::inference::registry::provider_model_context_window(provider, &managed_model)
.map(|window| ManagedDefaultWindow {
model: managed_model,
window,
})
- },
- ),
+ })
+ }
};
ContextWindowRouteInput {
catalog_window: tinyagents_registry::pricing::lookup(model.trim())
diff --git a/crates/openhuman-core/src/inference/context_window_tests.rs b/crates/openhuman-core/src/inference/context_window_tests.rs
index 77a89a2409..a4acd53859 100644
--- a/crates/openhuman-core/src/inference/context_window_tests.rs
+++ b/crates/openhuman-core/src/inference/context_window_tests.rs
@@ -395,7 +395,13 @@ fn model_limits_client_uses_provider_ca_and_falls_back_to_proxy() {
);
assert_eq!(
*calls.lock().unwrap(),
- [("ca".to_string(), "test-ca-bundle".to_string(), MODEL_LIMITS_SERVICE.to_string(), 5, 3)]
+ [(
+ "ca".to_string(),
+ "test-ca-bundle".to_string(),
+ MODEL_LIMITS_SERVICE.to_string(),
+ 5,
+ 3
+ )]
);
let proxy_calls = Arc::new(StdMutex::new(Vec::new()));