{"record":{"id":"1d81dadf9d106cae","repo":"Hmbown/CodeWhale","slug":"agent-not-found","errorCode":null,"errorMessage":"Agent not found","messagePattern":"Agent not found","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":6053,"sourceCode":"\n    pub(crate) fn followup_child_for_session(\n        &mut self,\n        active_session_id: &str,\n        agent_ref: &str,\n        text: String,\n    ) -> Result<ParentMailReceipt> {\n        let agent_id = self.resolve_agent_ref_for_session(active_session_id, agent_ref)?;\n        self.followup_child(&agent_id, text)\n    }\n\n    /// Follow the persisted continuation chain without treating deliberate\n    /// `start + resume_from` forks as continuation targets. Every hop retains\n    /// the original root conversation; malformed or cyclic state fails closed.\n    fn continuation_target(&self, agent_id: &str) -> Result<String> {\n        let source = self\n            .agents\n            .get(agent_id)\n            .ok_or_else(|| anyhow!(\"Agent not found\"))?;\n        let owner = &source.owner_session_id;\n        let mut target = agent_id.to_string();\n        let mut seen = HashSet::new();\n        while let Some(next) = self.resume_targets.get(&target) {\n            if !seen.insert(target.clone()) {\n                return Err(anyhow!(\"Invalid agent continuation lineage: cycle\"));\n            }\n            let successor = self\n                .agents\n                .get(next)\n                .ok_or_else(|| anyhow!(\"Agent continuation target is no longer retained\"))?;\n            if owner.is_empty() || successor.owner_session_id != *owner {\n                return Err(anyhow!(\n                    \"Agent continuation target is outside the active session\"\n                ));\n            }\n            target.clone_from(next);\n        }","sourceCodeStart":6035,"sourceCodeEnd":6071,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/tools/subagent/mod.rs#L6035-L6071","documentation":"Thrown by `continuation_target` when the given agent id is not present in `self.agents`, so no continuation target can be computed for a `start + resume_from` fork. The method walks `resume_targets` to find the chain's fork point; with no source agent there is no lineage to walk, and it fails closed (cyclic lineages get their own error).","triggerScenarios":"Computing a continuation target (mod.rs:6053) for an `agent_id` absent from `self.agents` — resuming from an agent id that was never spawned in this session, was reaped after completion, or disappeared in a state restore that cleared the agent map.","commonSituations":"Resuming a chain using an id from a previous session or a snapshot that cleared agents; a workflow referencing an agent spawned by a different parent/session; a typo'd or stale resume_from handle.","solutions":["Use a live agent id from the current session's agent listing as `resume_from`.","If the original agent is gone, restart the chain from the root conversation or re-spawn the source agent.","Verify the resume_from id belongs to the same owner session — cross-session ids are not tracked here.","If the id should exist, check whether a recent state restore or reap policy removed it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let known = engine.list_agents();\nif !known.iter().any(|a| a.id == resume_from_id) {\n    return Err(anyhow!(\"resume_from {resume_from_id} not tracked in this session\"));\n}","typeGuard":null,"tryCatchPattern":"match engine.resume_chain(&resume_from_id, text) {\n    Err(e) if e.to_string().contains(\"Agent not found\") => restart_chain_from_root(text),\n    other => other?,\n}","preventionTips":["Only pass resume_from ids produced in the same live session.","After a state restore, re-derive resume targets from the restored listing.","Persist the full chain root so a missing intermediate agent can be re-forked from the root.","Validate resume handles against the agent listing before issuing the fork."],"tags":["rust","subagent","resume","not-found"],"backgroundTag":"entity-not-found","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}