Skip to content

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

refactor(inference): simplify model handling in agent chat

Steven Enamakelbdabc4ea3183
diff --git a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs
index 45935e821c..48035f146f 100644
--- a/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs
+++ b/crates/openhuman-core/src/inference/host_runtime/ops/agent_chat_simple.rs
@@ -26,11 +26,6 @@ pub async fn agent_chat_simple(
effective.default_temperature = temp;
}
- let default_model = effective
- .default_model
- .clone()
- .unwrap_or_else(|| crate::config::DEFAULT_MODEL.to_string());
-
let (model, resolved_model): (
std::sync::Arc<dyn tinyinference_llm::model::ChatModel<()>>,
String,
@@ -39,7 +34,7 @@ pub async fn agent_chat_simple(
providers::factory::make_openhuman_backend_model_for_thread(
"chat",
&effective,
- &default_model,
+ effective.default_model.as_deref(),
true,
thread_id.as_deref(),
&crate::security::egress::EgressLedger::none(),
@@ -56,7 +51,7 @@ pub async fn agent_chat_simple(
.map_err(|e| e.to_string())?
};
tracing::debug!(
- requested_model = %default_model,
+ requested_model = ?effective.default_model,
resolved_model = %resolved_model,
temperature = effective.default_temperature,
"[inference] agent_chat_simple invoking crate-native chat model"
@@ -66,7 +61,7 @@ pub async fn agent_chat_simple(
tinyinference_llm::model::ModelRequest::new(vec![
tinyinference_llm::message::Message::user(message.to_string()),
])
- .with_model(default_model.clone())
+ .with_model(resolved_model.clone())
.with_temperature(effective.default_temperature),
);
let response = run.await.map_err(|e| e.to_string())?.text();
diff --git a/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs b/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
index 9c5b0a05e1..e4c6beec6b 100644
--- a/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
+++ b/crates/openhuman-core/src/inference/provider/factory/managed_backend.rs
@@ -70,7 +70,7 @@ pub(super) fn managed_chat_model(
pub(crate) fn make_openhuman_backend_model_for_thread(
role: &str,
config: &Config,
- model: &str,
+ model: Option<&str>,
native_tool_calling: bool,
thread_id: Option<&str>,
egress: &EgressLedger,
@@ -80,7 +80,7 @@ pub(crate) fn make_openhuman_backend_model_for_thread(
managed_chat_model(
role,
config,
- Some(model),
+ model,
None,
native_tool_calling,
thread_id,