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(layout): split the two sub-agent tool files the layout gate rejects
M3gA-Minda8b3cf148b4a
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rsindex 669ba000cd..6a05bcfa79 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent.rs@@ -257,6 +257,7 @@ impl SpawnAsyncSubagentTool {}include!("spawn_async_subagent_execute.rs");+include!("spawn_async_subagent_args.rs");/// Format the user-facing acceptance text around a structured async sub-agent reference.///diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_args.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_args.rsnew file mode 100644index 0000000000..22c5d5d7c2--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_args.rs@@ -0,0 +1,80 @@+// Argument decoding for `spawn_async_subagent`.+//+// Textually included into `spawn_async_subagent.rs` beside+// `spawn_async_subagent_execute.rs`, so it shares that module's imports. Split+// out because the execute fragment had grown to 847 lines against the layout+// gate's pin, and this prologue is the one phase of that function that is a+// pure function of `args` — every other phase closes over the run context, the+// registry or the session store.+//+// It is also the only seam in that function whose types can all be named.+// `find_reusable` yields a `DurableSubagentSession` from a private `types`+// module whose re-export is `#[cfg(test)]`-gated, so the reuse phase — the+// larger and more tempting candidate — cannot be given a signature without+// widening another module's surface. That is left as follow-up rather than+// forced through here.++/// The `spawn_async_subagent` arguments, decoded and normalised.+///+/// Trimmed, with blank strings treated as absent, exactly as the inline code+/// did — `task_title` keeps its default and `task_key` is normalised through+/// `subagent_sessions`.+struct AsyncSpawnArgs {+ agent_id: String,+ prompt: String,+ context: Option<String>,+ model_override: Option<String>,+ toolkit_override: Option<String>,+ task_title: String,+ task_key: String,+ force_fresh: bool,+}++fn decode_async_spawn_args(args: &serde_json::Value) -> AsyncSpawnArgs {+ let agent_id = args+ .get("agent_id")+ .and_then(|v| v.as_str())+ .unwrap_or("")+ .trim()+ .to_string();+ let prompt = args+ .get("prompt")+ .and_then(|v| v.as_str())+ .unwrap_or("")+ .trim()+ .to_string();+ let context = args+ .get("context")+ .and_then(|v| v.as_str())+ .map(str::to_string);+ let model_override = args+ .get("model")+ .and_then(|v| v.as_str())+ .map(|s| s.trim().to_string())+ .filter(|s| !s.is_empty());+ let toolkit_override = args+ .get("toolkit")+ .and_then(|v| v.as_str())+ .map(|s| s.trim().to_string())+ .filter(|s| !s.is_empty());+ let task_title = args+ .get("task_title")+ .and_then(|v| v.as_str())+ .map(str::trim)+ .filter(|s| !s.is_empty())+ .unwrap_or("Background subagent")+ .to_string();+ let task_key_source = durable_task_key_source(args, &prompt, context.as_deref());+ let task_key = subagent_sessions::normalize_task_key(&task_key_source);+ let force_fresh = args.get("fresh").and_then(|v| v.as_bool()).unwrap_or(false);+ AsyncSpawnArgs {+ agent_id,+ prompt,+ context,+ model_override,+ toolkit_override,+ task_title,+ task_key,+ force_fresh,+ }+}diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rsindex 1808f626f9..c229f2082d 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs@@ -11,42 +11,16 @@ impl SpawnAsyncSubagentTool {>,>,) -> anyhow::Result<ToolResult> {- let agent_id = args- .get("agent_id")- .and_then(|v| v.as_str())- .unwrap_or("")- .trim()- .to_string();- let prompt = args- .get("prompt")- .and_then(|v| v.as_str())- .unwrap_or("")- .trim()- .to_string();- let context = args- .get("context")- .and_then(|v| v.as_str())- .map(str::to_string);- let model_override = args- .get("model")- .and_then(|v| v.as_str())- .map(|s| s.trim().to_string())- .filter(|s| !s.is_empty());- let toolkit_override = args- .get("toolkit")- .and_then(|v| v.as_str())- .map(|s| s.trim().to_string())- .filter(|s| !s.is_empty());- let task_title = args- .get("task_title")- .and_then(|v| v.as_str())- .map(str::trim)- .filter(|s| !s.is_empty())- .unwrap_or("Background subagent")- .to_string();- let task_key_source = durable_task_key_source(&args, &prompt, context.as_deref());- let task_key = subagent_sessions::normalize_task_key(&task_key_source);- let force_fresh = args.get("fresh").and_then(|v| v.as_bool()).unwrap_or(false);+ let AsyncSpawnArgs {+ agent_id,+ prompt,+ context,+ model_override,+ toolkit_override,+ task_title,+ task_key,+ force_fresh,+ } = decode_async_spawn_args(&args);if agent_id.is_empty() {return Ok(ToolResult::error(diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rsindex 8ab881cf29..ce54db6575 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent.rs@@ -108,6 +108,7 @@ impl SpawnSubagentTool {}include!("spawn_subagent_tool_impl.rs");+include!("spawn_subagent_parameters.rs");/// Trim a raw prompt down to a thread-list-friendly title.///diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_parameters.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_parameters.rsnew file mode 100644index 0000000000..aeca8db2fe--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_parameters.rs@@ -0,0 +1,80 @@+// `spawn_subagent`'s parameter schema.+//+// Textually included into `spawn_subagent.rs` beside+// `spawn_subagent_tool_impl.rs`, so it shares that module's imports. Split out+// because the impl fragment had grown to 803 lines against the layout gate's+// pin, and this is the one part of it that answers a question of its own —+// "what arguments does this tool take?" — with no dependence on the execution+// path around it. It is a pure function of the agent registry.+//+// Behaviour is unchanged: the same statements, returning the same value. The+// trait method now delegates here, because a trait impl must stay one block.++/// The `spawn_subagent` JSON schema, with `agent_id` enumerated from the live+/// registry when one is initialised.+fn spawn_subagent_parameters_schema() -> serde_json::Value {+ // Build the agent_id enum dynamically from the global registry+ // when it's been initialised. Falls back to a string-with-hint+ // when the registry hasn't been set up yet (e.g. early tests).+ let agent_ids: Vec<String> = AgentDefinitionRegistry::global()+ .map(|reg| reg.list().iter().map(|d| d.id.clone()).collect())+ .unwrap_or_default();++ let agent_id_schema = if agent_ids.is_empty() {+ json!({+ "type": "string",+ "description": "Sub-agent id (e.g. code_executor, researcher, critic)."+ })+ } else {+ json!({+ "type": "string",+ "enum": agent_ids,+ "description": "Sub-agent id from the registry."+ })+ };++ json!({+ "type": "object",+ "required": ["agent_id", "prompt"],+ "properties": {+ "agent_id": agent_id_schema,+ // Back-compat alias — older callers used `archetype`.+ "archetype": {+ "type": "string",+ "description": "Deprecated alias for `agent_id`. Use `agent_id` going forward."+ },+ "prompt": {+ "type": "string",+ "description": "Clear, specific instruction for the sub-agent. The sub-agent has no memory of the parent's conversation, so include all context the sub-agent needs to act."+ },+ "context": {+ "type": "string",+ "description": "Optional context blob from prior task results. Rendered as a `[Context]` block before the prompt."+ },+ "model": {+ "type": "string",+ "description": "Optional exact model id for this spawn only. Keeps the parent provider/routing, but pins the child agent to this model instead of the agent definition's default."+ },+ "toolkit": {+ "type": "string",+ "description": "Composio toolkit slug to scope this spawn to — e.g. `gmail`, `notion`, `slack`. REQUIRED when `agent_id = \"integrations_agent\"`. Narrows the sub-agent's visible Composio actions AND its Connected Integrations prompt section to only that toolkit's catalogue, so the sub-agent's context window only carries the platform it was asked to operate on. Must match a currently-connected integration (see the Delegation Guide)."+ },+ "dedicated_thread": {+ "type": "boolean",+ "description": "Legacy compatibility flag. Delegations now always create a persistent worker thread when parent context is available, so this flag no longer gates thread creation."+ },+ "blocking": {+ "type": "boolean",+ "description": "Explicitly run the sub-agent inline and return its final output. Defaults to false; reusable async delegation is the default."+ },+ "task_key": {+ "type": "string",+ "description": "Optional deterministic identity key for reusable async delegation. Defaults to a normalized prompt/title."+ },+ "fresh": {+ "type": "boolean",+ "description": "When true, bypass reusable subagent matching and create a fresh durable worker."+ }+ }+ })+}diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rsindex dec4a6bf37..5d96e48a5b 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs@@ -24,70 +24,7 @@ impl Tool for SpawnSubagentTool {}fn parameters_schema(&self) -> serde_json::Value {- // Build the agent_id enum dynamically from the global registry- // when it's been initialised. Falls back to a string-with-hint- // when the registry hasn't been set up yet (e.g. early tests).- let agent_ids: Vec<String> = AgentDefinitionRegistry::global()- .map(|reg| reg.list().iter().map(|d| d.id.clone()).collect())- .unwrap_or_default();-- let agent_id_schema = if agent_ids.is_empty() {- json!({- "type": "string",- "description": "Sub-agent id (e.g. code_executor, researcher, critic)."- })- } else {- json!({- "type": "string",- "enum": agent_ids,- "description": "Sub-agent id from the registry."- })- };-- json!({- "type": "object",- "required": ["agent_id", "prompt"],- "properties": {- "agent_id": agent_id_schema,- // Back-compat alias — older callers used `archetype`.- "archetype": {- "type": "string",- "description": "Deprecated alias for `agent_id`. Use `agent_id` going forward."- },- "prompt": {- "type": "string",- "description": "Clear, specific instruction for the sub-agent. The sub-agent has no memory of the parent's conversation, so include all context the sub-agent needs to act."- },- "context": {- "type": "string",- "description": "Optional context blob from prior task results. Rendered as a `[Context]` block before the prompt."- },- "model": {- "type": "string",- "description": "Optional exact model id for this spawn only. Keeps the parent provider/routing, but pins the child agent to this model instead of the agent definition's default."- },- "toolkit": {- "type": "string",- "description": "Composio toolkit slug to scope this spawn to — e.g. `gmail`, `notion`, `slack`. REQUIRED when `agent_id = \"integrations_agent\"`. Narrows the sub-agent's visible Composio actions AND its Connected Integrations prompt section to only that toolkit's catalogue, so the sub-agent's context window only carries the platform it was asked to operate on. Must match a currently-connected integration (see the Delegation Guide)."- },- "dedicated_thread": {- "type": "boolean",- "description": "Legacy compatibility flag. Delegations now always create a persistent worker thread when parent context is available, so this flag no longer gates thread creation."- },- "blocking": {- "type": "boolean",- "description": "Explicitly run the sub-agent inline and return its final output. Defaults to false; reusable async delegation is the default."- },- "task_key": {- "type": "string",- "description": "Optional deterministic identity key for reusable async delegation. Defaults to a normalized prompt/title."- },- "fresh": {- "type": "boolean",- "description": "When true, bypass reusable subagent matching and create a fresh durable worker."- }- }- })+ spawn_subagent_parameters_schema()}fn permission_level(&self) -> PermissionLevel {diff --git a/scripts/ci/check-openhuman-rust-layout.mjs b/scripts/ci/check-openhuman-rust-layout.mjsindex 91c9a95f64..e16997f08e 100644--- a/scripts/ci/check-openhuman-rust-layout.mjs+++ b/scripts/ci/check-openhuman-rust-layout.mjs@@ -18,14 +18,19 @@ const LEGACY_LIMITS = new Map([// These orchestration files crossed the general limit in the already-merged// runtime compatibility work. Pin their exact post-merge sizes so follow-up// changes cannot grow them while they are split along semantic seams.+ // 847 -> 821: the argument prologue moved to+ // `spawn_async_subagent_args.rs`. Pinned at its exact new size, so the+ // 26 lines recovered cannot be spent again. Still exempt because the rest of+ // that function's phases close over locals whose types are not nameable from+ // this module (see that fragment's header); taking it under 750 needs a+ // visibility change in `subagent_sessions`, which is follow-up, not this PR.["crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs",- 832,- ],- [- "crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs",- 796,+ 821,],+ // `spawn_subagent_tool_impl.rs` had its entry DELETED, not lowered: the+ // parameter schema moved to `spawn_subagent_parameters.rs` and the file is+ // 740 lines, under the general 750 limit, so it needs no exception at all.["crates/openhuman-core/src/agent/multimodal.rs", 772],// The session-todo integration added transcript metadata construction to// this already-exempt composition seam. Keep its allowance exact.