{"record":{"id":"fb9c00a33514f6c1","repo":"tinyhumansai/openhuman","slug":"sub-agent-spawn-depth-exceeded-attempted-depth-a","errorCode":null,"errorMessage":"sub-agent spawn depth exceeded: attempted depth {attempted_depth}, max {max_depth}","messagePattern":"sub-agent spawn depth exceeded: attempted depth (.+?), max (.+?)","errorType":"exception","errorClass":"SubagentRunError::SpawnDepthExceeded","httpStatus":null,"severity":"error","filePath":"src/openhuman/agent/tinyagents/mod.rs","lineNumber":961,"sourceCode":"            // path) maps to the typed `AgentError::MaxIterationsExceeded` so\n            // callers downcast it (Sentry skip) and render the canonical\n            // \"Agent exceeded maximum tool iterations\" message, matching the\n            // legacy `ErrorCheckpoint`.\n            if let tinyagents::TinyAgentsError::LimitExceeded(msg) = &e {\n                if msg.contains(\"model call\") {\n                    tracing::debug!(\n                        model,\n                        \"[tinyagents] run hit the model-call cap; mapping to MaxIterationsExceeded (not consulting error_slot) — #4457 defect B\"\n                    );\n                    return Err(anyhow::Error::new(\n                        crate::openhuman::agent::error::AgentError::MaxIterationsExceeded {\n                            max: max_iterations,\n                        },\n                    ));\n                }\n            }\n            if let Some(depth_err) = tinyagents_depth_error(&e) {\n                return Err(anyhow::Error::new(depth_err));\n            }\n            // Otherwise prefer the original typed provider error (preserves\n            // `AgentError` downcasts the caller relies on) over the harness's\n            // string wrap — this is where a genuine model/provider failure that\n            // halted the run is re-surfaced with its real classification.\n            // #4469 item 3: `into_inner` recovers a poisoned slot so a panic in\n            // one run can't cascade into a second panic here that would mask the\n            // original typed provider error.\n            if let Some(original) = error_slot\n                .lock()\n                .unwrap_or_else(std::sync::PoisonError::into_inner)\n                .take()\n            {\n                tracing::debug!(\n                    model,\n                    \"[tinyagents] re-surfacing typed provider error from error_slot as the run failure — #4457 defect B\"\n                );\n                return Err(original);","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/agent/tinyagents/mod.rs#L943-L979","documentation":"A sub-agent attempted to spawn at a nesting depth beyond the configured maximum (attempted_depth vs max_depth). This is the recursion guard that prevents unbounded agent-spawns-agent chains exhausting stack (the default 2 MiB tokio worker stack overflows on deep delegation) and cost. tinyagents reports it as LimitExceeded; the dispatcher orders cap/depth mappings ahead of the error slot so it surfaces as the depth error rather than a stale provider error, keeping classification and Sentry suppression correct.","triggerScenarios":"Thrown at src/openhuman/agent/tinyagents/mod.rs:961 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Flatten the delegation: have the parent agent do the work directly instead of spawning another nested sub-agent","Restructure the orchestration so sub-agents are siblings spawned by the orchestrator, not children of other workers","Raise max spawn depth in harness configuration only if the topology genuinely requires deeper nesting"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}