somora 2026.1001.4 → 2026.1007.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/README.md +31 -24
  2. package/config.example.yaml +37 -1
  3. package/docs/agents.md +714 -584
  4. package/docs/api.md +2327 -2546
  5. package/docs/browser.md +450 -265
  6. package/docs/builder.md +408 -282
  7. package/docs/cache-strategy.md +249 -301
  8. package/docs/compaction.md +378 -232
  9. package/docs/display.md +363 -130
  10. package/docs/dream-phases.md +598 -789
  11. package/docs/files.md +509 -333
  12. package/docs/imagegen.md +421 -302
  13. package/docs/images/somora-hero.png +0 -0
  14. package/docs/index.md +139 -174
  15. package/docs/lsp.md +142 -60
  16. package/docs/mcp.md +365 -273
  17. package/docs/memory.md +315 -356
  18. package/docs/mobile.md +283 -282
  19. package/docs/models.md +440 -197
  20. package/docs/projects.md +297 -316
  21. package/docs/realtime-voice.md +358 -234
  22. package/docs/resources.md +268 -176
  23. package/docs/sampling.md +141 -78
  24. package/docs/security.md +413 -169
  25. package/docs/sentinel.md +268 -208
  26. package/docs/setup.md +786 -1115
  27. package/docs/skills.md +415 -430
  28. package/docs/team.md +268 -143
  29. package/docs/thinking.md +415 -387
  30. package/docs/tmux.md +384 -334
  31. package/docs/tools.md +492 -109
  32. package/docs/videogen.md +319 -146
  33. package/docs/voice.md +335 -220
  34. package/docs/web.md +633 -835
  35. package/docs/wiki.md +442 -482
  36. package/package.json +2 -1
  37. package/src/attachments/store.ts +19 -1
  38. package/src/browser/session.ts +2 -2
  39. package/src/cli/auth.ts +22 -0
  40. package/src/cli/banner.ts +56 -0
  41. package/src/cli/claude-bin.ts +48 -0
  42. package/src/cli/config.ts +47 -0
  43. package/src/cli/server-call.ts +65 -0
  44. package/src/cli/setup.ts +26 -8
  45. package/src/cli/somora.ts +36 -4
  46. package/src/cli/team.ts +13 -6
  47. package/src/cli/tui/api.ts +44 -2
  48. package/src/cli/tui/app.tsx +77 -8
  49. package/src/cli/tui/commands.ts +111 -14
  50. package/src/cli/tui/header.tsx +20 -0
  51. package/src/cli/tui/stream.ts +3 -0
  52. package/src/cli/tui/turn-views.tsx +22 -0
  53. package/src/cli/tui/types.ts +14 -3
  54. package/src/compaction/summarize.ts +12 -3
  55. package/src/compaction/template.ts +15 -0
  56. package/src/compaction/types.ts +3 -0
  57. package/src/config/loader.ts +75 -10
  58. package/src/config/types.ts +59 -20
  59. package/src/dream/deep-llm.ts +83 -3
  60. package/src/dream/deep-runner.ts +8 -2
  61. package/src/dream/deep-worker.ts +1 -0
  62. package/src/dream/lucid-runner.ts +7 -3
  63. package/src/dream/lucid-types.ts +3 -0
  64. package/src/dream/rem-extract.ts +99 -69
  65. package/src/dream/worker-model.ts +31 -0
  66. package/src/engine/a2a.ts +1 -1
  67. package/src/engine/claude-cli.ts +136 -4
  68. package/src/engine/codex-cli.ts +74 -0
  69. package/src/engine/engine-meta-labels.ts +2 -0
  70. package/src/engine/openai-compatible.ts +142 -29
  71. package/src/engine/types.ts +7 -0
  72. package/src/imagegen/generate.ts +30 -5
  73. package/src/imagegen/types.ts +6 -0
  74. package/src/media/capabilities.ts +8 -0
  75. package/src/memory/inject.ts +66 -7
  76. package/src/multimodal/blocks.ts +14 -0
  77. package/src/multimodal/load.ts +21 -2
  78. package/src/multimodal/model-image.ts +127 -0
  79. package/src/persona/loader.ts +2 -2
  80. package/src/server/index.ts +275 -62
  81. package/src/server/restart-intent.ts +138 -0
  82. package/src/server/restart-reconcile.ts +6 -2
  83. package/src/server/run-turn.ts +66 -17
  84. package/src/server/session-compact.ts +138 -0
  85. package/src/server/thinking-resolve.ts +30 -0
  86. package/src/server/turn-origin-kind.ts +2 -2
  87. package/src/ssh/exec.ts +55 -22
  88. package/src/ssh/known-hosts.ts +17 -2
  89. package/src/ssh/pool.ts +7 -1
  90. package/src/storage/sessions.ts +40 -15
  91. package/src/tools/dream/tools.ts +2 -2
  92. package/src/tools/exec/tools.ts +19 -2
  93. package/src/tools/file/analyze.ts +46 -7
  94. package/src/tools/file/remote.ts +31 -10
  95. package/src/tools/file/tools.ts +86 -19
  96. package/src/tools/image/tools.ts +6 -0
  97. package/src/tools/registry.ts +14 -0
  98. package/src/types/events.ts +25 -4
  99. package/src/types/turn-origin.ts +6 -2
  100. package/web/dist/apple-touch-icon.png +0 -0
  101. package/web/dist/assets/{index-CrkkIfd9.js → index-40x__Izy.js} +168 -163
  102. package/web/dist/assets/index-40x__Izy.js.map +1 -0
  103. package/web/dist/assets/index-CZFgQRsq.css +32 -0
  104. package/web/dist/favicon-48.png +0 -0
  105. package/web/dist/favicon.ico +0 -0
  106. package/web/dist/favicon.svg +1 -8
  107. package/web/dist/index.html +6 -2
  108. package/web-mobile/dist/apple-touch-icon.png +0 -0
  109. package/web-mobile/dist/assets/index-CxILeHfe.js +88 -0
  110. package/web-mobile/dist/assets/index-CxILeHfe.js.map +1 -0
  111. package/web-mobile/dist/assets/index-Cyr13VGR.css +1 -0
  112. package/web-mobile/dist/favicon-48.png +0 -0
  113. package/web-mobile/dist/favicon.ico +0 -0
  114. package/web-mobile/dist/favicon.svg +1 -8
  115. package/web-mobile/dist/icon-192.png +0 -0
  116. package/web-mobile/dist/icon-512.png +0 -0
  117. package/web-mobile/dist/index.html +5 -3
  118. package/web-mobile/dist/manifest.webmanifest +2 -2
  119. package/web/dist/assets/index-BA5mmiV0.css +0 -32
  120. package/web/dist/assets/index-CrkkIfd9.js.map +0 -1
  121. package/web-mobile/dist/assets/index-BqKt7IMx.css +0 -1
  122. package/web-mobile/dist/assets/index-X_vRr6cd.js +0 -88
  123. package/web-mobile/dist/assets/index-X_vRr6cd.js.map +0 -1
package/docs/agents.md CHANGED
@@ -1,63 +1,34 @@
1
1
  # Agents
2
2
 
3
- An **agent** is a distinct personality somora can chat as. You can have
4
- many; each has its own memory and its own model preferences.
3
+ An agent is one assistant with its own name, character, memory and
4
+ model. You can have many. Each one is a folder of plain files under
5
+ `~/.somora/agents/`, and changes to those files apply on the next turn.
6
+
7
+ ## What you get
8
+
9
+ - **A folder is an agent.** One `AGENTS.md` is enough. No registration,
10
+ no restart.
11
+ - **Its own model and backups.** Each agent names its model and an
12
+ ordered chain of fallbacks for when that model is down.
13
+ - **Its own tools.** Hide tools, skills and remote resources per agent.
14
+ - **Agents that maintain themselves.** An agent can edit its own
15
+ persona and settings, and those of its colleagues. Every change keeps
16
+ a backup.
17
+ - **Teamwork.** Agents ask each other questions and hand tasks to
18
+ sub-agents. Whoever started work is told when it is done.
19
+ - **A window to look inside.** The web client shows the persona files,
20
+ their size against a budget, and the full prompt of the next turn.
21
+
22
+ ## Set it up
23
+
24
+ The guided way asks for a name, a description and a model, and writes
25
+ the files:
5
26
 
6
- ## Two kinds: chat agents and builders
7
-
8
- Every agent has a kind, set in `agent.yaml` when it is created and never
9
- changed afterwards. This page describes **chat agents**, the default
10
- kind. A **builder** (`kind: builder`) shares the server, the sessions,
11
- the team and the API, but is a coding harness rather than a persona:
12
-
13
- | | Chat agent | Builder |
14
- |---|---|---|
15
- | **What it is for** | Talking, thinking, remembering, orchestrating: the assistant you ask, the analyst, the coordinator | Building software in a repository: plan, edit, run, test, report |
16
- | **Its prompt** | Its persona (`AGENTS.md`, `SOUL.md`, `USER.md`), your team, the wiki map, memory recall | Harness rules, an environment block, the repository's own `AGENTS.md`/`CLAUDE.md`; no persona, no memory recall |
17
- | **Tools** | The whole programme, gated per agent | A short coding set: files, shell, task list, questions, helpers, colleagues, search |
18
- | **Turns** | A few rounds; the loop stops at 30 tool calls | Hours; hundreds of rounds, compaction mid-turn, a task list you watch |
19
- | **Memory** | Notices facts, dreams them into notes and the wiki | Reads memory, never writes it; does not dream |
20
- | **Works in** | Its workspace | The pinned project's folder, and only there |
21
- | **Window** | Chat | Chat plus a task panel: mode, plan → Go, tasks, questions, running time |
22
- | **Made how** | `somora agent create`, or an agent creates one | The same, with `kind: builder` — fixed for life |
23
-
24
- Everything below applies to chat agents; where a builder differs, the
25
- line says so, and [builder.md](builder.md) has the whole picture.
26
-
27
- ## Anatomy
28
-
29
- ```
30
- ~/.somora/agents/<name>/
31
- ├── AGENTS.md ← required. behavioural rules + identity (frontmatter)
32
- ├── SOUL.md ← optional. voice / personality
33
- ├── USER.md ← optional. what the agent knows about you
34
- ├── VOICE.md ← optional. hand-written character for spoken calls
35
- ├── agent.yaml ← optional. operator-config (model, tools, voice, REM)
36
- ├── memory/ ← per-agent memory inbox
37
- │ ├── *.md ← un-consolidated notes
38
- │ ├── memory.db (+ -wal, -shm) ← derived index
39
- │ ├── .deep-skip-cache.json ← Deep's hash-cache for skipped files
40
- │ └── .dreams/ ← REM extraction findings awaiting review
41
- │ └── processed/ ← resolved findings (audit trail)
42
- └── sessions/ ← chat history (jsonl + meta json per session)
43
- ├── main.jsonl
44
- └── 20260501-143022_some-slug.jsonl
27
+ ```bash
28
+ somora setup agent
45
29
  ```
46
30
 
47
- The memory directory is the agent's **inbox** — short-term, volatile.
48
- Deep periodically promotes content to the shared wiki and deletes the
49
- source. See [memory.md](memory.md) and [wiki.md](wiki.md).
50
-
51
- What the agent knows about its **colleagues** — who reports to whom,
52
- who to involve for what — does not live in the persona. It is rendered
53
- into the prompt from `~/.somora/team.yaml`, one file for the whole
54
- install; see [team.md](team.md). Keep `AGENTS.md` to the agent's own
55
- behaviour and lane.
56
-
57
- ## Creating a new agent
58
-
59
- The minimum is an agent directory with an `AGENTS.md`. Everything else is
60
- optional.
31
+ By hand, create a folder with an `AGENTS.md`:
61
32
 
62
33
  ```bash
63
34
  mkdir -p ~/.somora/agents/<your-agent>
@@ -69,195 +40,127 @@ icon: 🌼
69
40
  ---
70
41
 
71
42
  - Be precise. Quote sources when you have them.
72
- - Don't speculate beyond what's in your memory or the conversation.
73
- - You are who the operator configured you as — stick to the
74
- description above and the SOUL.md voice.
43
+ - Do not speculate beyond your memory and the conversation.
75
44
  EOF
45
+ echo "model: <alias>" > ~/.somora/agents/<your-agent>/agent.yaml
76
46
  ```
77
47
 
78
- The next `/agents` call from the CLI lists the new agent — no server
79
- restart needed.
48
+ The agent appears in the next agent list (`/agents` in the TUI, the dock
49
+ in the web client). An agent needs a `model`: without one its turns fail
50
+ with an error that lists the configured models.
80
51
 
81
- ### Identity goes in AGENTS.md frontmatter
52
+ Folder names may contain letters, digits, `_`, `-` and `.`, and must not
53
+ start with a dot (`^[A-Za-z0-9_-][A-Za-z0-9_.-]*$`). Lowercase is the
54
+ convention. `somora setup agent` is stricter: lowercase letters, digits
55
+ and dashes, starting with a letter.
82
56
 
83
- ```yaml
84
- ---
85
- name: <your-agent> # must match the directory name
86
- description: ... # one-line — shown by `/agents`
87
- icon: 🌼 # optional emoji shown in CLI prompts and listings
88
- color: "#5cf2d6" # optional hex display colour for the web client's agent tint
89
- role: Researcher # optional short role tag shown under the name in the web dock
90
- ---
91
- ```
57
+ On a fresh install with no agents, somora creates one named `default`.
58
+ Rename or replace it.
92
59
 
93
- ### Operator config goes in agent.yaml
60
+ ## Chat agents and builders
94
61
 
95
- ```yaml
96
- # ~/.somora/agents/<your-agent>/agent.yaml
97
- model: opus # alias OR provider/modelId
98
- fallback: gpt55 # used when primary fails before producing any output
99
- # (visible: ⇄ chip on that turn + notice in the web UI)
100
- # fallback: [deep4flash, orhaiku] # or an ordered chain — each is tried in
101
- # turn when the previous one died before its first
102
- # output or tool call. Put at least one entry on a
103
- # different host/provider than the primary: two
104
- # models on the same GPU box go down together.
105
- # A model that was unreachable is remembered as such
106
- # (config `fallback.retryUnavailableMinutes`, default
107
- # 60): the next turns start on the working backup
108
- # right away instead of knocking on the dead primary
109
- # again, still with the fallback chip on the turn
110
- # (its reason then reads "not tried — marked
111
- # unavailable since …"). After the hour the primary
112
- # is tried once more; a success drops the note.
113
- #
114
- # One exception to "before producing any output": some providers stream
115
- # their refusal AS assistant text and only then report the error — a
116
- # monthly quota notice is the common case. The engine adapter marks
117
- # those, and the chain still runs, because such text is not an answer.
118
- # A turn that already called a tool is never repeated on another model:
119
- # the side effects have happened.
120
-
121
- # Optional: cross-engine thinking depth (off|low|medium|high)
122
- # Per-session override via /thinking <level>. Only applies to models with
123
- # the `reasoning` capability — see thinking.md.
124
- thinking: medium
125
-
126
- # Optional: the kind of agent — chat (default) or builder. Fixed at
127
- # creation. A builder is a coding harness: harness rules instead of
128
- # SOUL/USER prose, a short coding tool set, no memory recall block, long
129
- # turns, a task panel in the web. See builder.md.
130
- kind: chat
131
-
132
- # Optional: per-agent loop caps for the openai-compatible engine
133
- # (override the server's agentLoop). Builders default to 500 rounds,
134
- # 2000 tool calls and 8 hours per turn; chat agents inherit the server
135
- # config unless set here.
136
- agentLoop:
137
- maxRounds: 50
138
- maxToolCallsPerTurn: 200
139
- maxTurnMs: 3600000
62
+ Every agent has a kind, set as `kind` in `agent.yaml` when it is created
63
+ and not changed afterwards. This page describes chat agents, the
64
+ default. A builder (`kind: builder`) is a coding harness and has
65
+ [its own page](builder.md).
140
66
 
141
- # Optional: steering default for the web client. true = a message typed
142
- # while a turn is running is handed INTO that turn before its next step
143
- # (the model reads it between two tool calls); false (default) = it waits
144
- # in the session queue and becomes its own turn. The steer / queue
145
- # toggle next to Send flips it per message either way. Works on the openai-compatible,
146
- # claude-cli and codex-cli engines; other engines always queue. See the
147
- # `steer` field of POST /chat/send in api.md.
148
- steering: false
67
+ | | Chat agent | Builder |
68
+ |---|---|---|
69
+ | **What it is for** | Talking, thinking, remembering, coordinating | Building software in a repository: plan, edit, run, test, report |
70
+ | **Its prompt** | Its persona files, your team, the wiki map, memory recall | Harness rules, an environment block, the repository's own `AGENTS.md` or `CLAUDE.md`. No persona prose, no memory recall |
71
+ | **Tools** | Everything configured, minus what you hide | A short coding set, plus what you allow |
72
+ | **Skills** | All, minus what you hide | None, plus what you allow |
73
+ | **Turn limits** | The server's `agentLoop` values: 8 rounds, 30 tool calls | 500 rounds, 2000 tool calls, 8 hours |
74
+ | **Memory** | Notices facts, dreams them into notes and the wiki | Reads memory, never writes it, does not dream |
75
+ | **Works in** | Its workspace | The pinned project's folder |
76
+ | **Window** | Chat | Chat plus a task panel |
149
77
 
150
- # Optional: sampling defaults for openai-compatible models (temperature,
151
- # top_p, top_k, …). Override the model's own defaults per key; per-session
152
- # via /sampling and /temp. Dormant on claude-cli / codex-cli — see sampling.md.
153
- sampling:
154
- temperature: 1.0
155
- top_p: 0.95
78
+ ## The agent folder
156
79
 
157
- # Optional: per-agent workspace override. Default cwd for the file_* tools.
158
- # Falls back to config.workspace.default (~/somoraworkspace) when unset.
159
- workspace:
160
- path: ~/<your-agent>-workspace
80
+ ```
81
+ ~/.somora/agents/<name>/
82
+ ├── AGENTS.md ← required: identity (frontmatter) and behaviour rules
83
+ ├── SOUL.md ← optional: voice and character
84
+ ├── USER.md ← optional: what the agent knows about you
85
+ ├── VOICE.md ← optional: character for spoken calls
86
+ ├── agent.yaml ← optional: model, tools, voice, REM
87
+ ├── *.bak-<timestamp> ← backups of the five files above
88
+ ├── memory.db (+ -wal, -shm) ← search index of this agent's notes
89
+ ├── memory/ ← the agent's notes (its inbox)
90
+ │ └── .dreams/ ← REM findings
91
+ └── sessions/ ← chat history, two files per session
92
+ ├── main.jsonl
93
+ ├── main.meta.json
94
+ └── 20260501-143022_some-topic.jsonl
95
+ ```
161
96
 
162
- # Optional: hide remote resources from this agent. By default every
163
- # resource defined in config.yaml is visible. See resources.md.
164
- resources:
165
- deny: ['production-db']
97
+ The memory folder is short-term. The Deep phase moves lasting knowledge
98
+ into the shared wiki and removes the note.
166
99
 
167
- # Optional: per-agent tool visibility — uniform for built-in and
168
- # external MCP tools. Patterns: exact name, toolset:<tag>, trailing-*
169
- # glob. deny beats allow; no section = agent sees everything. See mcp.md.
170
- # Denying a tool removes it from the model's tool list, which is real
171
- # context saved: the full built-in surface costs roughly 13k tokens per
172
- # turn. Only tools whose configuration exists are offered in the first
173
- # place — the web Abilities window lists exactly those, so a switch there
174
- # always changes something.
175
- tools:
176
- deny: ['toolset:exec', 'mcp__parallel__*']
177
- allow: []
100
+ ## Persona files
178
101
 
179
- # Optional: per-agent skill visibility, same shape and semantics as
180
- # tools: (deny beats allow, empty allow = all). The Abilities window
181
- # writes exact-name denies here; a plain list (`skills: [a, b]`) is
182
- # also accepted as an allow-list. See skills.md.
183
- skills:
184
- deny: ['instagram-downloader']
102
+ | File | In the prompt | What goes in it |
103
+ |---|---|---|
104
+ | `SOUL.md` | first | Voice and character. "I speak in short sentences. I have dry humour." |
105
+ | `AGENTS.md` | second, under `# Behaviour` | Behaviour rules. "Reply concisely." "Use tools when asked." |
106
+ | `USER.md` | third, under `# About the user` | Static context about you. "The user is Nina Muster. Two cats." |
107
+ | `VOICE.md` | no, only in realtime calls | A hand-written spoken character. It replaces the one derived from the other files. The rules that keep a call honest always stay. |
108
+ | `agent.yaml` | no | Settings, see [Settings](#settings). |
185
109
 
186
- # Optional: whether this agent looks at the images it generates.
187
- # `never` (default) returns path + metadata only; `always` also feeds the
188
- # image back into the agent's context so it can judge the result and
189
- # re-prompt on its own — roughly 2k tokens per image. Not a lock: the
190
- # agent can still set `return_image` per call.
191
- imageReview: never # never | always
110
+ The files are read again on every turn. An edit applies to the next
111
+ message, without a restart.
192
112
 
193
- # Optional: this agent's voice, for realtime calls (realtime-voice.md).
194
- # Only what SPEAKING needs — who the agent is comes from its persona
195
- # files, so there is no second character to maintain. Without this block
196
- # the agent cannot be called and does not appear in the voice picker.
197
- # A hand-written character can live in VOICE.md next to AGENTS.md; it
198
- # replaces the derived one, while the rules that keep a call honest stay.
199
- voice:
200
- enabled: true
201
- voice: ash # alloy ash ballad coral echo sage shimmer verse marin cedar
202
- language: de
203
- style: "dry, direct, no small talk"
204
- consultPolicy: always # auto | substantive | always
205
- maxSpokenSentences: 4
113
+ What an agent knows about its colleagues does not belong in the
114
+ persona. It comes from `~/.somora/team.yaml`, one file for the whole
115
+ install. Keep `AGENTS.md` to the agent's own behaviour.
206
116
 
207
- # Optional: REM phase (per-agent session→memory extraction)
208
- rem:
209
- enabled: true
210
- model: gemma4big # required when enabled — never inherits the chat model
211
- # fallback: deep4pro # optional backup worker, used only when `model`
212
- # is unreachable (connection refused, 5xx, timeout)
213
- # fallback: [glm, deep41flash] # or an ordered chain, tried in turn
214
- idleMinutes: 30 # auto-trigger after N min idle
215
- chunkTokens: 50000 # range-split for very long sessions
216
- chunkTimeoutMs: 600000 # 10 min/chunk; gemma-friendly
217
- participate_in_wiki: true # default true; false = REM only, never Deep
218
- # thinking: low # optional reasoning depth (off|low|medium|high) for
219
- # the REM worker; applied only when that model has
220
- # the `reasoning` capability
117
+ ### Identity in the AGENTS.md frontmatter
118
+
119
+ ```yaml
120
+ ---
121
+ name: <your-agent>
122
+ description: Engineering-minded research assistant
123
+ icon: 🌼
124
+ color: "#5cf2d6"
125
+ role: Researcher
126
+ ---
221
127
  ```
222
128
 
223
- REM is the per-agent dream phase that watches sessions and proposes
224
- memory updates with your approval. The platform-wide phases (Deep,
225
- Lucid) are configured in `~/.somora/config.yaml.wiki.deep / .lucid` —
226
- not per-agent. See [dream-phases.md](dream-phases.md).
227
-
228
- `participate_in_wiki: false` opts a single agent's memory inbox out
229
- of the Deep promote-to-wiki pipeline. REM still runs (the agent still
230
- gets memory findings), Deep just won't see this agent's inbox. Useful
231
- for sandbox/scratch agents you don't want contributing to the shared
232
- wiki.
233
-
234
- The split between `AGENTS.md` (identity + behavioural rules, agent-editable)
235
- and `agent.yaml` (operator config) is intentional but not enforced as a
236
- hard limit — the agent **can** edit `agent.yaml` via the `file_*` tools,
237
- the path-blacklist allows it. The convention is: persona-content evolves
238
- in the .md files, operator-config evolves in .yaml. Agents can self-edit
239
- both.
240
-
241
- ### Seeing and editing the persona without a terminal
242
-
243
- `/web` → right-click the agent tile → **Configure…** opens the Agent
244
- window: the three persona files as editors, `agent.yaml` read-only, a
245
- budget strip (persona total, team block, full prompt, tool schemas —
246
- characters and estimated tokens against `promptBudgets` in config.yaml)
247
- and a *Full prompt* tab with the system prompt exactly as the next turn
248
- would send it. Saves are refused when the agent changed the file in the
249
- meantime, and every save keeps a backup. See [web.md](web.md).
250
-
251
- ### Self-edit and cross-agent edit
252
-
253
- Each agent gets a small self-pointer block prepended to its system prompt
254
- at every turn. It tells the agent its name, where its persona files
255
- live, the workspace path, the global config location, which remote
256
- resources are configured, and the convention for referencing local
257
- files in chat replies (markdown links carrying the bare absolute path
258
- like `[label](/home/.../file.md)` — those route to a FileView window
259
- in the web client; wrapped URLs do not). This means the agent can run
260
- e.g.:
129
+ | Key | Meaning |
130
+ |---|---|
131
+ | `name` | Must equal the folder name. The folder name is what counts. The web editor refuses a save where the two differ. |
132
+ | `description` | One line, shown in agent lists. |
133
+ | `icon` | Emoji shown in the TUI and in listings. |
134
+ | `color` | Hex colour for the agent's tint in the web client. Without it the client picks one. |
135
+ | `role` | Short role tag under the name in the web dock. |
136
+
137
+ All keys are optional. A frontmatter that is not valid YAML does not
138
+ break the agent: the whole file is then used as the behaviour text.
139
+
140
+ ### What the prompt is made of
141
+
142
+ The system prompt of a chat agent has these parts, in this order:
143
+
144
+ | Part | Content |
145
+ |---|---|
146
+ | Self-pointer | The agent's name, the paths of its persona files and `agent.yaml`, its workspace, the path of `config.yaml`, the visible remote resources, and how to link local files and show images in a reply. |
147
+ | Persona | `SOUL.md`, `AGENTS.md`, `USER.md`. |
148
+ | Team block | Rendered from `team.yaml`. |
149
+ | Tool reminder | A short constant text, when the agent has tools. |
150
+ | Wiki overview | A map of the shared wiki, fixed when the session starts. |
151
+ | Skills | The skills this agent may use. |
152
+ | This session | The session's name. |
153
+ | Project | The project pinned to the session. |
154
+
155
+ Memory recall is not part of the system prompt. It travels with each
156
+ message.
157
+
158
+ A local file is linked in a reply with its bare absolute path,
159
+ `[label](/home/.../file.md)`. The web client opens such a link in a file
160
+ window.
161
+
162
+ Because of the self-pointer, an agent knows where its files are. It can
163
+ change them without you dictating paths:
261
164
 
262
165
  ```
263
166
  file_write({ path: "~/.somora/agents/<your-agent>/USER.md", content: "...", mode: "overwrite" })
@@ -265,274 +168,234 @@ file_read({ path: "~/.somora/agents/<your-agent>/agent.yaml" })
265
168
  file_patch({ path: "~/.somora/config.yaml", old_string: "...", new_string: "..." })
266
169
  ```
267
170
 
268
- …to update its own state without you having to dictate paths.
171
+ To learn how somora works, agents read these docs with
172
+ `somora_docs_list` and `somora_docs_read`.
173
+
174
+ ## Agents edit themselves and each other
175
+
176
+ An agent may edit its own persona files and `agent.yaml`, and those of
177
+ any other agent. This is intended: agents shape each other. The
178
+ convention is that character and rules evolve in the `.md` files and
179
+ settings in `agent.yaml`.
180
+
181
+ Two protections apply:
182
+
183
+ - **A backup first.** Every `file_write` or `file_patch` on `AGENTS.md`,
184
+ `SOUL.md`, `USER.md`, `VOICE.md` or `agent.yaml` first writes
185
+ `<file>.bak-<timestamp>`. The last five are kept. The web editor does
186
+ the same.
187
+ - **Sessions are closed.** No agent can write into any `sessions/`
188
+ folder. The conversation logs belong to somora.
189
+
190
+ > **Warning:** A mistake in `agent.yaml` does not stop the agent, it
191
+ > silently resets it. When the file fails validation, the whole file is
192
+ > ignored for that turn, including `model`. See
193
+ > [Troubleshooting](#troubleshooting).
194
+
195
+ ## The Agent window
196
+
197
+ In the web client (`/web`), right-click the agent tile and choose
198
+ **Configure…**.
199
+
200
+ - **Budget strip.** Four meters in characters and estimated tokens:
201
+ the persona files together, the team block, the full prompt, and the
202
+ tool schemas. The first two are measured against `promptBudgets`.
203
+ - **Persona editors.** `AGENTS.md`, `SOUL.md` and `USER.md`, each with
204
+ its own counter. A save is refused when the agent changed the file in
205
+ the meantime, and every save keeps a backup.
206
+ - **agent.yaml.** Read-only here.
207
+ - **Full prompt.** The system prompt exactly as the next turn of a
208
+ session would send it, split into its parts.
209
+ - **Voice prompt.** What the voice is told in a call. Only for agents
210
+ with a `voice` block.
211
+
212
+ Tools and skills are switched per agent in the Abilities window. It
213
+ writes exact-name entries into `tools.deny` and `skills.deny`.
214
+
215
+ ## Sessions
216
+
217
+ Each agent has any number of sessions. `main` always exists and cannot
218
+ be deleted. In the TUI:
219
+
220
+ | Command | What it does |
221
+ |---|---|
222
+ | `/agents` | Lists all agents. |
223
+ | `/agent <name> [session]` | Switches to an agent, into `main` or the named session. |
224
+ | `/sessions` | Lists the current agent's sessions. |
225
+ | `/session <slug-or-id>` | Switches to a session. |
226
+ | `/new <slug>` | Creates a session and switches to it. |
227
+ | `/main` | Back to the main session. |
228
+ | `/reset YES` | Archives the current session and starts it fresh. The archive can be resumed with `/session <id>`. |
229
+ | `/model` | Shows the model in use. |
230
+ | `/model <alias>` | Uses that model for this session only. |
231
+ | `/model default` | Drops the override. |
232
+ | `/models` | Lists every configured model with its alias. |
233
+ | `/export [json\|markdown] [path]` | Writes the session to a file. Default: Markdown to `./<agent>-<session>.md`. |
234
+
235
+ A model override is stored with the session and survives a restart.
236
+
237
+ The Markdown export is a readable transcript with tool calls as fenced
238
+ blocks and task lists as checkboxes. The JSON export is the session
239
+ file itself, for backups or for moving a conversation to another host.
240
+ In the web client both are icons on each row of the Sessions tool.
269
241
 
270
- **Cross-agent editing is intentionally allowed.** One agent can rewrite
271
- another's `AGENTS.md`, adjust their `agent.yaml`, or add notes to
272
- their memory. Agents shape each other in this design, not just
273
- themselves. The only files in `~/.somora/agents/<*>/` that stay
274
- off-limits are the `sessions/` dirs (append-only conversation logs
275
- managed by somora's storage layer). See `files.md` for the full
276
- write blacklist.
242
+ ## Talking to another agent
277
243
 
278
- To learn more about somora's own architecture, agents can call
279
- `somora_docs_list` and `somora_docs_read` — those tools serve the
280
- contents of this `docs/` directory.
244
+ Agents talk to each other with `agent_ask`. The message lands in the
245
+ target's real session as a user message. The target answers with its
246
+ full memory, persona and history, and the exchange stays visible there.
281
247
 
282
- ### Persona in three files
248
+ ```
249
+ agent_ask({ agent: "<other-agent>", message: "…" })
250
+ agent_ask({ agent: "<other-agent>", session: "project-a", create_session: true, model: "<alias>", message: "…" })
251
+ agent_ask({ agent: "<other-agent>", message: "…", images: ["/abs/path.png"], timeout_ms: 120000 })
252
+ ```
283
253
 
284
- | File | Role |
285
- | ---------- | --------------------------------------------------------------------- |
286
- | `AGENTS.md` | Behavioural rules. "Reply concisely." "Use tools when asked, don't preface." |
287
- | `SOUL.md` | Voice / character. "I speak in short sentences. I have dry humour." |
288
- | `VOICE.md` | Optional, and only for realtime calls: the spoken character, replacing the one derived from the files above. The rules that keep a call honest (ask before answering anything factual, never invent, never refuse work on your own authority) always stay. See [realtime-voice.md](realtime-voice.md). |
289
- | `USER.md` | Static context about you. "User is Maria. Lives in Berlin. Two cats." |
254
+ The target sees the header `[Message from agent <name>, session <slug>]`
255
+ in front of the message. The header is a frame around the turn. The
256
+ stored text is the message itself, so the target's memory is built from
257
+ the message alone.
290
258
 
291
- All three are concatenated into the system prompt. Edit them in place; the
292
- loader re-reads on every turn — no restart needed.
259
+ This is request and response, not a message bus. An agent that received
260
+ a question answers by finishing its turn, never by calling `agent_ask`
261
+ back. An agent cannot ask itself: that is what `spawn_subagent` is for.
293
262
 
294
- ### Naming rules
263
+ ### Parameters
295
264
 
296
- Agent directory names must match `^[A-Za-z0-9_-][A-Za-z0-9_.-]*$`. No
297
- spaces, no slashes. Lowercase is the convention.
265
+ | Parameter | Meaning |
266
+ |---|---|
267
+ | `agent`, `message` | The target and the text. |
268
+ | `session` | The target session. Without it, a reply to the agent that wrote to you (or to your spawning parent) goes back to the session that message came from. Anything else goes to the target's `main`. An unknown name is an error that lists the target's sessions. |
269
+ | `create_session` | `true` creates the named session on the target when it is missing. Not for `main`, ids or `sub-…` sessions. |
270
+ | `model` | Pins an alias or `provider/id` on the session this call creates. On an existing session it is ignored and `session_note` says so. Use `session_model` to change an existing session. |
271
+ | `images` | Absolute paths. A target with vision sees the pictures. One without gets the vision worker's description. |
272
+ | `wait` | `true` (default) blocks until the reply. `false` hands the message over and returns `pending` at once. |
273
+ | `timeout_ms` | How long to wait. Default `agentLoop.longTaskDefaultTimeoutMs` (5 minutes), capped at `agentLoop.longTaskMaxTimeoutMs` (30 minutes). |
298
274
 
299
- ## Switching agents and sessions
275
+ Use `wait: true` when you need the answer to go on with this turn, and
276
+ `wait: false` for a job that may take its time. The call waits in the
277
+ target session's queue in arrival order, like a typed message.
300
278
 
301
- ```
302
- /agents — list all configured agents
303
- /agent <name> — switch to <name>, drop into its main session
304
- /agent <name> some-topic — switch to <name>, session named "some-topic"
305
-
306
- /sessions — list sessions of the current agent
307
- /session some-topic — switch to that session (newest match)
308
- /new daily-2026-05-02 — create + switch to a new session
309
- /main — back to the agent's main session
279
+ A session created this way tells the target so, beside its first
280
+ message:
281
+
282
+ ```text
283
+ [Your session '<slug>' was just created by <agent> for this conversation; it runs on model <model>.]
310
284
  ```
311
285
 
312
- `main` is a magic name — every agent always has one, you can't delete it.
313
- Use `/reset YES` to archive the current main and start fresh while keeping
314
- the old content as an archived session you can resume any time.
286
+ ### Result states
315
287
 
316
- ## Exporting a session
288
+ | `state` | What it carries | Meaning |
289
+ |---|---|---|
290
+ | `done` | `response`, `ms`, `usage`, `call_id`, `target_agent`, `target_session`, `routing_reason` | The target answered. |
291
+ | `pending` | `call_id`, `hint` | The target is still queued or running, or the call used `wait: false`. The target keeps working and the message is never sent again. |
292
+ | `failed` | `error`, `hint` | The target's turn failed (a model or engine error, or `stopped by the user`), or a person took the call out of the queue (`removed from the queue by the user before it started`). Do not retry on your own. |
317
293
 
318
- ```
319
- /export — write current session as Markdown to ./<agent>-<session>.md
320
- /export markdown [path] — same, optionally pick a target path
321
- /export json [path] — write raw JSONL (full fidelity) to <path or default>
322
- ```
294
+ `routing_reason` is `explicit`, `reply_to_origin` or `default_main`.
295
+ These fields appear when they apply: `session_inferred`,
296
+ `session_created`, `session_model`, `session_note`, and `routing_note`.
297
+ The last one warns that the message went to the target's `main` although
298
+ the caller works in another session, so the target may lack the context.
323
299
 
324
- Markdown is the default — a readable transcript with user/assistant
325
- turns, fenced tool-call blocks, and engine plan/todo items rendered as
326
- GitHub task lists. JSON is the canonical source (byte-identical to the
327
- on-disk JSONL); use it for backups or moving a conversation to another
328
- somora host.
300
+ ### Fetching a pending answer
329
301
 
330
- In the web client the same export lives in the Sessions tool: each row
331
- has a file-text icon (Markdown) and a file-json icon (JSONL) that
332
- trigger a browser download.
302
+ `agent_ask_result({ call_id })` returns `done` with the reply, `failed`
303
+ with the error, or `pending` with `phase` `queued` or `running`.
304
+ `wait_until_done: true` blocks on the server until the call finishes or
305
+ `timeout_ms` passes, which is cheaper than polling. After a server
306
+ restart, pass `agent` and `session` of the original call: the answer is
307
+ then read from the target's session.
333
308
 
334
- ## Per-session model overrides
309
+ ### The wake
335
310
 
336
- Each agent has a default model from `agent.yaml`. You can override per
337
- session:
311
+ An asker that stopped waiting, or never waited, does not have to poll.
312
+ When the answer lands, the asker is woken in the session it asked from:
338
313
 
339
- ```
340
- /model — show what's effectively used now
341
- /model gemma — use gemma for this session only
342
- /model default — drop the override, fall back to agent default
343
- /models — list every configured model with its alias
314
+ ```text
315
+ [agent answer] <other-agent> has answered the question you sent to session 'main' — you had stopped waiting for it. It begins: "…"
344
316
  ```
345
317
 
346
- Overrides are stored in the session's meta-file and survive across server
347
- restarts.
318
+ The turn tells the agent to read the whole answer with
319
+ `agent_ask_result({ call_id })` and then do what depended on it. A
320
+ failed call, and one a person removed from the queue, wake the asker the
321
+ same way.
348
322
 
349
- ## Talking to another agent
323
+ The wake waits `agentLoop.wakeGraceMs` (3 seconds). Reading the result
324
+ inside that time cancels it. An asker still waiting gets none. The same
325
+ mechanism brings back a finished background sub-agent and a rendered
326
+ video.
350
327
 
351
- Agents talk to each other with `agent_ask`. The message lands in the
352
- target's **real** session as a user message, so the target answers with
353
- its full memory, persona and history, and the exchange stays visible
354
- there afterwards. The target sees a header
355
- `[Message from agent <name>, session <slug>]` ahead of the message and
356
- answers as it would answer you; that answer comes back to the asker as
357
- the tool result. The header is the turn's frame — the server composes
358
- it beside the message, in the same per-turn field that carries the
359
- memory-recall block — so the stored text of the turn is the message
360
- itself, and that is what the target's memory and recall are built
361
- from.
362
- It is request-response, not a message bus: an agent that received a
363
- question answers by finishing its turn, never by calling `agent_ask`
364
- back at its caller.
328
+ ### Taking a question back
365
329
 
366
- ```
367
- agent_ask({ agent: "<other-agent>", message: "…" })
368
- agent_ask({ agent: "<other-agent>", session: "projekt-a", create_session: true, model: "<alias>", message: "…" })
369
- agent_ask({ agent: "<other-agent>", message: "…", images: ["/abs/path.png"], timeout_ms: 120000 })
370
- ```
330
+ `agent_ask_cancel({ call_id })` takes back a call of your own. Another
331
+ agent's call cannot be taken back.
371
332
 
372
- - **Where it lands.** Without `session`, a reply to the agent that
373
- wrote to you (or to your spawning parent) goes back to the session
374
- that message came from; anything else goes to the target's `main`.
375
- An explicit `session` always wins. An unknown slug is an error that
376
- lists the target's existing sessions.
377
- - **Creating a project session.** `create_session: true` creates a
378
- named slug on the target when it does not exist yet (not `main`, not
379
- ids, not `sub-…` sessions). `model` pins an alias or `provider/id`
380
- on the session this call creates; on an existing session it is
381
- ignored and the result says so in `session_note`. The target is
382
- told, beside its first message in that session, `[Your session
383
- '<slug>' was just created by <agent> for this conversation; it runs
384
- on model <model>.]` — the stored text is the question.
385
- - **Pictures.** `images` takes absolute paths. somora uploads them and
386
- puts them on the target's turn, so a model with vision sees them; a
387
- target without vision gets the vision worker's description.
388
- - **Queueing.** The call waits in the target session's queue in arrival
389
- order, like a typed message. It cannot ask yourself; a self-clone
390
- task is what `spawn_subagent` is for.
391
- - **Waiting.** `wait: true` (the default) blocks until the reply.
392
- `timeout_ms` defaults to `agentLoop.longTaskDefaultTimeoutMs`
393
- (5 minutes) and is capped at `longTaskMaxTimeoutMs` (30 minutes).
394
- When the target has not answered by then the call returns
395
- `state: "pending"` with a `call_id` — the target keeps working, and
396
- the message is never sent again.
397
- - **Handing over.** `wait: false` hands the message over and returns
398
- `state: "pending"` with the `call_id` at once (plus `session_created`,
399
- `session_model` or `session_note` when they apply). The rule: an
400
- answer needed to go on with this turn → `wait: true`; a job that may
401
- take its time → `wait: false`. Either way the reply reaches the asker
402
- — see the wake below.
403
- - **Taking it back.** `agent_ask_cancel({ call_id })` takes a call of
404
- your own back. Still waiting in the target's queue: it is removed and
405
- the target never sees it (`removed`). Already running — the usual
406
- case, since a free target starts a call within milliseconds: the
407
- target is told to stop through its running turn (the same channel a
408
- steered message uses), and whatever it still delivers wakes you no
409
- more (`withdrawn`, with `steered: true` when the stop message reached
410
- the turn, `false` when the engine does not read messages mid-turn or
411
- the turn had just ended). The target stops on its own; the tool never
412
- aborts another agent's turn — a person's Stop does that. `unknown`
413
- when nothing runs or waits under the id. Another agent's call cannot
414
- be taken back.
415
-
416
- The result has one of three states:
333
+ | Result | When |
334
+ |---|---|
335
+ | `removed` | The call was still waiting in the queue. The target never sees it. |
336
+ | `withdrawn` | The call was already running, which is the usual case. The target is told to stop, and whatever it still delivers no longer wakes you. `steered: true` means the stop message reached the running turn. `false` means the engine reads no messages mid-turn or the turn had just ended. |
337
+ | `unknown` | Nothing runs or waits under this id. |
417
338
 
418
- | `state` | What it carries | Meaning |
419
- |---|---|---|
420
- | `done` | `response`, `ms`, `usage`, `call_id`, `target_agent`, `target_session`, `routing_reason` (`explicit`, `reply_to_origin` or `default_main`), plus `session_inferred`, `session_created`, `session_model`, `session_note` or `routing_note` when they apply | The target answered. `routing_note` appears when no session was named, there was no origin to reply to, and the caller is working in a non-main session: the message went to the target's `main`, which may not have that context. |
421
- | `pending` | `call_id`, `hint` | The target is still queued or running, or the call was sent with `wait: false`. Fetch the outcome with `agent_ask_result`, or wait to be woken. |
422
- | `failed` | `error`, `hint` | The target's turn ran and failed — a model or engine error, or `stopped by the user` when a person pressed Stop on it — or it never ran because a person took it out of the target's queue (`removed from the queue by the user before it started`). An asker that had stopped waiting is woken with an `[agent answer]` turn saying so. Not something to retry on your own. |
423
-
424
- `agent_ask_result({ call_id })` picks up a pending call: `done` with
425
- the reply, `failed` with the error, or `pending` with `phase` `queued`
426
- or `running`. `wait_until_done: true` blocks server-side until the call
427
- finishes or `timeout_ms` passes, which is cheaper than polling. After a
428
- server restart, pass `agent` and `session` of the original call and the
429
- answer is read from the target's session.
430
-
431
- An asker that stopped waiting, or never waited, does not have to
432
- remember to poll. When the answer lands, the asker is woken in the
433
- session it asked from with an `[agent answer]` turn. Its text is the
434
- record of what happened:
339
+ The tool never aborts another agent's turn. Only a person's Stop does
340
+ that.
435
341
 
436
- ```text
437
- [agent answer] <other-agent> has answered the question you sent to session 'main' — you had stopped waiting for it. It begins: "…"
438
- ```
342
+ ### Follow-ups
439
343
 
440
- The instruction that goes with it — read the whole answer with
441
- `agent_ask_result({ call_id })`, then do what depended on it —
442
- accompanies the turn as its frame, beside the text, so the record
443
- stays one line. A question a person took out of the target's queue
444
- wakes the asker the same way (`… was removed from the queue by the
445
- user before <other-agent> saw it — it will not be answered (call_id
446
- "…")`). The wake waits `agentLoop.wakeGraceMs`
447
- (default 3 seconds); reading the result through `agent_ask_result`
448
- inside that window cancels it, and an asker still on the line never
449
- gets one. The same wake, with the same grace, brings back a finished
450
- background sub-agent and a rendered video — one mechanism for
451
- everything an agent started and walked away from.
452
-
453
- **Follow-ups.** A target may answer with "I am working on it with
454
- sub-agents and will report back". Its turn ends, and with it the call,
455
- while the work goes on. The asker does not have to come back for the
456
- rest. Every piece of work remembers during which turn it was started,
457
- so the sub-agents the target spawned while answering, the calls it
458
- made, and whatever those start in turn form a tree under the original
459
- call. When the last member of that tree has finished and the wake turn
460
- about it has run in the target's session, the asker hears about it
461
- exactly once — a follow-up carrying what the target wrote in its wake
462
- turns about this work, oldest first (the answers of all of them, not
463
- only the last: a summary given in the first wake turn is not lost to a
464
- "nothing new" in the second). A wake that is still waiting in the
465
- queue when the target reads that result itself is withdrawn, so a
466
- result fetched during another turn does not come back as a stale
467
- "finished" notice. So that this text is written for the asker and not as a note to
468
- self, every wake turn under such a call carries, beside the usual
469
- "fetch the result" frame, where its answer goes:
344
+ A target may answer "I am working on it with sub-agents and will report
345
+ back". Its turn ends while the work goes on. The asker does not need to
346
+ ask again.
347
+
348
+ Every piece of work remembers the turn it was started in. The
349
+ sub-agents the target spawned while answering, the calls it made, and
350
+ whatever those start, form a tree under the original call. Work started
351
+ inside a wake turn extends the tree.
352
+
353
+ When the last member has finished and the target's wake turn about it
354
+ has run, the asker gets one follow-up message. It carries what the
355
+ target wrote in all its wake turns about this work, oldest first. Four
356
+ subs are four wakes for the target and one follow-up for the asker.
357
+
358
+ So that the target writes for the asker, each of its wake turns carries
359
+ this note:
470
360
 
471
361
  ```text
472
362
  What you answer in this turn is forwarded to agent <asker> as the follow-up to the question they sent (call_id "<id>") once all the work you started for it has finished — write it as the answer to that question, with the results, not as a note to yourself.
473
363
  ```
474
364
 
475
- Four subs are four wakes in the target's session and one
476
- follow-up to the asker, after the fourth. Work started inside a wake
477
- turn extends the tree, and grandchildren count. The follow-up is an
478
- ordinary message from the target agent — `origin.kind: "agent"` with
479
- the original `call_id`, the text stored as the message — so clients
480
- render it like any other. Its frame, beside the usual `[Message from
481
- agent …]` header, says what it is:
365
+ The follow-up arrives as an ordinary message from the target
366
+ (`origin.kind: "agent"` with the original `call_id`), framed like this:
482
367
 
483
368
  ```text
484
369
  [Follow-up on the question you sent earlier (call_id "<id>"): the work it started has finished. Below is its result — treat it as the answer to that question. Continue whatever depended on it; if nothing does, tell your human in one line.]
485
370
  ```
486
371
 
487
- Nobody waits for this message, so taking it out of the queue wakes no
488
- one. There is no follow-up when the tree hangs under a person's turn
489
- (that session shows the wake itself) or under a turn nobody asked for
490
- (a sentinel fire, a tmux wake), when the call did not finish `done`,
491
- when the wake turn was stopped by a person, when the target has already
492
- sent the asker a message of its own since the call finished, or when the
493
- asker read the result with `agent_ask_result` during the grace. A wake
494
- turn that fails for another reason still produces one, saying the work
495
- finished but the turn reporting it failed, with the error. Like the
496
- rest of the ledger the tree lives in memory: after a server restart
497
- there is none, and no follow-up. So a target that says it will report
498
- back does — through such a follow-up turn — and the asker never asks
499
- again.
500
-
501
- Blocking waits are guarded against cycles. The server tracks who waits
502
- on whom and refuses a call that would close the loop — even through a
503
- chain of three or more agents — with an error that says so, instead of
504
- letting both sessions hang. Sub-agents waiting on their parents are
505
- part of the same graph.
506
-
507
- ## Persona files change only with a backup
508
-
509
- Agents may edit their own persona files and each other's (self-edit and
510
- collaborative editing are by design), but never without a copy: every
511
- `file_write` or `file_patch` on `AGENTS.md`, `SOUL.md`, `USER.md`,
512
- `VOICE.md` or `agent.yaml` first writes `<file>.bak-<timestamp>` (last
513
- five kept), the same way the web editor does. See
514
- [files.md](files.md#persona-files-never-without-a-backup).
515
-
516
- ## What a server restart does to running turns
517
-
518
- A restart cuts every turn that is running. At the next boot somora
519
- reads each session's tail: a turn without an end gets an `error`
520
- (`[somora] This turn was interrupted by a server restart…`) and a
521
- `turn_end`, so the window stops showing it as running and the model's
522
- history is whole again. Whoever was waiting for that turn is told: an
523
- agent that asked with `agent_ask` (waiting or not) or with
524
- `builder_dispatch` is woken with `[agent answer] … was cut off by a
525
- server restart before an answer came` and the `call_id`, the parent of a
526
- helper with a `[subagent attention]` note. Nothing is re-run on its own;
527
- the asker sends again if it still needs the answer.
372
+ There is no follow-up when:
373
+
374
+ - the work hangs under a person's turn, or under a turn nobody asked
375
+ for, such as a sentinel fire or a tmux wake
376
+ - the call did not finish `done`
377
+ - a person stopped the wake turn
378
+ - the target has already sent the asker a message of its own since
379
+ - the asker read the result with `agent_ask_result` during the grace
380
+ - the server was restarted: the tree lives in memory
381
+
382
+ A wake turn that fails for another reason still sends one. It says the
383
+ work finished but the turn reporting it failed, with the error.
384
+
385
+ ### No deadlocks
386
+
387
+ The server tracks who waits on whom. A blocking call that would close a
388
+ circle, even through three or more agents, is refused with an error
389
+ that says so. Sub-agents waiting on their parents are part of the same
390
+ check.
528
391
 
529
392
  ## Sub-agents
530
393
 
531
- `spawn_subagent` delegates a sealed task. The sub runs in a **fresh**
532
- session of the target persona — `sub-<parent>-<timestamp>`, or
533
- `sub-self-…` for a clone of the caller — with normal memory, tools and
534
- thinking, and produces a final answer. Sub sessions stay visible in the
535
- target's session list with a "sub from" marker.
394
+ `spawn_subagent` delegates a sealed task. The sub runs in a fresh
395
+ session of the target agent, with normal memory, tools and thinking,
396
+ and returns a final answer. The session is named
397
+ `sub-<parent>-<timestamp>`, or `sub-self-…` for a clone of the caller,
398
+ and stays visible in the session list with a "sub from" marker.
536
399
 
537
400
  ```
538
401
  spawn_subagent({ task: "…" }) # clone of yourself, background
@@ -541,137 +404,404 @@ spawn_subagent({ task: "…", model: "<alias>", maxRounds: 32, attention: false
541
404
  spawn_subagents({ tasks: [{ task: "…" }, { persona: "<other-agent>", task: "…" }] })
542
405
  ```
543
406
 
544
- - **Every spawn is a background task.** `spawn_subagent` registers a
545
- task and starts the sub in the background whichever way it is
546
- called. **`wait: false`** (default) returns the `task_id` at once
547
- and the caller's turn ends. **`wait: true`** waits for that same
548
- task and returns the sub's final answer inline — the result, the
549
- runtime verdict and the `task_id`. Because a synchronous sub is an
550
- ordinary task, it appears in `subagent_list`, a person can stop it
551
- with the Stop button, and `subagent_cancel` reaches it and every
552
- sub it spawned while the parent is still waiting.
553
- - **When the wait runs out.** The wait is sized off
554
- `agentLoop.longTaskMaxTimeoutMs` (default 30 minutes, minus a few
555
- seconds). A sub still working by then does not fail: the tool
556
- returns `ok: false, wait: "sync", state: "pending"` with the
557
- `task_id` and a hint, the sub keeps running, and the parent is woken
558
- with a `[subagent attention]` turn when it finishes — or fetches the
559
- result itself with `subagent_result({ task_id })`. A sub that
560
- finishes inside the wait does not wake the parent; the parent has
561
- the result.
562
- - **`spawn_subagents`** runs up to eight tasks in parallel and returns
563
- one result per task in the same order; `wait` applies to the batch.
564
- - **`model`** overrides the persona's default for this sub (an alias or
565
- `provider/id` exactly as configured). **`maxRounds`** raises the
566
- sub's tool-call round cap above `agentLoop.maxRounds` — orchestrator
567
- subs that spawn and poll their own subs need it. **`images`** works
568
- as for `agent_ask`.
569
- - **Checking on a sub.** `subagent_status({ task_id })` reports
570
- `running`, `done`, `failed` or `cancelled` with target and
571
- timestamps. `subagent_result({ task_id, wait_until_done?, timeout_ms? })`
572
- returns `done` with the text, `usage`, the runtime verdict `outcome`
573
- (`completed`, `partial`, `degraded`, `failed`) with `outcome_reason`,
574
- `tool_calls`, `rounds`, `files_written`, `media` and
575
- `follow_ups` (texts that arrived after the sub's report, oldest
576
- first — see the follow-up wake below); `failed` with
577
- the error; or `pending`. `subagent_list({ state?, limit? })` lists
578
- the caller's own tasks, newest first, from the server's in-memory
579
- registry (a restart empties it). `subagent_cancel({ task_id,
580
- reason? })` cancels a sub of your own — running, or still waiting in
581
- its session's queue — and every sub it spawned; files on disk and the
582
- session stay.
583
- - **Attention wake.** When a background sub finishes and its result has
584
- not been fetched, the parent is woken in the session it spawned from
585
- with a `[subagent attention]` turn. Its text is the record:
586
-
587
- ```text
588
- [subagent attention] Task '<task_id>' (sub-agent '<name>', session 'sub-…') finished with state 'done'. Outcome: completed, 7 tool calls, 3 rounds. First line: "…" Files written (1): … Generated media (1): …
589
- ```
590
-
591
- The instruction — fetch the full answer with `subagent_result({
592
- task_id })`, then continue whatever depended on it — accompanies
593
- the turn as its frame, beside the text. A brief a person removed
594
- from the queue wakes the parent the same way (`… was removed from
595
- the queue by the user before it started — there is no result.`).
596
- The wake waits `agentLoop.wakeGraceMs` (default 3 seconds); a
597
- `subagent_result` inside that window cancels it, and
598
- `attention: false` opts a spawn out of it altogether — except when
599
- the spawn happened while answering another agent or a voice call:
600
- they wait for the outcome and hear it through the follow-up, which
601
- needs that wake, so the flag does not count there. A sub a person
602
- stops from the queue (■ under From here, `/queue rm` in the TUI)
603
- wakes its parent the same way, with `was stopped by the user before
604
- it finished — there is no result`; a sub the parent cancels itself,
605
- and children taken down with their parent, wake no one.
606
- - **Follow-up wake.** A sub that starts sub-agents of its own is told
607
- in its system prompt not to hand in its report while they are still
608
- working: wait for them (`wait: true`, or `subagent_result` with
609
- `wait_until_done`) and fold their results in, because what it returns
610
- is what its parent gets. A sub that reports early anyway does not
611
- leave its parent without the rest. Whatever a sub starts is
612
- remembered as started during its task — its own subs, the agents it
613
- asks, and what those start in turn — and when the last of it has
614
- finished and the wake about it has run in the sub's session, the
615
- parent gets one more `[subagent attention]` turn:
616
-
617
- ```text
618
- [subagent attention] Task '<task_id>' (sub-agent '<name>', session 'sub-…') has a follow-up: the work it started has finished. It begins: "…"
619
- ```
620
-
621
- Its frame: fetch it with `subagent_result({ task_id })` — the
622
- follow-up is in its `follow_ups` field — then continue whatever
623
- depended on it; if nothing does, a short acknowledgement to the user
624
- is enough. The sub's own wake turns (about its subs) carry the
625
- matching note — "What you answer in this turn is forwarded to your
626
- parent (<agent>, session <session>) as the follow-up to task
627
- '<task_id>' …" — so the sub writes them as its report. The text is
628
- the final text of that last wake turn;
629
- `follow_ups` (`result.follow_ups` under `GET /spawn-result`) keeps every
630
- follow-up of a task, oldest first. A parent hears once, after the
631
- whole tree, not once per level, and work started inside a wake turn
632
- extends the tree. The follow-up waits the same grace, and a
633
- `subagent_result` inside it cancels it. There is none for a task a
634
- person asked for, for one that did not finish `done`, for a wake turn
635
- a person stopped, or after a server restart; a wake turn that failed
636
- for another reason still sends one, saying the work finished but the
637
- turn reporting it failed, with the error.
638
- - **Limits.** Nesting is capped at depth 3. Each agent may run 4 subs
639
- at once and the whole server 16; subs spawned by subs count against
640
- the parent's 4 and may fill only 3 of them, so an orchestrator sub
641
- can never lock its own agent out. A spawn that finds a cap full is
642
- refused with the numbers.
643
-
644
- A sub's turn is a turn like any other: it waits in its session's
645
- queue, shows up in `/health` and in the session's queue view, and a
646
- person can stop it — with Stop in the sub's own session the parent sees
647
- the task as `failed` with `stopped by the user`; with ■ under "From
648
- here" in the queue popover (or `/queue rm` in the TUI) as `cancelled`
649
- with the same reason — or remove it from the queue before it starts,
650
- which the parent sees as `cancelled` with `removed from the queue by
651
- the user before it started`. Either way the parent is woken and told.
652
-
653
- ## Programmatic agent creation
654
-
655
- If you want to script agent creation, the directory layout is the contract.
656
- Drop the files into `~/.somora/agents/<name>/` and they're picked up on the
657
- next `GET /agents` request.
658
-
659
- The HTTP API:
407
+ | Parameter | Meaning |
408
+ |---|---|
409
+ | `task` | The brief. The sub sees nothing else of the parent's conversation. |
410
+ | `persona` | The agent to run as. Default: a clone of the caller. |
411
+ | `wait` | `false` (default) returns the `task_id` at once. `true` waits and returns the answer, the runtime verdict and the `task_id`. |
412
+ | `model` | An alias or `provider/id` for this sub. |
413
+ | `maxRounds` | Raises the round cap above `agentLoop.maxRounds` for this sub, up to 100. Subs that orchestrate their own subs need it. |
414
+ | `attention` | `false` switches off the wake when the sub finishes. Ignored when the spawn happened while answering another agent or a voice call: those wait for the outcome. |
415
+ | `images` | As for `agent_ask`. |
416
+
417
+ `spawn_subagents` runs up to eight tasks in parallel and returns one
418
+ result per task in the same order. `wait` applies to the whole batch.
419
+
420
+ Every spawn is a background task, also with `wait: true`. It appears in
421
+ `subagent_list`, a person can stop it, and `subagent_cancel` reaches it
422
+ and every sub it started.
423
+
424
+ A `wait: true` that runs out is not a failure. The wait is just under
425
+ `agentLoop.longTaskMaxTimeoutMs` (30 minutes). After that the tool
426
+ returns `ok: false, wait: "sync", state: "pending"` with the `task_id`.
427
+ The sub keeps running and the parent is woken when it finishes.
428
+
429
+ ### Checking on a sub
660
430
 
431
+ | Tool | What it returns |
432
+ |---|---|
433
+ | `subagent_status({ task_id })` | `running`, `done`, `failed` or `cancelled`, with target and timestamps. |
434
+ | `subagent_result({ task_id, wait_until_done?, timeout_ms? })` | `done` with the text, `usage`, `outcome` (`completed`, `partial`, `degraded`, `failed`), `outcome_reason`, `tool_calls`, `rounds`, `files_written`, `media` and `follow_ups`. Or `failed` with the error, or `pending`. |
435
+ | `subagent_list({ state?, limit? })` | The caller's own tasks, newest first. The list lives in memory: a restart empties it. |
436
+ | `subagent_cancel({ task_id, reason? })` | Cancels a sub of your own, running or queued, and every sub it spawned. Files and the session stay. |
437
+
438
+ ### The attention wake
439
+
440
+ When a background sub finishes and nobody fetched its result, the
441
+ parent is woken in the session it spawned from:
442
+
443
+ ```text
444
+ [subagent attention] Task '<task_id>' (sub-agent '<name>', session 'sub-…') finished with state 'done'. Outcome: completed, 7 tool calls, 3 rounds. First line: "…" Files written (1): … Generated media (1): …
661
445
  ```
662
- GET /agents list agents
663
- GET /agents/:agent/sessions list sessions
664
- POST /agents/:agent/sessions {slug} create session
665
- POST /agents/:agent/sessions/:session/reset archive + reset (spawns REM if configured)
666
- GET /agents/:agent/memory/notes list memory inbox notes
667
- GET /agents/:agent/memory/search?q=… hybrid recall across memory+wiki+vault (debug)
668
- POST /agents/:agent/tools/:name invoke a tool directly (debug)
669
- POST /dream/run-deep {wait?, force?} trigger Deep manually (platform-wide)
670
- POST /dream/run-lucid {wait?} trigger Lucid manually (platform-wide)
446
+
447
+ The turn tells the parent to fetch the full answer with
448
+ `subagent_result({ task_id })` and continue. The wake waits
449
+ `agentLoop.wakeGraceMs`, and a `subagent_result` inside that time
450
+ cancels it. A sub that finishes inside a `wait: true` wakes no one.
451
+
452
+ | What happened to the sub | The parent sees | Woken |
453
+ |---|---|---|
454
+ | A person pressed Stop in the sub's session | `failed`, `stopped by the user` | yes |
455
+ | A person stopped it from the queue view (■ under "From here", or `/queue rm` in the TUI) | `cancelled`, `stopped by the user` | yes |
456
+ | A person removed it from the queue before it started | `cancelled`, `removed from the queue by the user before it started` | yes |
457
+ | The parent cancelled it, or it went down with its parent | `cancelled` | no |
458
+
459
+ ### Follow-ups from a sub
460
+
461
+ A sub that starts sub-agents of its own is told not to hand in its
462
+ report while they still work. It should wait for them (`wait: true`, or
463
+ `subagent_result` with `wait_until_done`) and fold their results in.
464
+
465
+ A sub that reports early anyway does not leave its parent without the
466
+ rest. The work it started is tracked as a tree, as for `agent_ask`.
467
+ When the last of it has finished, the parent gets one more wake:
468
+
469
+ ```text
470
+ [subagent attention] Task '<task_id>' (sub-agent '<name>', session 'sub-…') has a follow-up: the work it started has finished. It begins: "…"
471
+ ```
472
+
473
+ The text is in the `follow_ups` field of `subagent_result`
474
+ (`result.follow_ups` under `GET /spawn-result`), which keeps every
475
+ follow-up of a task, oldest first. The parent hears once, after the
476
+ whole tree, not once per level.
477
+
478
+ The sub's own wake turns carry the matching note, so it writes them as
479
+ its report:
480
+
481
+ ```text
482
+ What you answer in this turn is forwarded to your parent (<agent>, session <session>) as the follow-up to task '<task_id>' …
483
+ ```
484
+
485
+ There is no follow-up for a task a person asked for, for one that did
486
+ not finish `done`, for a wake turn a person stopped, or after a server
487
+ restart. A wake turn that failed for another reason still sends one,
488
+ with the error.
489
+
490
+ ### Limits
491
+
492
+ | Limit | Value |
493
+ |---|---|
494
+ | Nesting depth | 3 |
495
+ | Subs running at once, per agent | 4 |
496
+ | Subs running at once, whole server | 16 |
497
+ | Subs started by subs | Count against the parent's 4 and may fill only 3 of them, so an orchestrating sub cannot lock its agent out. |
498
+
499
+ A spawn that finds a limit reached is refused with the numbers. A sub's
500
+ turn is a turn like any other: it waits in its session's queue and
501
+ shows up in `GET /health` and in the queue view.
502
+
503
+ ## What a restart does to running turns
504
+
505
+ A server restart cuts every running turn. At the next start somora
506
+ closes each open turn with an `error` entry and a `turn_end`, so the
507
+ window stops showing it as running and the history is whole again:
508
+
509
+ ```text
510
+ [somora] This turn was interrupted by a server restart; the work it was doing stopped here.
671
511
  ```
672
512
 
673
- See:
674
- - [memory.md](memory.md) — the per-agent memory inbox + retrieval
675
- - [wiki.md](wiki.md) — the shared long-term wiki layer
676
- - [dream-phases.md](dream-phases.md) — REM/Deep/Lucid mechanics
677
- - [tools.md](tools.md) — full tool reference
513
+ Whoever waited for such a turn is woken and told. Nothing is run again
514
+ by itself.
515
+
516
+ | Who waited | Wake text begins |
517
+ |---|---|
518
+ | An agent that asked with `agent_ask` or `builder_dispatch` | `[system: restart] The question you sent to <agent> (session '<session>') was cut off by a server restart before an answer came`, with the `call_id` |
519
+ | The parent of a sub-agent | `[system: restart] The helper in <agent>'s session '<session>' was cut off by a server restart before it finished; there is no result.` |
520
+
521
+ > **Tip:** An agent that needs to restart somora should run
522
+ > `somora server restart` or `somora update` from its shell. The restart
523
+ > then waits until the agent's turn has ended, and the agent is woken
524
+ > afterwards.
525
+
526
+ ## Settings
527
+
528
+ All of this lives in `~/.somora/agents/<name>/agent.yaml`. Every key is
529
+ optional. Unknown keys are ignored.
530
+
531
+ ```yaml
532
+ kind: chat # chat | builder
533
+ model: opus # alias or provider/modelId
534
+ fallback: [gpt55, orhaiku] # one ref or an ordered list
535
+ thinking: medium # off | low | medium | high
536
+ steering: false
537
+ imageReview: never # never | always
538
+
539
+ sampling:
540
+ temperature: 1.0
541
+ top_p: 0.95
542
+
543
+ agentLoop:
544
+ maxRounds: 50
545
+ maxToolCallsPerTurn: 200
546
+ maxTurnMs: 3600000
547
+
548
+ workspace:
549
+ path: ~/<your-agent>-workspace
550
+
551
+ tools:
552
+ deny: ['toolset:exec', 'mcp__parallel__*']
553
+ allow: []
554
+
555
+ skills:
556
+ deny: ['instagram-downloader']
557
+
558
+ resources:
559
+ deny: ['production-db']
560
+
561
+ voice:
562
+ enabled: true
563
+ voice: ash
564
+ language: de
565
+ style: "dry, direct, no small talk"
566
+ consultPolicy: always # auto | substantive | always
567
+ maxSpokenSentences: 4
568
+
569
+ rem:
570
+ enabled: true
571
+ model: gemma4big
572
+ fallback: [glm, deep41flash]
573
+ idleMinutes: 30
574
+ chunkTokens: 50000
575
+ chunkTimeoutMs: 600000
576
+ participate_in_wiki: true
577
+ thinking: low
578
+ ```
579
+
580
+ ### Model and fallback
581
+
582
+ | Key | Type | Default | Meaning |
583
+ |---|---|---|---|
584
+ | `model` | string | none | The agent's model: an alias or `provider/modelId` from `config.yaml`. A session override (`/model`) wins over it. |
585
+ | `fallback` | string or list | none | Backup models, tried in order. Repeated entries and the primary itself are dropped. |
586
+ | `thinking` | `off`, `low`, `medium`, `high` | the model's own | Reasoning depth. Applies only to models with the `reasoning` capability. Per session: `/thinking <level>`. |
587
+ | `sampling` | map | the model's own | Sampling values for `openai-compatible` models, per key over the model's defaults. Per session: `/sampling`, `/temp`. No effect on the CLI engines. |
588
+
589
+ `sampling` accepts `temperature` (0 to 2), `top_p` (0 to 1), `top_k`,
590
+ `min_p` (0 to 1), `frequency_penalty` and `presence_penalty` (-2 to 2),
591
+ `repetition_penalty`, `seed` and `stop` (a string or up to four). Any
592
+ other key in this block is an error.
593
+
594
+ How the fallback chain works:
595
+
596
+ - **When it switches.** A backup takes over only when the model before
597
+ it failed before its first output and before any tool call. A turn
598
+ that already called a tool is never repeated on another model: the
599
+ side effects have happened.
600
+ - **Refusals as text.** Some providers send their refusal, such as a
601
+ quota notice, as answer text and then report an error. That text is
602
+ not an answer, so the chain still runs.
603
+ - **You see it.** The turn carries a fallback chip and the web client
604
+ shows a notice.
605
+ - **Dead models are remembered.** A model that was unreachable is
606
+ skipped for `fallback.retryUnavailableMinutes` (default 60, in
607
+ `config.yaml`). Turns start on the working backup at once. The chip's
608
+ reason then reads `not tried — marked unavailable since …`. After
609
+ that time the primary is tried again, and a success clears the mark.
610
+
611
+ > **Tip:** Put at least one fallback on a different host or provider
612
+ > than the primary. Two models on the same GPU box go down together.
613
+
614
+ ### Behaviour
615
+
616
+ | Key | Type | Default | Meaning |
617
+ |---|---|---|---|
618
+ | `kind` | `chat`, `builder` | `chat` | The kind of agent. Set once at creation. |
619
+ | `steering` | boolean | `false` | Default for a message typed in the web client while a turn runs. `true` hands it into the running turn before its next step. `false` queues it as its own turn. The toggle next to Send flips it per message. Steering works on `openai-compatible`, `claude-cli` and `codex-cli`. Other engines always queue. |
620
+ | `imageReview` | `never`, `always` | `never` | `always` feeds each generated image back to the agent so it can judge it, about 2k tokens per image. Not a lock: the agent can set `return_image` per call either way. |
621
+ | `agentLoop.maxRounds` | integer | server value (8) | Rounds per turn on the `openai-compatible` engine. Builders default to 500. |
622
+ | `agentLoop.maxToolCallsPerTurn` | integer | server value (30) | Tool calls per turn, across all rounds. Builders default to 2000. |
623
+ | `agentLoop.maxTurnMs` | integer | none | Time limit per turn in milliseconds. Builders default to 8 hours. |
624
+
625
+ ### Workspace and visibility
626
+
627
+ | Key | Type | Default | Meaning |
628
+ |---|---|---|---|
629
+ | `workspace.path` | string | `workspace.default` in `config.yaml` (`~/somoraworkspace`) | Default folder for the `file_*` tools. `~` expands. Created at server start. |
630
+ | `tools.deny` | list | empty | Tools to hide. |
631
+ | `tools.allow` | list | empty | When not empty, only these tools are offered. |
632
+ | `skills.deny` | list | empty | Skills to hide. |
633
+ | `skills.allow` | list | empty | When not empty, only these skills are offered. A plain list (`skills: [a, b]`) means the same. |
634
+ | `resources.deny` | list | empty | Remote resources to hide. There is no allow list. |
635
+
636
+ Rules for `tools` and `skills`:
637
+
638
+ - `deny` beats `allow`. No block means no restriction.
639
+ - A tool pattern is an exact name (`web_search`), a toolset
640
+ (`toolset:exec`) or a name with a trailing `*` (`mcp__parallel__*`).
641
+ The same patterns cover built-in tools and tools from MCP servers.
642
+ - A hidden tool is removed from the model's tool list, which saves
643
+ context on every turn.
644
+ - Only tools whose configuration exists are offered at all. The
645
+ Abilities window lists exactly those.
646
+ - The Abilities window edits exact names only. When the file holds an
647
+ `allow` list or patterns, the window shows them read-only.
648
+ - For a builder, `tools.allow` adds to the builder set and
649
+ `skills.allow` is the complete list.
650
+
651
+ ### Voice
652
+
653
+ Without a `voice` block the agent cannot be called and does not appear
654
+ in the voice picker. The block holds only what speaking needs. Who the
655
+ agent is comes from its persona files.
656
+
657
+ | Key | Type | Default | Meaning |
658
+ |---|---|---|---|
659
+ | `voice.enabled` | boolean | `true` | Switches the voice off without removing the block. |
660
+ | `voice.voice` | string | the provider's | Voice id, for example `ash`. |
661
+ | `voice.language` | string | the speech-to-text language | Spoken language, 2 to 8 characters. |
662
+ | `voice.style` | string | none | One line on how the agent sounds. Up to 400 characters. |
663
+ | `voice.consultPolicy` | `auto`, `substantive`, `always` | `realtimeVoice.consultPolicy` | When the voice must ask the agent before answering. |
664
+ | `voice.maxSpokenSentences` | integer, 1 to 10 | `4` | Longest spoken answer. |
665
+
666
+ ### REM
667
+
668
+ REM is the per-agent dream phase. After a session goes quiet it reads
669
+ the conversation and proposes notes for the agent's memory. Deep and
670
+ Lucid work for the whole install and are set under `wiki.deep` and
671
+ `wiki.lucid` in `config.yaml`.
672
+
673
+ | Key | Type | Default | Meaning |
674
+ |---|---|---|---|
675
+ | `rem.enabled` | boolean | required | Master switch. |
676
+ | `rem.model` | string | required | The worker model. It never inherits the chat model, so REM cannot run on an expensive model by accident. |
677
+ | `rem.fallback` | string or list | none | Backup workers, tried in order when the one before is unreachable: connection refused, a 5xx error, a timeout, a rate limit. A 4xx error is a configuration problem and does not switch. It never inherits the chat fallback. |
678
+ | `rem.idleMinutes` | number | `30` | Quiet minutes before REM starts. Every message to the agent resets the count. |
679
+ | `rem.chunkTokens` | integer | `50000` | Size of one piece of a long session. |
680
+ | `rem.chunkTimeoutMs` | integer | `600000` | Time limit per piece. Ten minutes leaves room for local models. A piece that runs out is marked failed and REM continues with the next. |
681
+ | `rem.participate_in_wiki` | boolean | `true` | `false` keeps Deep away from this agent's notes. REM still runs. Useful for scratch agents. |
682
+ | `rem.thinking` | `off`, `low`, `medium`, `high` | none | Reasoning depth for the worker, when its model has the `reasoning` capability. |
683
+
684
+ The worker can be a model on `claude-cli`, `codex-cli` or an
685
+ `openai-compatible` provider. A model on `grok-cli` cannot run REM.
686
+
687
+ > **Note:** A `rem` block needs both `enabled` and `model`, also with
688
+ > `enabled: false`. REM agents are registered when the server starts:
689
+ > restart after you switch REM on or change `idleMinutes`.
690
+
691
+ ### Related settings in config.yaml
692
+
693
+ | Setting | Default | Meaning |
694
+ |---|---|---|
695
+ | `fallback.retryUnavailableMinutes` | `60` | How long an unreachable model is skipped. 1 to 1440. |
696
+ | `agentLoop.maxRounds` | `8` | Rounds per turn, `openai-compatible` engine. |
697
+ | `agentLoop.maxToolCallsPerTurn` | `30` | Tool calls per turn. |
698
+ | `agentLoop.longTaskDefaultTimeoutMs` | `300000` | Default wait of `agent_ask` and the result tools. |
699
+ | `agentLoop.longTaskMaxTimeoutMs` | `1800000` | Longest wait. |
700
+ | `agentLoop.wakeGraceMs` | `3000` | Delay before a wake turn. 0 to 60000. |
701
+ | `agentLoop.toolUsageReminder` | `true` | The tool reminder in the prompt. |
702
+ | `promptBudgets.personaFileChars` | `8000` | Budget for each of `AGENTS.md`, `SOUL.md`, `USER.md`. |
703
+ | `promptBudgets.personaTotalChars` | `14000` | Budget for the three together. |
704
+ | `promptBudgets.teamBlockChars` | `3000` | Budget for the team block. |
705
+ | `workspace.default` | `~/somoraworkspace` | Workspace of agents without their own. |
706
+
707
+ The prompt budgets are what the Agent window measures against. They
708
+ warn. They do not cut anything.
709
+
710
+ ## Commands
711
+
712
+ | Command | What it does |
713
+ |---|---|
714
+ | `somora setup agent` | Creates an agent with guidance, and checks that every agent's model exists. |
715
+ | `somora setup memory` | Switches REM on per agent, among other things. |
716
+ | `somora team init`, `check`, `show <agent>` | Creates and validates `team.yaml`, and prints the team block an agent sees. |
717
+ | `somora tui` | Opens the TUI, where the commands under [Sessions](#sessions) work. |
718
+
719
+ There is no command that creates an agent without questions. For
720
+ scripts, the folder layout is the contract: write the files and the
721
+ agent is there on the next `GET /agents`.
722
+
723
+ ## Routes
724
+
725
+ | Route | What it does |
726
+ |---|---|
727
+ | `GET /agents` | Lists agents: `name`, `description`, `icon`, `color`, `role`, `steering`, `kind`. |
728
+ | `GET /agents/:agent/persona` | The persona files and `agent.yaml` with content, hash and size, plus `promptBudgets`. |
729
+ | `PUT /agents/:agent/persona/:file` | Saves `AGENTS.md`, `SOUL.md` or `USER.md`. Body `{content, baseHash}`. Answers 409 with the current content when the file changed since `baseHash`. |
730
+ | `GET /agents/:agent/prompt-preview?session=` | The system prompt of the next turn, its parts, and the visible tools with their schema size. |
731
+ | `GET /agents/:agent/system-prompt` | The persona part of the prompt only. |
732
+ | `GET /agents/:agent/tools` | The configured tools with a `visible` flag each. |
733
+ | `PUT /agents/:agent/tools` | Writes `tools` into `agent.yaml`. Body `{deny, allow}`. |
734
+ | `GET /agents/:agent/skills` | The skills with a `visible` flag each. |
735
+ | `PUT /agents/:agent/skills` | Writes `skills` into `agent.yaml`. Body `{deny, allow}`. |
736
+ | `POST /agents/:agent/tools/:name` | Runs a tool directly, for debugging. |
737
+ | `GET /agents/:agent/sessions` | Lists sessions. |
738
+ | `POST /agents/:agent/sessions` | Creates a session. Body `{slug}`. 409 when the name is taken. |
739
+ | `POST /agents/:agent/sessions/:session/reset` | Archives the session and starts it fresh. |
740
+ | `POST /agents/:agent/sessions/:session/archive`, `/unarchive` | Archives a session, or brings it back. |
741
+ | `GET /agents/:agent/sessions/:session/export?format=` | The session as `markdown` (default) or `json`. |
742
+ | `GET`, `PUT`, `DELETE /agents/:agent/sessions/:session/model` | The session's model override. `/thinking` and `/sampling` work the same way. |
743
+ | `GET /agents/:agent/memory/notes` | Lists the agent's indexed notes. |
744
+ | `GET /agents/:agent/memory/search?q=` | Searches memory, wiki and vault, for debugging. |
745
+ | `POST /agents/:agent/dream/run-rem` | Starts REM for this agent now. |
746
+ | `POST /dream/run-deep`, `POST /dream/run-lucid` | Start Deep or Lucid, for the whole install. Body `{wait?, force?}` and `{wait?}`. |
747
+ | `GET /spawn-result` | The result of a sub-agent task, as `subagent_result` reads it. |
748
+
749
+ Bodies and answers in full are on the [API](api.md) page.
750
+
751
+ ## Troubleshooting
752
+
753
+ **The agent does not appear.** The folder needs an `AGENTS.md`, and the
754
+ folder name must match the naming rule under [Set it up](#set-it-up).
755
+
756
+ **The agent ignores its `agent.yaml`.** One invalid value makes somora
757
+ ignore the whole file: the agent then has no model, no tool rules and
758
+ no REM. The log line `persona.agent_yaml_parse_failed` names the key.
759
+ Common causes: a `rem` block without `model`, an unknown key under
760
+ `sampling`, a `thinking` value outside the four levels, or broken YAML.
761
+ `persona.agent_yaml_not_object` means the file is not a key and value
762
+ map.
763
+
764
+ **Turns fail with "model … cannot be resolved".** `model` is missing or
765
+ is not an alias or `provider/modelId` from `config.yaml`. The error
766
+ lists the valid names. If the model is set, check the point above.
767
+
768
+ **The frontmatter is ignored.** `persona.frontmatter_parse_failed` in
769
+ the log: the frontmatter of that file is not valid YAML. Quote values
770
+ that contain a colon.
771
+
772
+ **A fallback never runs.** The primary produced output or called a tool
773
+ before it failed. That turn is not repeated. Entries equal to the
774
+ primary are dropped (`persona.fallback_is_primary`), as are repeated
775
+ ones (`persona.fallback_duplicate`).
776
+
777
+ **The web editor refuses a save.** The agent changed the file after you
778
+ opened it. Reload and apply your change again. An empty `AGENTS.md`,
779
+ and a `name` that differs from the folder, are refused too.
780
+
781
+ **REM does not start.** `POST /agents/:agent/dream/run-rem` answers
782
+ "REM is not enabled" when `rem.enabled` is not `true`, and "REM worker
783
+ has no entry" when REM was switched on after the server started.
784
+ Restart the server.
785
+
786
+ **A file was overwritten.** Look for `<file>.bak-<timestamp>` next to
787
+ it. To see who changed the tool or skill rules through the web client,
788
+ search the log for `agents.tool_gating_updated`.
789
+
790
+ ## See also
791
+
792
+ - [Builder agents](builder.md): the other kind of agent
793
+ - [Team](team.md): `team.yaml` and what agents know about each other
794
+ - [Models](models.md): providers, aliases and capabilities
795
+ - [Tools](tools.md): every tool, and choosing tools per agent
796
+ - [Skills](skills.md): skills and their visibility
797
+ - [Resources](resources.md): remote machines an agent can reach
798
+ - [File tools](files.md): where agents may write, and the backups
799
+ - [Memory](memory.md): the agent's notes and recall
800
+ - [Wiki](wiki.md): the shared long-term layer
801
+ - [Dream phases](dream-phases.md): REM, Deep and Lucid
802
+ - [Thinking](thinking.md) and [Sampling](sampling.md): the levels and
803
+ values in detail
804
+ - [Realtime voice](realtime-voice.md): calls, `VOICE.md` and the voice
805
+ settings
806
+ - [Web client](web.md): the Agent window, Abilities and Sessions
807
+ - [API](api.md): all routes, including `steer` on `POST /chat/send`