Skip to content

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

refactor(core): update model routing logic to use unified provider model checks

Steven Enamakel4d4137891762
diff --git a/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rs b/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rs
index 814edb9a9d..36121a6158 100644
--- a/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/host/budget_gate.rs
@@ -388,9 +388,9 @@ impl BudgetGate for OpenHumanBudgetGate {
/// a call, so there is no enforcement to feed.
async fn record(&self, usage: &Usage) -> Result<()> {
log::debug!(
- "[tinyagents][budget] observed usage model={} in={} out={} cached={} (ledger is \
+ "[tinyagents][budget] observed usage model={:?} in={} out={} cached={} (ledger is \
written by the event bridge)",
- model = ?self.attributed_model(),
+ self.attributed_model(),
usage.input_tokens,
usage.output_tokens,
usage.cache_read_tokens,
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
index 1ca398dcac..d048168d86 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/agent.rs
@@ -18,7 +18,6 @@ use tinyflows::error::{EngineError, Result};
use super::*;
use crate::config::Config;
-use crate::inference::provider::is_raw_passthrough_model;
/// [`AgentRunner`] backing an `agent` node's `agent_ref`. It runs the selected
/// agent kind by one of two paths, chosen by [`route_for_agent_ref`]:
@@ -163,7 +162,10 @@ pub(crate) fn route_for_agent_ref(agent_ref: &str) -> AgentRoute {
/// ids to the backend unchanged. Mirrors the per-node routing
/// [`OpenHumanLlm::complete`] applies via `agent_prompt::resolve_completion_model`.
pub(crate) fn harness_model_default_override(node_model: &str) -> String {
- if is_raw_passthrough_model(node_model) {
+ if crate::inference::provider_model::is_raw_model(
+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,
+ node_model,
+ ) {
return node_model.to_string();
}
format!(
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/llm.rs b/crates/openhuman-core/src/flows/tinyflows/caps/llm.rs
index b4e5d74b2b..aa041122ba 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/llm.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/llm.rs
@@ -14,7 +14,7 @@ use tinyflows::error::{EngineError, Result};
use super::*;
use crate::config::Config;
-use crate::inference::provider::{create_chat_model_with_model_id_in, is_raw_passthrough_model};
+use crate::inference::provider::create_chat_model_with_model_id_in;
use tinyflows::nodes::integration::agent_prompt;
use tinyinference_llm::model::ModelRequest;
@@ -108,8 +108,12 @@ impl LlmProvider for OpenHumanLlm {
.map_err(|e| EngineError::Capability(e.to_string()))?;
// `create_chat_provider` handed back the role's default model. If the node
// pinned a raw/BYOK id, forward it verbatim instead (issue #4598).
- let model =
- agent_prompt::resolve_completion_model(node_model, model, is_raw_passthrough_model);
+ let model = agent_prompt::resolve_completion_model(node_model, model, |candidate| {
+ crate::inference::provider_model::is_raw_model(
+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,
+ candidate,
+ )
+ });
let mut model_request = ModelRequest::new(
messages
diff --git a/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs b/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs
index 0f9bcdb07c..018ec2da37 100644
--- a/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/caps/ops_schema_and_structured_output_tests.rs
@@ -1,7 +1,13 @@
use super::*;
-use crate::inference::provider::is_raw_passthrough_model;
use tinyflows::nodes::integration::agent_prompt;
+fn is_raw_model(model: &str) -> bool {
+ crate::inference::provider_model::is_raw_model(
+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,
+ model,
+ )
+}
+
// ── resolve_completion_model raw/BYOK passthrough (issue #4598) ───────────
#[test]
fn resolve_completion_model_forwards_raw_byok_node_model_verbatim() {
@@ -12,7 +18,7 @@ fn resolve_completion_model_forwards_raw_byok_node_model_verbatim() {
agent_prompt::resolve_completion_model(
Some("claude-opus-4"),
"chat-v1".to_string(),
- is_raw_passthrough_model
+ is_raw_model
),
"claude-opus-4"
);
@@ -20,7 +26,7 @@ fn resolve_completion_model_forwards_raw_byok_node_model_verbatim() {
agent_prompt::resolve_completion_model(
Some("deepseek-v4-pro"),
"chat-v1".to_string(),
- is_raw_passthrough_model
+ is_raw_model
),
"deepseek-v4-pro"
);
@@ -33,7 +39,7 @@ fn resolve_completion_model_leaves_managed_tier_and_hint_node_models_untouched()
agent_prompt::resolve_completion_model(
Some("chat-v1"),
"chat-v1".to_string(),
- is_raw_passthrough_model
+ is_raw_model
),
"chat-v1"
);
@@ -41,7 +47,7 @@ fn resolve_completion_model_leaves_managed_tier_and_hint_node_models_untouched()
agent_prompt::resolve_completion_model(
Some("hint:reasoning"),
"reasoning-v1".to_string(),
- is_raw_passthrough_model
+ is_raw_model
),
"reasoning-v1"
);
@@ -49,7 +55,7 @@ fn resolve_completion_model_leaves_managed_tier_and_hint_node_models_untouched()
agent_prompt::resolve_completion_model(
Some("hint:garbage"),
"reasoning-v1".to_string(),
- is_raw_passthrough_model
+ is_raw_model
),
"reasoning-v1"
);
@@ -58,7 +64,7 @@ fn resolve_completion_model_leaves_managed_tier_and_hint_node_models_untouched()
agent_prompt::resolve_completion_model(
None,
"chat-v1".to_string(),
- is_raw_passthrough_model
+ is_raw_model
),
"chat-v1"
);
@@ -66,7 +72,7 @@ fn resolve_completion_model_leaves_managed_tier_and_hint_node_models_untouched()
agent_prompt::resolve_completion_model(
Some(" "),
"chat-v1".to_string(),
- is_raw_passthrough_model
+ is_raw_model
),
"chat-v1"
);
diff --git a/crates/openhuman-core/src/inference/provider/mod.rs b/crates/openhuman-core/src/inference/provider/mod.rs
index e8d2ed9c26..f5b3b9aa91 100644
--- a/crates/openhuman-core/src/inference/provider/mod.rs
+++ b/crates/openhuman-core/src/inference/provider/mod.rs
@@ -17,8 +17,6 @@ pub mod types;
#[allow(unused_imports)]
pub use types::{BilledUsage, ChatResponse, ProviderDelta, AGENT_TURN_MAX_OUTPUT_TOKENS};
-#[cfg(feature = "flows")]
-pub(crate) use factory::is_raw_passthrough_model;
pub use factory::{
create_chat_model_from_string, create_chat_model_from_string_with_model_id,
create_chat_model_in, create_chat_model_with_model_id_in, probe_inference_readiness,
diff --git a/crates/openhuman-core/src/web_chat/session.rs b/crates/openhuman-core/src/web_chat/session.rs
index 2c54ec0e3f..7b974ba6d2 100644
--- a/crates/openhuman-core/src/web_chat/session.rs
+++ b/crates/openhuman-core/src/web_chat/session.rs
@@ -61,7 +61,12 @@ pub(crate) fn provider_role_for_model_override(model_override: Option<&str>) ->
// A role alias (`hint:coding`) or a retired tier slug (`hint:coding`) picks
// that workload's route; a concrete model id rides the chat route.
match model_override.map(str::trim) {
- Some(value) if value.starts_with("hint:") || crate::config::is_legacy_tier_model(value) => {
+ Some(value)
+ if crate::inference::provider_model::is_abstract_model(
+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,
+ value,
+ ) =>
+ {
match crate::inference::provider_model::role_for_provider_model(
crate::inference::provider::factory::PROVIDER_OPENHUMAN,
value,
@@ -98,7 +103,12 @@ fn effective_session_config(
.default_model
.as_deref()
.map(str::trim)
- .filter(|model| crate::inference::provider::factory::is_raw_passthrough_model(model))
+ .filter(|model| {
+ crate::inference::provider_model::is_raw_model(
+ crate::inference::provider::factory::PROVIDER_OPENHUMAN,
+ model,
+ )
+ })
{
if model.starts_with("openrouter/") {
// The managed backend accepts catalog ids verbatim. This also