The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(mcp): flag subagents run_subagent will not dispatch
Nguyen Thanh Datb05dc58b0abd
diff --git a/src/openhuman/mcp/server/tools/dispatch.rs b/src/openhuman/mcp/server/tools/dispatch.rsindex a840850af4..55bec93388 100644--- a/src/openhuman/mcp/server/tools/dispatch.rs+++ b/src/openhuman/mcp/server/tools/dispatch.rs@@ -243,6 +243,31 @@ async fn core_tool_instructions() -> Result<Value, ToolCallError> {))}+/// Why `agent.run_subagent` will refuse `agent_id`, or `None` when it will run it.+///+/// One source for the refusal and for what `agent.list_subagents` publishes, so+/// the catalogue cannot advertise a delegate that dispatch turns away. The list+/// enumerates the whole registry and each entry's `when_to_use` invites the+/// model to delegate; before this, a brain reached `integrations_agent` through+/// that invitation and only learned it was unreachable from the error, after+/// spending the round trip (#5755).+pub fn mcp_dispatch_block_reason(agent_id: &str) -> Option<&'static str> {+ (agent_id == "integrations_agent").then_some(+ "agent.run_subagent does not yet support `integrations_agent`; first-level MCP support is currently limited to standalone agents that do not require toolkit binding",+ )+}++/// One bullet of the `agent.list_subagents` summary.+///+/// Pure so the "not dispatchable" marker is asserted without standing up a+/// config and an agent registry.+pub fn subagent_summary_line(id: &str, when_to_use: &str) -> String {+ match mcp_dispatch_block_reason(id) {+ Some(reason) => format!("- **{id}** (not dispatchable over MCP — {reason}): {when_to_use}"),+ None => format!("- **{id}**: {when_to_use}"),+ }+}+async fn list_subagents() -> Result<Value, ToolCallError> {let config = load_config_and_init_registry().await?;let registry = AgentDefinitionRegistry::global().ok_or_else(|| {@@ -263,6 +288,10 @@ async fn list_subagents() -> Result<Value, ToolCallError> {"tool_scope": def.tools,"subagents": def.subagents,"source": def.source,+ // Advertised alongside the invitation, not discovered from the+ // error of acting on it (#5755).+ "dispatchable_over_mcp": mcp_dispatch_block_reason(&def.id).is_none(),+ "not_dispatchable_reason": mcp_dispatch_block_reason(&def.id),})}).collect::<Vec<_>>();@@ -275,7 +304,7 @@ async fn list_subagents() -> Result<Value, ToolCallError> {.map(|def| {let id = def.get("id").and_then(Value::as_str).unwrap_or("<unknown>");let when = def.get("when_to_use").and_then(Value::as_str).unwrap_or("");- format!("- **{id}**: {when}")+ subagent_summary_line(id, when)}).collect::<Vec<_>>().join("\n")@@ -298,10 +327,8 @@ async fn run_subagent_tool(params: &Map<String, Value>) -> Result<Value, ToolCallet agent_id = required_non_empty_string(params, "agent_id")?;let prompt = required_non_empty_string(params, "prompt")?;- if agent_id == "integrations_agent" {- return Err(ToolCallError::InvalidParams(- "agent.run_subagent does not yet support `integrations_agent`; first-level MCP support is currently limited to standalone agents that do not require toolkit binding".to_string(),- ));+ if let Some(reason) = mcp_dispatch_block_reason(&agent_id) {+ return Err(ToolCallError::InvalidParams(reason.to_string()));}// Bound nested recursion per delegation chain (CC → run_subagent → CC → …).diff --git a/src/openhuman/mcp/server/tools/mod.rs b/src/openhuman/mcp/server/tools/mod.rsindex 9e375d3306..6e2b511d76 100644--- a/src/openhuman/mcp/server/tools/mod.rs+++ b/src/openhuman/mcp/server/tools/mod.rs@@ -42,6 +42,8 @@ pub use crate::openhuman::config::rpc as config_rpc;#[cfg(all(test, feature = "mcp"))]pub use crate::openhuman::tools::SEARXNG_MAX_RESULTS;#[cfg(all(test, feature = "mcp"))]+pub use dispatch::{mcp_dispatch_block_reason, subagent_summary_line};+#[cfg(all(test, feature = "mcp"))]pub use params::{build_rpc_params, slug_from};#[cfg(all(test, feature = "mcp"))]pub use serde_json::{json, Value};diff --git a/src/openhuman/mcp/server/tools_tests_part_02_tests.rs b/src/openhuman/mcp/server/tools_tests_part_02_tests.rsindex a7077c22d7..3e5a5e5d55 100644--- a/src/openhuman/mcp/server/tools_tests_part_02_tests.rs+++ b/src/openhuman/mcp/server/tools_tests_part_02_tests.rs@@ -264,3 +264,42 @@ fn slug_from_unicode_only_titles_are_unique_and_stable() {assert_eq!(slug_from("会议记录"), chinese);assert_eq!(slug_from("Протокол"), russian);}++/// `agent.list_subagents` enumerates the whole registry and every entry's+/// `when_to_use` reads as an invitation, but `agent.run_subagent` refuses+/// `integrations_agent`. A brain following the invitation could only learn that+/// from the error it got back, after paying for the round trip (#5755). These+/// pin the marker to the same predicate dispatch refuses on, so the catalogue+/// cannot drift back into advertising a delegate that will not run.+#[test]+fn integrations_agent_is_flagged_as_not_dispatchable_over_mcp() {+ let reason =+ mcp_dispatch_block_reason("integrations_agent").expect("integrations_agent is refused");+ assert!(+ reason.contains("does not yet support"),+ "the reason should say what run_subagent does, got: {reason}"+ );++ let line = subagent_summary_line("integrations_agent", "Use for Gmail, Calendar, Notion");+ assert!(+ line.contains("not dispatchable over MCP"),+ "the listing must carry the marker, got: {line}"+ );+ assert!(+ line.contains(reason),+ "the marker must carry the dispatch reason itself, got: {line}"+ );+ assert!(+ line.contains("Use for Gmail, Calendar, Notion"),+ "when_to_use must survive the marker, got: {line}"+ );+}++#[test]+fn dispatchable_subagents_are_listed_without_a_marker() {+ assert_eq!(mcp_dispatch_block_reason("tools_agent"), None);+ assert_eq!(mcp_dispatch_block_reason(""), None);++ let line = subagent_summary_line("tools_agent", "Use for shell and file work");+ assert_eq!(line, "- **tools_agent**: Use for shell and file work");+}