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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//! Agent configuration schema for tcode.
//!
//! Why: Sub-agents (and the PM itself) are defined declaratively so model,
//! prompt, and LLM parameters can evolve without code changes. As of #2897
//! Slice D, the on-disk source format is Markdown+frontmatter
//! (`.claude/agents/<name>.md`) ONLY — the original TOML loader
//! (`AgentConfig::from_toml_str`/`AgentConfig::load`) has been retired; see
//! `agents::md_loader` for the current loader and
//! `scripts/migrate-tcode-agents-toml-to-md.py` for the one-time converter a
//! project with pre-#2897 `.toml` agent files should run.
//! What: `AgentConfig` and all nested config types. These are pure data
//! structs — format-agnostic — that `agents::md_loader::project_to_agent_config`
//! populates from a composed `.md` document's frontmatter + body.
//! Test: `agent_config_default_is_empty`, `runner_kind_defaults_to_in_process`;
//! the loading path itself is covered by `agents::md_loader::tests::*`.
use ;
/// Top-level agent configuration.
///
/// Why: Declarative agent configs let operators define or override agents
/// without touching Rust code.
/// What: `agent` carries identity/role; `llm` carries model/token params;
/// `system_prompt` carries the prompt text; optional sections add capabilities.
/// Populated by `agents::md_loader::project_to_agent_config` from a composed
/// `.md` agent document.
/// Test: `agent_config_default_is_empty`; `agents::md_loader::tests::*` cover
/// the actual field-projection contract end-to-end.
/// Core identity fields for an agent.
///
/// Why: Every agent needs a stable `name` (the dispatch key) and `model`.
/// What: `name`, optional `role`, optional `model`.
/// Test: `agent_config_default_is_empty` asserts the zero-value default;
/// `agents::md_loader::tests::load_md_agent_base_case` covers real loading.
/// LLM parameters for a single agent.
///
/// Why: Each agent may need different temperature, token budget, or model. The
/// backend (OpenRouter vs. Bedrock) is no longer a boolean here — it is derived
/// from the resolved model slug by `provider::provider_for` (#1021), so a single
/// slug like `bedrock/...` selects the backend without a separate flag.
/// What: Standard LLM knobs, all optional with sensible defaults.
/// Test: `agent_config_llm_params`.
/// System prompt for an agent.
///
/// Why: Keeping the prompt in config (not source code) lets operators tune
/// agent behavior without a Rust recompile.
/// What: `content` is the raw prompt text; `append_skills` is a list of skill
/// names to inject at startup.
/// Test: `agent_config_system_prompt`.
/// Per-agent tool permissions.
///
/// Why: Restricts which tools an agent may call, preventing e.g. the
/// plan-agent from shelling out.
/// What: `allowed` is an explicit allowlist; `None` means "all registered tools".
/// Test: `ToolRegistry::dispatch_gated` tests exercise the allowlist.
/// Runner backend selection for an agent.
///
/// Why: Different agents may use different execution backends (subprocess,
/// in-process, Claude Code CLI).
/// What: `kind` selects the backend; defaults to `SubProcess`.
/// Test: `agent_config_runner_kind`.
/// Execution backend for agent invocations.
///
/// Why: Abstracts over the concrete runner selected at startup so config can
/// swap backends without code changes. As of #1029 the in-process runner is the
/// real, production default — the M1 model-comparison harness drives a delegated
/// sub-agent inside the PM's own process (cheap, observable, usage rolls up onto
/// one transcript). The subprocess and Claude-Code CLI backends are retained as
/// future variants for deployments that need process isolation.
/// What: `InProcess` is the default (drives the sub-agent's `AgentLoop` in the
/// same process — see `crate::runner::InProcessAgentRunner`); `SubProcess` spawns
/// a new process via NDJSON IPC; `ClaudeCode` wraps the `claude` CLI binary.
/// Test: `runner_kind_defaults_to_in_process`.
// ── Tests ─────────────────────────────────────────────────────────────────────