{"record":{"id":"21948821c2cec21c","repo":"Hmbown/CodeWhale","slug":"agent-not-found-in-the-active-session","errorCode":null,"errorMessage":"Agent not found in the active session","messagePattern":"Agent not found in the active session","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":7478,"sourceCode":"                    .worker_records\n                    .get(&agent.id)\n                    .is_none_or(|record| record.spec.parent_run_id.is_none())\n                && !delivered_ids.contains(&agent.id)\n        })\n    }\n\n    /// Resolve either a durable agent id or a model-facing session name.\n    fn resolve_agent_ref(&self, agent_ref: &str) -> Result<String> {\n        self.resolve_agent_ref_inner(agent_ref, None)\n    }\n\n    fn resolve_agent_ref_for_session(\n        &self,\n        active_session_id: &str,\n        agent_ref: &str,\n    ) -> Result<String> {\n        self.resolve_agent_ref_inner(agent_ref, Some(active_session_id))\n            .map_err(|_| anyhow!(\"Agent not found in the active session\"))\n    }\n\n    fn resolve_agent_ref_inner(\n        &self,\n        agent_ref: &str,\n        active_session_id: Option<&str>,\n    ) -> Result<String> {\n        let agent_ref = agent_ref.trim();\n        if let Some(agent) = self.agents.get(agent_ref)\n            && active_session_id\n                .is_none_or(|session_id| self.agent_is_owned_by_session(agent, session_id))\n        {\n            return Ok(agent.id.clone());\n        }\n\n        let mut matches = self\n            .agents\n            .values()","sourceCodeStart":7460,"sourceCodeEnd":7496,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L7460-L7496","documentation":"`resolve_agent_ref_for_session` resolves an agent id or session name but only accepts agents owned by the currently active session. Any resolution failure — unknown ref, or a valid ref belonging to a different session — is collapsed into this single message, so the caller cannot distinguish \"no such agent\" from \"agent exists elsewhere\".","triggerScenarios":"Calling an API that resolves refs against the active session (e.g. checkpoint continuation's resume_from_agent_id) with a ref that does not match any agent owned by the active session namespace.","commonSituations":"Passing an agent id from a previous session's ledger (workers hydrated from old ledgers are invisible to session-scoped status/peek/followup); using an id captured in a different TUI session or workspace; typos in the ref.","solutions":["Re-list the sub-agents within the current session and use one of those ids/names.","If the source agent is from a prior session, re-derive the continuation source from the current session's records, or start a fresh agent instead of continuing.","Verify the ref string (trim whitespace, full id or exact session name) before retrying."],"exampleFix":"// before\nresume_from_agent_id: Some(\"agent_a1b2c3d4\".into()) // from a prior session\n// after\nlet live = manager.list_in_session(&session_id)?;\nresume_from_agent_id: Some(live[0].id.clone())","handlingStrategy":"validation","validationCode":"const sessionAgentIds = new Set(listAgentsInSession(currentSessionId).map(a => a.id));\nif (!sessionAgentIds.has(ref)) throw new Error(`${ref} is not an agent of the active session`);","typeGuard":null,"tryCatchPattern":"match resolve_err {\n    e if e.message == \"Agent not found in the active session\" => re_list_and_pick_ref(),\n    other => propagate(other),\n}","preventionTips":["Only reference agent ids/names captured in the current session; discard ids carried across session restarts.","Re-list agents after any session/workspace switch before making continuation calls.","Trim and validate ref strings before passing them to session-scoped APIs."],"tags":["subagent","session-scope","not-found","ref-resolution"],"backgroundTag":"entity-not-found","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"}