You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ffa432b
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/spec/07-agents.md
+38-29Lines changed: 38 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,12 @@ Agents define behavioral presets: system prompts, tool permissions, and model pa
8
8
9
9
```go
10
10
typeInfostruct {
11
-
Namestring// unique identifier
11
+
Namestring// unique identifier (registry key is filename stem; Name may differ via frontmatter)
12
12
Descriptionstring// human-readable description
13
13
ModeMode// "primary", "subagent", "all"
14
14
Nativebool// true for hardcoded agents
15
15
Hiddenbool// hidden from user lists
16
+
Disabledbool// soft-disabled; Get/List skip these
16
17
TopP *float64// LLM sampling parameter
17
18
Temperature *float64// LLM sampling parameter
18
19
Colorstring// TUI display color (hex)
@@ -38,9 +39,13 @@ type Info struct {
38
39
39
40
### Loading Order
40
41
41
-
1.**Native agents** — Hardcoded in `registerNativeAgents()` with specific permissions
42
-
2.**Bundled agents** — Loaded from `defaults/*.md` via embedded filesystem (`embed.FS`)
43
-
3.**Config overrides** — Applied from `config.Info.Agents` via `ApplyConfigOverrides()`
42
+
1.**Native agents** — Hardcoded in `registerNativeAgents()` with specific permissions (prompts from `defaults/*.txt`, except `explore` which prefers `explore.md` body)
43
+
2.**Bundled agents** — Loaded from `defaults/*.md` via embedded filesystem (`embed.FS`); skipped when a native agent already owns the name
44
+
3.**User agents** — `LoadUserAgents`: `~/.config/tinycode/agents/*.md` then `~/.config/tinycode/agent/*.md` (compat)
45
+
4.**Project agents** — `.tinycode/agent/*.md` (loaded after user; overwrites non-native)
46
+
5.**Config overrides** — Applied from `config.Info.Agents` via `ApplyConfigOverrides()`
47
+
48
+
User/project `.md` agents may replace bundled (non-native) agents. Native agents are never overwritten by directory loads.
44
49
45
50
### Native Agents
46
51
@@ -50,49 +55,49 @@ type Info struct {
50
55
|`plan`| Primary | Read-only plan mode |`plan_exit:allow`, `edit:deny`|
`explore.md` / `explore.compact.md` also live under defaults; the native `explore` agent uses the `explore.md` body as its prompt (permissions stay native). Compact peers of archived agents are disabled alongside the base agent.
84
85
85
86
## 7.3 Frontmatter Schema
86
87
87
-
Agent `.md` files use YAML frontmatter:
88
+
Agent `.md` files use YAML frontmatter. Shared parsing via `applyFrontmatter`:
The registry map key is always the filename stem. If `name` is set in frontmatter, it updates `Info.Name` only. Omitted `mode` defaults to `ModeSubagent` (not `ModeAll`).
113
+
107
114
### Permission Rules in Frontmatter
108
115
109
116
Permissions support two formats:
@@ -115,7 +122,7 @@ permission:
115
122
read: allow
116
123
```
117
124
118
-
**Pattern-specific:**
125
+
**Pattern-specific (nested maps):**
119
126
```yaml
120
127
permission:
121
128
bash:
@@ -125,23 +132,24 @@ permission:
125
132
126
133
## 7.4 Small-Model Variants
127
134
128
-
When a model's parameter count is ≤8B (detected from model name), the registry returns a **compact variant** if available:
135
+
When a model's parameter count is ≤8B (detected from model name), the registry returns a **compact variant** if available and not disabled:
result.Name = name // requested base name, not "*.compact"
136
144
result.Compact = true
137
145
return &result
138
146
}
139
147
}
140
-
// ... return standard agent
148
+
// ... return standard agent (nil if missing or Disabled)
141
149
}
142
150
```
143
151
144
-
Compact variants are agent files named `<agent>.compact.md` with simplified prompts optimized for smaller models.
152
+
Compact variants are agent files named `<agent>.compact.md` with simplified prompts optimized for smaller models.`Get` never serves disabled agents (base or compact).
145
153
146
154
## 7.5 Permission Merging
147
155
@@ -192,15 +200,15 @@ Users can modify agents via config:
Setting `disable: true`removes the agent from the registry.
203
+
Setting `disable: true`sets `Disabled` on the agent (soft disable). It does **not** remove the agent from the registry. Native agents cannot be disabled. `Get` and `List` skip disabled agents; `ListAll` includes them.
196
204
197
205
## 7.7 Default Agent Resolution
198
206
199
207
`DefaultAgent(configDefault)` resolves the default agent:
200
208
201
-
1. If `configDefault` is set in config, validate it exists and is a primary, visible agent
202
-
2. Otherwise, use `"build"`
203
-
3. Fallback: first registered non-subagent, non-hidden agent
209
+
1. If `configDefault` is set in config, validate it exists and is a primary, visible, non-disabled agent
210
+
2. Otherwise, use `"build"` if not disabled
211
+
3. Fallback: first registered non-subagent, non-hidden, non-disabled agent
204
212
205
213
## 7.8 Agent Model Override
206
214
@@ -221,12 +229,13 @@ When an agent has a `Model` set, the session manager uses that model instead of
221
229
222
230
Source: `internal/agent/loader.go`
223
231
224
-
`LoadUserAgents(configDir, projectDir)` loads user-defined agents from two directories:
Files are parsed identically to bundled agents (frontmatter + body). Agents already in the registry are **not**overwritten — bundled and native agents take precedence.
238
+
Files are parsed identically to bundled agents (frontmatter + body via `applyFrontmatter`). Non-native agents already in the registry **may be overwritten**(project wins over user over bundled). Native agents are never overwritten. Load errors are logged, not silently discarded.
230
239
231
240
Compact variants (`*.compact.md`) are loaded alongside their full counterparts.
0 commit comments