{"record":{"id":"5847942dd5b573c7","repo":"Hmbown/CodeWhale","slug":"sub-agent-depth-limit-reached-child-depth-absolute-inherited","errorCode":null,"errorMessage":"Sub-agent depth limit reached (child depth {}, absolute inherited max {})","messagePattern":"Sub-agent depth limit reached \\(child depth (.+?), absolute inherited max (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":6908,"sourceCode":"                let remaining = source.spec.max_steps.saturating_sub(source.steps_taken);\n                if remaining == 0 {\n                    return Err(anyhow!(\n                        \"child step budget exhausted; continuation cannot reset its model-turn allowance\"\n                    ));\n                }\n                max_steps = narrow_model_steps(max_steps, remaining);\n            }\n            // A source's absolute position is part of its authority. A fork\n            // requested by root cannot turn a depth-2 leaf into a depth-1\n            // worker and thereby regain a generation of delegation.\n            runtime.spawn_depth = runtime\n                .spawn_depth\n                .max(source.spec.spawn_depth)\n                .max(source.spec.runtime_profile.spawn_depth);\n            runtime.max_spawn_depth = runtime.max_spawn_depth.min(source.spec.max_spawn_depth);\n        }\n        if runtime.spawn_depth > runtime.max_spawn_depth {\n            return Err(anyhow!(\n                \"Sub-agent depth limit reached (child depth {}, absolute inherited max {})\",\n                runtime.spawn_depth,\n                runtime.max_spawn_depth\n            ));\n        }\n        let wall_time = options\n            .wall_time\n            .unwrap_or(MAX_CHILD_WALL_TIME)\n            .min(self.wall_time.unwrap_or(DEFAULT_CHILD_WALL_TIME))\n            .min(\n                runtime\n                    .worker_profile\n                    .wall_time_secs\n                    .map(Duration::from_secs)\n                    .unwrap_or(MAX_CHILD_WALL_TIME),\n            )\n            .min(MAX_CHILD_WALL_TIME);\n        let now_ms = epoch_millis_now();","sourceCodeStart":6890,"sourceCodeEnd":6926,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L6890-L6926","documentation":"A continuation/fork inherits the source's depth authority: child depth is raised to at least the source's spec/profile spawn depth while max is lowered to the source's max. If the resulting child depth still exceeds the inherited max, spawn is refused with this message.","triggerScenarios":"Creating a continuation/fork where `runtime.spawn_depth` (max of current, source.spec.spawn_depth, source.runtime_profile.spawn_depth) exceeds `runtime.max_spawn_depth` (min of current and source.spec.max_spawn_depth).","commonSituations":"Continuing a child that itself already sits at the inherited absolute depth cap; forks of forks stacking depth; source recorded under a stricter max than the current runtime allows to be inherited.","solutions":["Perform the continued work at a shallower level — let the parent or a fresh depth-1 child take it over.","Raise `max_spawn_depth` in the source spec or `[subagents]` config if deeper nesting is intended.","Reconsider whether this continuation should be a child at all; flatten the chain."],"exampleFix":"// before\n[subagents]\nmax_spawn_depth = 1  # inherited by continuation, child depth 2 fails\n\n// after\n[subagents]\nmax_spawn_depth = 3","handlingStrategy":"validation","validationCode":"let child_depth = runtime.spawn_depth\n    .max(source.spec.spawn_depth)\n    .max(source.spec.runtime_profile.spawn_depth);\nlet inherited_max = runtime.max_spawn_depth.min(source.spec.max_spawn_depth);\nif child_depth > inherited_max { /* flatten or raise limit */ }","typeGuard":null,"tryCatchPattern":"match continue_child(source) {\n    Err(e) if e.to_string().contains(\"inherited max\") => delegate_from_parent(source.task),\n    other => other?,\n}","preventionTips":["Record and respect the source's inherited depth authority before forking","Avoid fork-of-fork chains that stack depth","Keep max_spawn_depth in specs consistent with runtime config"],"tags":["subagent","depth-limit","continuation","inheritance"],"backgroundTag":"value-out-of-range","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}