Skip to main content

Crate aidaemon_agents

Crate aidaemon_agents 

Source
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 optional context argument. ContextMode::Fork also prepends a parent-transcript summary, which is caller-supplied: a tool cannot read the parent’s transcript from ToolContext, so the summary comes from a construction-time closure (ForkSource). TranscriptTap is 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 from ChildBudget (default max_turns 20).
  • Failures are visible, and the parent decides. A child that ends with anything other than Completed becomes 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 with RunOutcome::tool_results on 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, use run_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 beyond max_depth are 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§

AgentTool
A child Agent exposed as a Tool. Arguments: {task, context?}.
ChildBudget
Per-child hard caps, applied when the child agent is built through AgentTool::from_builder.
TranscriptTap
A hook that records a compact summary of each session’s transcript so a ContextMode::Fork child can see what the parent has been doing.

Enums§

ContextMode
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§

AgentExt
agent.as_tool(name, description).

Functions§

child_session_id
Session id for the child spawned by call_id inside parent_session.
condense
Keep the head and tail of text within max_chars characters (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 of session ({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§

ForkSource
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 returns None when no summary is available.