Skip to content

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

refactor(session_host): extract provider role resolution into its own module

Steven Enamakeld2939a0713dd
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
index 0ccb4bf7a6..f56ff2afe7 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs
@@ -918,47 +918,8 @@ pub(super) fn resolve_target_definition(
))
}
-/// Resolve the provider/workload role for a session build.
-///
-/// Explicit `hint:<role>` markers route to their workload; everything else
-/// (incl. the legacy `default_model` tier the bootstrap pinned) falls through
-/// to `chat` so `chat_provider` drives the user-facing turn.
-pub(crate) fn provider_role_for(default_model: Option<&str>) -> &'static str {
- match default_model.map(str::trim) {
- Some("hint:agentic") => "agentic",
- Some("hint:coding") => "coding",
- Some("hint:summarization") => "summarization",
- Some("hint:reasoning") => "reasoning",
- _ => "chat",
- }
-}
+use super::factory_resolution::{provider_role_for, resolve_target_definition};
#[cfg(test)]
#[path = "factory_provider_role_tests_tests.rs"]
mod provider_role_tests;
-
-/// Resolve the initial harness workload without constructing a session.
-/// Flow readiness shares this path so it checks the provider used at runtime.
-pub(crate) fn provider_role_for_definition(
- default_model: Option<&str>,
- target_def: Option<&crate::agent_registry::host_definition::AgentDefinition>,
-) -> &'static str {
- let master_hint = default_model
- .is_none()
- .then(|| {
- target_def.and_then(|def| {
- if def.id == "orchestrator" {
- match &def.model {
- tinyagents_definition::ModelSpec::Hint(hint) => {
- Some(format!("hint:{hint}"))
- }
- _ => None,
- }
- } else {
- None
- }
- })
- })
- .flatten();
- provider_role_for(master_hint.as_deref().or(default_model))
-}
diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory_resolution.rs b/crates/openhuman-core/src/agent/session_host/builder/factory_resolution.rs
new file mode 100644
index 0000000000..954b8237aa
--- /dev/null
+++ b/crates/openhuman-core/src/agent/session_host/builder/factory_resolution.rs
@@ -0,0 +1,46 @@
+//! Agent-definition fallback resolution and provider-role selection for session construction.
+
+use crate::agent_registry::host_definition::AgentDefinitionRegistry;
+use crate::config::Config;
+use anyhow::Result;
+
+/// Resolve the provider/workload role for a session build.
+///
+/// Explicit `hint:<role>` markers route to their workload; everything else
+/// (incl. the legacy `default_model` tier the bootstrap pinned) falls through
+/// to `chat` so `chat_provider` drives the user-facing turn.
+pub(crate) fn provider_role_for(default_model: Option<&str>) -> &'static str {
+ match default_model.map(str::trim) {
+ Some("hint:agentic") => "agentic",
+ Some("hint:coding") => "coding",
+ Some("hint:summarization") => "summarization",
+ Some("hint:reasoning") => "reasoning",
+ _ => "chat",
+ }
+}
+
+/// Resolve the initial harness workload without constructing a session.
+/// Flow readiness shares this path so it checks the provider used at runtime.
+pub(crate) fn provider_role_for_definition(
+ default_model: Option<&str>,
+ target_def: Option<&crate::agent_registry::host_definition::AgentDefinition>,
+) -> &'static str {
+ let master_hint = default_model
+ .is_none()
+ .then(|| {
+ target_def.and_then(|def| {
+ if def.id == "orchestrator" {
+ match &def.model {
+ tinyagents_definition::ModelSpec::Hint(hint) => {
+ Some(format!("hint:{hint}"))
+ }
+ _ => None,
+ }
+ } else {
+ None
+ }
+ })
+ })
+ .flatten();
+ provider_role_for(master_hint.as_deref().or(default_model))
+}
diff --git a/crates/openhuman-core/src/agent/session_host/builder/mod.rs b/crates/openhuman-core/src/agent/session_host/builder/mod.rs
index d1a460ed5b..cbecdc30bc 100644
--- a/crates/openhuman-core/src/agent/session_host/builder/mod.rs
+++ b/crates/openhuman-core/src/agent/session_host/builder/mod.rs
@@ -7,10 +7,11 @@
//! [`super::turn`]; accessors and run-helpers live in [`super::runtime`].
#[cfg(feature = "flows")]
-pub(crate) use factory::provider_role_for_definition;
+pub(crate) use factory_resolution::provider_role_for_definition;
mod builder_build;
mod factory;
+mod factory_resolution;
mod host_only;
mod host_tools;
mod iteration_cap;