Expand description
§aidaemon-agents (experimental)
Multi-agent composition for aidaemon-core, built only on its public API.
The one pattern supported here is agent-as-tool: a parent agent calls a child agent the way it calls any other tool, the child runs to completion in its own session, and the parent receives a condensed result plus structured evidence (status, turns, per-receipt summary, child run id). Reports from Anthropic (orchestrator + condensed sub-agent results) and Cognition (parallel writers and persona crews diverge) point the same way: delegate bounded tasks, keep one writer, return summaries.
Design points:
- Fresh session per call. The child runs in
{parent_session}/sub/{call_id}(child_session_id), so stores and traces can relate it to the parent without sharing a transcript. - Explicit context.
ContextMode::Brief(default) gives the child only the task and the optionalcontextargument.ContextMode::Forkalso prepends a parent-transcript summary, which is caller-supplied: a tool cannot read the parent’s transcript fromToolContext, so the summary comes from a construction-time closure (ForkSource).TranscriptTapis a ready-made hook that captures one for you. - Budgets roll up. The child’s usage is returned through
ToolOutput::with_usage, which the kernel adds to the parent run, so parent token limits cover delegated work. Per-child caps come fromChildBudget(defaultmax_turns20). - Failures are visible, and the parent decides. A child that ends
with anything other than
Completedbecomes an error result (failed receipt) naming the status. The parent’s run does not fail with it: the parent’s model sees the error and carries on. Read each child’s answer and how it ended withRunOutcome::tool_resultson the parent’s outcome. - Sequential by default. The tool is annotated
ToolAnnotations::WRITE, so two children never run concurrently unless the caller marks them read-only (e.g. research children). A suspending child always runs alone. To run several tasks at once without a model choosing them, userun_all. - No file access of its own. A delegation declares
CallEffects::none: the call itself changes no file; each of the child’s own calls is judged by the child’s hooks. So a parent’s scope guard and approval policy (the SDK preset’s included) neither refuse it nor ask the owner for not declaring paths; an approval mode that asks before every write (ApprovalMode::AllWrites) still asks before a delegation that is not read-only. - Depth guard. Nesting depth is the number of
/sub/segments in the session id; calls beyondmax_depthare refused.
§Synchronous mode and approvals
A child that pauses on a before_tool interrupt is settled inside the
parent’s tool call by the resolver given to
AgentTool::interrupt_resolver, and keeps going. The parent’s tool call
stays open meanwhile, so Limits::tool_timeout on the parent bounds the
wait, and a cancelled parent stops waiting. With no resolver, or when it
leaves the interruption unsettled, the child is reported as an error,
unless the tool suspends.
§Durable mode
With AgentTool::suspend_on_interrupt, a child left interrupted pauses
the parent instead: the parent’s RunStatus::Interrupted carries the
child’s interruption, the child’s whole state is saved in the parent’s
Pending, and the process may exit. Agent::resume on the parent, even
in another process, passes the answer down to the child, and the parent’s
call ends with what the child ends with. A crash after the answer was
given and before the child finished is the crash of any running call: the
delegation is re-run if annotated idempotent and marked indeterminate
otherwise, and nothing the child did is repeated.
Modules§
- specialist
- Specialist profiles: the stable labels a host gives its child agents, so their sessions and events say what kind of work each one does.
Structs§
- Agent
Tool - A child
Agentexposed as aTool. Arguments:{task, context?}. - Child
Budget - Per-child hard caps, applied when the child agent is built through
AgentTool::from_builder. - Transcript
Tap - A hook that records a compact summary of each session’s transcript so a
ContextMode::Forkchild can see what the parent has been doing.
Enums§
- Context
Mode - What the child sees besides the task.
Constants§
- DEFAULT_
MAX_ DEPTH - Default maximum nesting depth (a child of a child of a child).
- DEFAULT_
MAX_ RESULT_ CHARS - Default cap on the condensed child result handed back to the parent.
- SUB_
SEGMENT - The segment that separates a parent session from a child session.
Traits§
- Agent
Ext agent.as_tool(name, description).
Functions§
- child_
session_ id - Session id for the child spawned by
call_idinsideparent_session. - condense
- Keep the head and tail of
textwithinmax_charscharacters (plus a one-line notice). The conclusion of a report is usually at the end and the framing at the start, so both survive. - run_all
- Run each
(agent, task)at the same time, each in its own child session ofsession({session}/sub/job-{n}), and return their outcomes in the order given. For fan-out the application decides, not the model: the runs share nothing and a failed one does not stop the others. - session_
depth - Nesting depth encoded in a session id: the number of
/sub/segments. A top-level session has depth 0. - status_
label - A short machine-derived label for a terminal status.
Type Aliases§
- Fork
Source - Produces a summary of the parent’s transcript for
ContextMode::Fork. It receives the trusted context of the delegating call (session, run and call ids) and returnsNonewhen no summary is available.