Skip to content

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

chore: files changed src/openhuman/agent/registry/agents/orchestrator/prompt.rs

Steven Enamakel69e5529fa87a
diff --git a/src/openhuman/agent/registry/agents/orchestrator/prompt.rs b/src/openhuman/agent/registry/agents/orchestrator/prompt.rs
index a17f4a88c4..60dfdbd84d 100644
--- a/src/openhuman/agent/registry/agents/orchestrator/prompt.rs
+++ b/src/openhuman/agent/registry/agents/orchestrator/prompt.rs
@@ -138,7 +138,11 @@ fn render_withheld_specialists(ctx: &PromptContext<'_>) -> String {
);
return String::new();
};
- let Some(definition) = registry.get(ctx.agent_id) else {
+ let Some(definition) = resolve_definition(registry, ctx.agent_id) else {
+ tracing::debug!(
+ agent = ctx.agent_id,
+ "[orchestrator-prompt] agent id does not resolve to a registry entry"
+ );
return String::new();
};
@@ -189,6 +193,41 @@ fn render_withheld_specialists(ctx: &PromptContext<'_>) -> String {
out
}
+/// The registry entry behind `agent_id`, tolerating the web channel's rename.
+///
+/// `PromptContext::agent_id` carries `Agent::agent_definition_name`, which the
+/// web channel rewrites to `"orchestrator_<short_thread>"` so each thread gets
+/// its own transcript namespace. The canonical id lives in a different field
+/// (`agent_definition_id`, whose docs say to use it for exactly this), but that
+/// one is not on `PromptContext` and adding it would mean editing all 62
+/// construction sites of a struct with no `Default`.
+///
+/// So: exact match first, then the longest registry id that `agent_id` extends
+/// at an `_` boundary. Longest wins because ids are not prefix-free —
+/// `integrations_agent` starts with no other id today, but `mcp_agent` and
+/// `mcp_setup` share a stem, and a shorter accidental match would resolve a
+/// renamed session onto the wrong agent's subagent list.
+fn resolve_definition<'r>(
+ registry: &'r AgentDefinitionRegistry,
+ agent_id: &str,
+) -> Option<&'r crate::openhuman::agent::harness::definition::AgentDefinition> {
+ if let Some(found) = registry.get(agent_id) {
+ return Some(found);
+ }
+ let best = registry
+ .list()
+ .iter()
+ .filter(|d| {
+ agent_id
+ .strip_prefix(d.id.as_str())
+ .is_some_and(|rest| rest.starts_with('_'))
+ })
+ .max_by_key(|d| d.id.len())?
+ .id
+ .clone();
+ registry.get(&best)
+}
+
/// The first sentence of `text`, or a hard-capped prefix when it has none.
///
/// `when_to_use` is written as a paragraph for the tool description; one