Hmbown/CodeWhale · error · anyhow::Error
Agent not found
Error message
Agent not found
What it means
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).
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.
Defensive patterns
Strategy: validation
Validate before calling
let known = engine.list_agents();
if !known.iter().any(|a| a.id == resume_from_id) {
return Err(anyhow!("resume_from {resume_from_id} not tracked in this session"));
} Try / catch
match engine.resume_chain(&resume_from_id, text) {
Err(e) if e.to_string().contains("Agent not found") => restart_chain_from_root(text),
other => other?,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Agent not found
- Agent has no continuable checkpoint to resume from…
- Agent not found in the active session
- Agent session not found
- agent should stay registered
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/1d81dadf9d106cae.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/subagent/mod.rs:6053
pub(crate) fn followup_child_for_session(
&mut self,
active_session_id: &str,
agent_ref: &str,
text: String,
) -> Result<ParentMailReceipt> {
let agent_id = self.resolve_agent_ref_for_session(active_session_id, agent_ref)?;
self.followup_child(&agent_id, text)
}
/// Follow the persisted continuation chain without treating deliberate
/// `start + resume_from` forks as continuation targets. Every hop retains
/// the original root conversation; malformed or cyclic state fails closed.
fn continuation_target(&self, agent_id: &str) -> Result<String> {
let source = self
.agents
.get(agent_id)
.ok_or_else(|| anyhow!("Agent not found"))?;
let owner = &source.owner_session_id;
let mut target = agent_id.to_string();
let mut seen = HashSet::new();
while let Some(next) = self.resume_targets.get(&target) {
if !seen.insert(target.clone()) {
return Err(anyhow!("Invalid agent continuation lineage: cycle"));
}
let successor = self
.agents
.get(next)
.ok_or_else(|| anyhow!("Agent continuation target is no longer retained"))?;
if owner.is_empty() || successor.owner_session_id != *owner {
return Err(anyhow!(
"Agent continuation target is outside the active session"
));
}
target.clone_from(next);
}View on GitHub (pinned to 433685b202)