{"record":{"id":"72daf543f3a87dfa","repo":"affaan-m/ECC","slug":"template-template-name-requires-session-slots","errorCode":null,"errorMessage":"template {template_name} requires {} session slots but only {available_slots} available","messagePattern":"template (.+?) requires (.+?) session slots but only (.+?) available","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/session/manager.rs","lineNumber":637,"sourceCode":"        .transpose()?;\n    let vars = build_template_variables(&repo_root, source_session.as_ref(), task, variables);\n    let template = cfg.resolve_orchestration_template(template_name, &vars)?;\n    let live_sessions = db\n        .list_sessions()?\n        .into_iter()\n        .filter(|session| {\n            matches!(\n                session.state,\n                SessionState::Pending\n                    | SessionState::Running\n                    | SessionState::Idle\n                    | SessionState::Stale\n            )\n        })\n        .count();\n    let available_slots = cfg.max_parallel_sessions.saturating_sub(live_sessions);\n    if template.steps.len() > available_slots {\n        anyhow::bail!(\n            \"template {template_name} requires {} session slots but only {available_slots} available\",\n            template.steps.len()\n        );\n    }\n\n    let default_profile = cfg\n        .default_agent_profile\n        .as_deref()\n        .map(|name| cfg.resolve_agent_profile(name))\n        .transpose()?;\n    let base_grouping = SessionGrouping {\n        project: Some(\n            source_session\n                .as_ref()\n                .map(|session| session.project.clone())\n                .unwrap_or_else(|| default_project_label(&repo_root)),\n        ),\n        task_group: Some(","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/session/manager.rs#L619-L655","documentation":"This error is thrown by launch_orchestration_template when a user tries to launch an orchestration template whose number of steps exceeds the configured maximum parallel sessions minus the currently live (non-stale) sessions. The library refuses to launch because it would oversubscribe the session slot budget. It is a capacity guard against launching more concurrent sessions than cfg.max_parallel_sessions allows.","triggerScenarios":"Calling launch_orchestration_template with a template whose steps.len() > available_slots, where available_slots = max_parallel_sessions - count of live sessions (states not Pending/Stale counted as live via the preceding filter).","commonSituations":"Running a large orchestration template (many steps) while many sessions are already active; max_parallel_sessions configured too low for the template size; zombie/Idle sessions counted as live so slots appear exhausted; trying to launch multiple templates concurrently and hitting the shared slot pool.","solutions":["Increase cfg.max_parallel_sessions so it covers live sessions plus the template's step count","Complete, cancel, or clean up currently live sessions to free slots before launching","Split the template into smaller templates with fewer steps and launch them sequentially","Check for stale/orphaned sessions inflating the live count and remove them"],"exampleFix":"// before\nanyhow::bail!(\n    \"template {template_name} requires {} session slots but only {available_slots} available\",\n    template.steps.len()\n);\n// after: guard before launching, or raise the limit\nlet available_slots = cfg.max_parallel_sessions.saturating_sub(live_sessions);\nif template.steps.len() > available_slots {\n    eprintln!(\"waiting for slots... need {}, have {}\", template.steps.len(), available_slots);\n    return Ok(None); // or reduce template steps\n}","handlingStrategy":"validation","validationCode":"let live = count_live_sessions(db);\nif template.steps.len() > cfg.max_parallel_sessions.saturating_sub(live) {\n    return Err(format!(\"need {} slots, have {}\", template.steps.len(), cfg.max_parallel_sessions - live));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size max_parallel_sessions >= the largest template you run plus headroom","Free live sessions before launching large templates","Monitor live session counts and alert when slots run low"],"tags":["session","capacity","orchestration","config"],"backgroundTag":"value-out-of-range","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}