Skip to content

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

fix(dispatch): always route channel turns to the orchestrator agent

Steven Enamakel6accb7d859b4
diff --git a/crates/openhuman-core/src/agent/host_agents.rs b/crates/openhuman-core/src/agent/host_agents.rs
index 1cf8550a75..0b5d0a05f1 100644
--- a/crates/openhuman-core/src/agent/host_agents.rs
+++ b/crates/openhuman-core/src/agent/host_agents.rs
@@ -62,13 +62,9 @@ impl HostAgent {
config: Config,
agent_id: &str,
) -> anyhow::Result<Self> {
- let definition = AgentDefinitionRegistry::current()
+ let definition = AgentDefinitionRegistry::load(&config.workspace_dir)
+ .ok()
.and_then(|registry| registry.get(agent_id).cloned())
- .or_else(|| {
- AgentDefinitionRegistry::load(&config.workspace_dir)
- .ok()
- .and_then(|registry| registry.get(agent_id).cloned())
- })
.ok_or_else(|| anyhow::anyhow!("agent definition `{agent_id}` is unavailable"))?;
let context = dispatch
.core()
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
index fb875e68bb..d90613bcd3 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/host_agent/mod.rs
@@ -36,7 +36,6 @@ pub(crate) use turn::{HostChannelTurn, run_host_agent_turn};
/// provider/model remain the channel's configured route.
pub(crate) async fn configured_agent(
ctx: &ChannelRuntimeContext,
- channel: &str,
route: &crate::channels::context::ChannelRouteSelection,
) -> Result<HostAgent, String> {
let dispatch = ctx.dispatch_ctx();
@@ -47,11 +46,14 @@ pub(crate) async fn configured_agent(
.await
.map_err(|error| error.to_string())?,
};
- let scoping = super::routing::resolve_target_agent(channel).await;
- let agent_id = scoping
- .target_agent_id
- .unwrap_or_else(|| "orchestrator".to_string());
- config.chat_provider = Some(route.provider.clone());
+ let agent_id = "orchestrator";
+ config.chat_provider = Some(
+ if route.provider == crate::inference::provider::INFERENCE_BACKEND_ID {
+ crate::inference::provider::INFERENCE_BACKEND_ID.to_string()
+ } else {
+ format!("{}:{}", route.provider, route.model)
+ },
+ );
config.default_model = Some(route.model.clone());
config.default_temperature = ctx.temperature;
config.multimodal_files = crate::config::MultimodalFileConfig::for_untrusted_channel_input();
diff --git a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
index b928912ad1..0b5b5307d0 100644
--- a/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
+++ b/crates/openhuman-core/src/channels/runtime/dispatch/processor/turn.rs
@@ -424,7 +424,7 @@ pub(crate) async fn process_channel_runtime_message(
let selected_host = match bound_agent {
Some(host) => Some(*host),
None if ctx.config.is_some() => {
- match host_agent::configured_agent(ctx.as_ref(), &msg.channel, &route).await {
+ match host_agent::configured_agent(ctx.as_ref(), &route).await {
Ok(host) => Some(host),
Err(error) => {
tracing::warn!(channel = %msg.channel, %error, "[dispatch] configured channel agent could not be built");