1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Error type for the in-process agent runner.
//!
//! Why: The runner is library code, so per the crate convention it surfaces a
//! structured `thiserror` enum rather than `unwrap()` or bare `anyhow` strings.
//! Each variant names a distinct failure the caller (the delegate tool, the
//! orchestrator) may want to react to differently — a missing/invalid agent
//! config is the caller's mistake, whereas an `AgentLoop` failure is downstream.
//! What: `RunnerError` enumerates config-load, unknown-agent, and loop-failure
//! cases. It converts to `anyhow::Error` automatically so it slots into the
//! `AgentRunner` trait's `anyhow::Result` return type via `?`.
//! Test: `runner::tests::unknown_agent_errors` and the config-load tests assert
//! on these variants' `Display` text.
use PathBuf;
use crateAgentLoopError;
/// Failure modes of an in-process agent run.
///
/// Why: A typed error lets call sites distinguish "you asked for an agent that
/// does not exist" (recoverable, surface to the model) from "the agent's loop
/// blew up" (propagate). Bundling them in one enum keeps the runner's signature
/// a single `Result<_, RunnerError>`.
/// What: `UnknownAgent` and `ConfigLoad` cover resolving the agent's `.md`
/// config (#2897 Slice D); `Loop` wraps an `AgentLoopError` from the
/// multi-turn loop.
/// Test: `runner::tests::*` exercise `UnknownAgent` and `Loop` paths.