ADR-058: A helper is a child run on its own thread, with its steps in the parent's log
Date: 2026-11-15 Status: superseded by ADR-059 (a helper is a child session). The limits, the read-only tool set and the rule that an answer is data carry over
Context
A small local model is good at a narrow job with a short context and bad at a long chat (docs/vision/sub-agents.md). One broad question ("what is this repo") filled 29.7K of a 32K window with file contents. Step 9.7 (#866) hands such a job to a helper that starts with an empty context and returns a short answer. Phase 15 (#733) plans full sub-agents later: agent files, approvals that bubble up, parallel workers, child sessions.
The vision says a child is "a session of its own, linked to its parent". A full child session needs headless sessions (4.0, ADR-050), which are not built. This step needs something smaller that does not close that door. The tickets that depend on this ADR are #911 (the delegate tool), #912 (chat and trace), #913 (limits and cost) and #914 (the prompt line).
What exists today:
open_chatandChatRuntimeingolem/graphs/chat.pycompile one chat graph.ChatRuntime.streamruns it on a thread whose id is the session id (ADR-002). The checkpoint is the model's memory (ADR-006).- The stream yields facts (
golem/graphs/adapter.py).run_turnand_applyingolem/sessions/runner.pyturn them into events and keep per-run bookkeeping in_Progress. tools_nodeingolem/graphs/tools_node.pydecides every call with the permission policy. A call that asks callsinterrupt()(ADR-013).- The reducer in
packages/view/src/chat-state.tsdrawstool.*events under the assistant message named bymessage_id. - The trace is built from the log by
build_traceingolem/sessions/trace.py(ADR-041).
Decision
What a child is now. A child run: the same chat graph, run on its own checkpoint thread
<session_id>/c/<call_id>, started by thedelegatetool inside the parent's run.<call_id>is the id of thedelegatecall. Its message history is its own and begins with the brief. It is not a row insessions, andsession.listdoes not show it. Nothing lists the thread, andsession.inspecton the parent does not include it. A child shares the parent's graph, router, tool registry and policy; only the thread, the tool scope and the limits differ. Phase 15 may later promote a child run to a session. The thread id, theparent_call_idon its events and the unchanged graph are chosen so that promotion is a migration, not a rewrite: the thread becomes a session's thread, and the events get a session of their own.Events. A child's
model.call.started,model.call.completed,tool.requested,tool.started,tool.completedandtool.failedare stored in the parent's session log, in the parent's run. Each gets a new optional fieldparent_call_id, thedelegatecall's id. The protocol minor version rises.- No
message.*events are emitted for a child. Its text is not part of the transcript, and norun.*events either: the child has no run of its own. Its final answer is thedelegatetool's result. - The runner keeps child bookkeeping apart from
_Progress(open message, call index, pending calls), keyed by the parent call id. A child's call index counts the child's calls, and the parent'sMAX_MODEL_CALLScounts only the parent's. - A child's
message_idandmessage_idsname messages in the child's thread, not the parent's. Reading a child call's context (trace.span) reads the thread<session_id>/c/<parent_call_id>. - Child calls carry
cost_usdand usage like any call and roll up into the run. A usage row of a child call has the roleexplore.
- No
Old clients. An event with
parent_call_idmust not be drawn as a top-level step.- The shared reducer in
packages/viewfolds such events under thedelegatestep they belong to (childon the step). Both web and TUI use that reducer. - A client older than the version that adds the field would draw them flat. That is acceptable for one release, because clients and daemon ship together (ADR-020).
- The trace builder nests child spans under the
delegatetool span. The parent's context series (inputSeries) does not include child calls, because they are a different context.
- The shared reducer in
Tools and rules.
- A child's tools are a fixed read-only set:
read_file,list_dir,glob,grep,git_log,git_diff,git_status,read_artifact. These are the registry's names today (READ_ONLY_TOOLSingolem/tools/fs.py, the git tools ingolem/tools/shell.py,golem/tools/artifacts.py). The set is a subset of the parent's scope. No shell, no writes, no web, no MCP, no skills, notodo_write. - A child cannot call
delegate(depth 1). The tool is left out of the child's scope. - A call outside the scope gets the existing "unknown tool" error result, which the child's model can read.
- A child never asks for approval.
tools_nodegets a run flag, set in the graph'sconfigurablelike the permission mode, that turns anaskinto a refused call with a message the model can read (for example "a helper cannot ask for approval: this path needs it"). Thedenyrules of the policy still apply. The child gets none of the session'sallowed_tools, so an allowance the user gave the parent is not extended to it. - The
delegatecall itself is read-only for the permission layer, so it needs no approval. What it returns is data, like any tool result. - Approvals that bubble up are Phase 15 (15.3).
- A child's tools are a fixed read-only set:
Limits.
- Model calls: 15 by default. Past the limit the child makes one last call without tools, asking for the answer from what it knows.
- Wall time: 5 minutes by default.
- Size of the returned answer: 6,000 characters by default, cut.
- Hitting a limit ends the child with what it has. The tool result's first line names the reason:
explorer finished: <reason>when it is notdone. The reasons aredone,calls,time,budget,tokensandcancelled. The limits are the[agents.explorer]settings (#913);budgetis a spent cap in[budget], andtokensis input tokens past 8 times the window.
Cancellation and restart.
- The child runs inside the
delegatetool call, in the parent's run task. Cancelling the parent's run cancels the child with it (ADR-008). Child tool calls still open are failed with the cancel message, like the parent's. Thedelegatecall is then unanswered in the parent's checkpoint, and the existing rule for unanswered calls gives it a cancelled result on the next turn (answer_dangling). - A daemon restart in the middle of a child: the parent's run is closed by recovery (
golem/sessions/recovery.py), its open calls fail, and thedelegatecall is unanswered, so it is reported as cancelled on the next turn. The child's thread stays incheckpoints.dband is not resumed in this step. - An approval in the parent while a child runs cannot happen: the parent waits on the tool.
- The child runs inside the
Model. The
explorerole of ADR-055 (for_roleingolem/models/roles.py). On a local session that is the same model with the same options, so nothing reloads. The gate (ServerGate) serialises parent and child. The parent's model call has ended before the tool runs, so the child's calls take the slot one at a time and do not deadlock. A local-only session stays local.Cost and trace. Child calls carry cost like any call and roll up into the run's totals and the turn's footer. In the trace they are spans under the
delegatetool span: tool span, the child's model spans, their tool spans. A child's model span opens the same detail as any other, with its own context meter against its own window.
Alternatives Considered
Alternative 1: A full child session now
- Pros: matches the vision, resumes after a restart, has its own chat to open.
- Cons: needs headless sessions (4.0), which are not built. It adds a row in
sessions, a list filter, attach rules and cleanup. - Why not: more surface than one read-only helper needs. The child run keeps the door open.
Alternative 2: A separate graph for helpers
- Pros: a loop shaped for the job, with no flags.
- Cons: two loops to maintain: prompts, tools, retries, cancel, usage.
- Why not: the chat graph already does all of it, so one flag and one scope are cheaper.
Alternative 3: Plain function calls with no checkpoint
- Pros: simplest to write.
- Cons: no trace, no cost, and nothing to promote or resume later.
- Why not: the trace and the cost are the point of keeping a helper visible.
Alternative 4: Child events in their own log
- Pros: the parent's log stays small.
- Cons: the parent's trace and its cost need a join, and every reader of the log must know about a second log.
- Why not: one field on events already in the parent's log gives the same grouping with no join.
Consequences
Positive
- The parent's context holds the brief and a short answer, not the files.
- Cost, usage and the trace include a helper with no new store.
- The graph, router and tools are reused, so a helper gets every fix of the chat loop.
- Promoting a child run to a session (#733, 15.2) is a migration: give the thread a session row and move its events. #733 needs no change for that. Its line "its events go to the same log, so a restart resumes it" holds once the child is a session. The wording of 15.2, "a child is a session linked to its parent", is the target of the promotion.
Negative
- No approvals, no writes, no parallel helpers, and a child is not resumed after a restart (Phase 15: 15.3, 15.5, 15.2).
- Child events add to the parent's log. A turn with a helper has more events.
- Child threads stay in
checkpoints.db. A fork copies only the parent's thread, so a forked session has helper events in its log with no thread behind them. Cleanup of child threads is left to Phase 15. - A client older than the field draws child steps flat for one release.
Risks
- A model may delegate when it should not, or never. #914 adds a short prompt line for small windows and measures it.
- A helper's answer is data. A parent that treats it as an instruction would let a read file steer it. The result is marked as the output of a tool, and carries no permission.