Persisted leader/subagent ownership. An explicit ping resumes an independent peer; a managed session stays under its team rule.
Persisted leader/subagent ownership. An explicit ping resumes an independent peer; a managed session stays under its team rule.
(ask env question)(ask env question opts)As a subagent, ask your parent for a decision and wait for the reply text. If only the person can decide, your parent asks the person and you keep waiting. Returns None when the parent stops or does not reply within reply_timeout_s. Use a whole number from 1 to 1800. The default is 600. Then choose the safest option and say so in your answer.
As a subagent, ask your parent for a decision and wait for the reply text. If only the person can decide, your parent asks the person and you keep waiting. Returns None when the parent stops or does not reply within reply_timeout_s. Use a whole number from 1 to 1800. The default is 600. Then choose the safest option and say so in your answer.
(ask-budget env iterations reason)(ask-budget env iterations reason opts)As a subagent, ask your parent for more model iterations and wait for the answer. Ask before your budget ends, with the number that you need and the reason. Returns a dict with granted (0 when the parent refuses), iteration_budget and reply. reply is None when the parent is not running or does not answer within reply_timeout_s. Use a whole number from 1 to 1800. The default is 600.
As a subagent, ask your parent for more model iterations and wait for the answer. Ask before your budget ends, with the number that you need and the reason. Returns a dict with granted (0 when the parent refuses), iteration_budget and reply. reply is None when the parent is not running or does not answer within reply_timeout_s. Use a whole number from 1 to 1800. The default is 600.
(ask-files env files reason)(ask-files env files reason opts)As a subagent, ask your parent for file access and wait for the answer. files holds write, read_only and deny rules: paths or globs, absolute, ~ or relative to the parent's workspace root. Give at least one rule. deny wins over read_only, and read_only wins over write.
Returns a dict with granted, files (your grant now), missing and reply. granted is True only when the grant covers every write rule that you asked for. missing lists the others. reply is None when the parent is not running or does not answer within reply_timeout_s. Use a whole number from 1 to 1800. The default is 600.
After a grant, your Python sandbox restarts before the next block and restores your saved helpers.
As a subagent, ask your parent for file access and wait for the answer. files holds write, read_only and deny rules: paths or globs, absolute, ~ or relative to the parent's workspace root. Give at least one rule. deny wins over read_only, and read_only wins over write. Returns a dict with granted, files (your grant now), missing and reply. granted is True only when the grant covers every write rule that you asked for. missing lists the others. reply is None when the parent is not running or does not answer within reply_timeout_s. Use a whole number from 1 to 1800. The default is 600. After a grant, your Python sandbox restarts before the next block and restores your saved helpers.
(attempt-cancelled? agent)True if the child is cancelled or its current Task has a cancel request.
True if the child is cancelled or its current Task has a cancel request.
(attempt-ended? agent)True if the current attempt of agent ended.
True if the current attempt of `agent` ended.
(changed env)(changed env opts)Return a Task that ends when a child asks a question or requests budget or files.
The result has cursor and requests. Each request has session_id and entry_id.
Omit after to read all open requests. Use the last cursor to wait for new requests.
A request that is open when you start the watch can settle the Task at once.
If another Task wins the wait, reuse the pending watch or cancel it.
Cancelling the watch does not cancel the child.
Return a Task that ends when a child asks a question or requests budget or files. The result has `cursor` and `requests`. Each request has `session_id` and `entry_id`. Omit `after` to read all open requests. Use the last cursor to wait for new requests. A request that is open when you start the watch can settle the Task at once. If another Task wins the wait, reuse the pending watch or cancel it. Cancelling the watch does not cancel the child.
(checkpoint! env messages)Capture the last complete model input, before its in-flight tool call. Never copy runtime handles.
Capture the last complete model input, before its in-flight tool call. Never copy runtime handles.
(claim-iteration! env)Reserve one model iteration. A child budget is durable across replies, turns and restarts.
When the budget ends in a turn, that turn gets one more iteration without a claim for the
handoff of the child. A later claim refuses, and the child becomes budget_limited.
Reserve one model iteration. A child budget is durable across replies, turns and restarts. When the budget ends in a turn, that turn gets one more iteration without a claim for the handoff of the child. A later claim refuses, and the child becomes `budget_limited`.
(context env)(context env {:keys [child routing-locked?]})The agent context of the session of env. facts holds :child and
:routing-locked? when a caller has already read them; else they come from the store.
The agent context of the session of `env`. `facts` holds `:child` and `:routing-locked?` when a caller has already read them; else they come from the store.
(controls? db actor-id target-id)A leader controls its children. A subagent controls only itself.
A leader controls its children. A subagent controls only itself.
(council-inserted! {:keys [thread_id reply_to]})A Council entry was stored: wake the questions that wait on its thread or on the entry that it answers.
A Council entry was stored: wake the questions that wait on its thread or on the entry that it answers.
(deny-agent env session-id reason)Refuse the open budget or file request of a subagent, with a short reason. The child keeps its budget and its files. Returns the record.
Refuse the open budget or file request of a subagent, with a short reason. The child keeps its budget and its files. Returns the record.
(dependency-changes children)The status changes of the waiting and blocked tasks among children, the rows of one parent,
as [child status] pairs in task order. A change counts for later tasks: a blocked task blocks
the tasks after it, and a task that starts makes them wait.
The status changes of the waiting and blocked tasks among `children`, the rows of one parent, as `[child status]` pairs in task order. A change counts for later tasks: a blocked task blocks the tasks after it, and a task that starts makes them wait.
(dependency-status deps)The status of a task that did not start yet, from the rows of the tasks in its after: queued when all of them completed, blocked when one ended without completion or is missing, else waiting.
The status of a task that did not start yet, from the rows of the tasks in its after: queued when all of them completed, blocked when one ended without completion or is missing, else waiting.
(enabled? db sid)Whether session sid can use managed subagents. A new session starts without the session
settings of its source, so a managed child reads the setting of its leader. Without such a
session setting, or with an invocation value, the configuration decides. Subagents run on
Council messages, so they are off while Council is off.
Whether session `sid` can use managed subagents. A new session starts without the session settings of its source, so a managed child reads the setting of its leader. Without such a session setting, or with an invocation value, the configuration decides. Subagents run on Council messages, so they are off while Council is off.
(extend-agent env session-id iterations)Give a subagent more model iterations. Use it to answer a budget request (status asking with budget_request), or before a follow-up ping to a budget_limited child. A budget has no upper limit. Returns the record.
Give a subagent more model iterations. Use it to answer a budget request (status asking with budget_request), or before a follow-up ping to a budget_limited child. A budget has no upper limit. Returns the record.
(finish! db sid status)Store the status of a finished child turn. A child that ended its turn in its handoff
iteration becomes budget_limited, so its parent knows that it needs council.extend before
a follow-up ping. A child that answered within its budget is completed. The first end of a task
stores finished_at, and a task without council.result gets the first line of its answer.
Store the status of a finished child turn. A child that ended its turn in its handoff iteration becomes `budget_limited`, so its parent knows that it needs council.extend before a follow-up ping. A child that answered within its budget is `completed`. The first end of a task stores `finished_at`, and a task without council.result gets the first line of its answer.
(follow-up-refusal db author-id target-id)The refusal of a ping from author-id to its idle child target-id, as [error message], or
nil. A ping from the parent or the leader gives an idle child a follow-up task. The child
needs iterations left. A cancelled child also needs a running turn of its leader. So a late
ping cannot restart a child that the user stopped.
The refusal of a ping from `author-id` to its idle child `target-id`, as `[error message]`, or nil. A ping from the parent or the leader gives an idle child a follow-up task. The child needs iterations left. A cancelled child also needs a running turn of its leader. So a late ping cannot restart a child that the user stopped.
(grant-files env session-id files)Add file rules to the grant of a subagent. Use it to answer a file request (status asking with
files_request). To start a follow-up attempt with a different grant, pass files to council.run.
See doc("council.run").
files holds write, read_only and deny rules, like a task dict. Give at least one rule. deny wins over read_only, and read_only wins over write.
Returns the record. Its warning names write rules that changed nothing and active siblings that can write the same files.
A grant gives at most your own access. A write rule outside your writable roots or under your deny rules fails, and your deny rules stay closed to the child. A write rule under a read_only or deny rule of the child fails too. A child without write rules already writes where you write, so a write grant changes nothing for it. The child gets the new access at its next block.
Add file rules to the grant of a subagent. Use it to answer a file request (status asking with
`files_request`). To start a follow-up attempt with a different grant, pass `files` to `council.run`.
See `doc("council.run")`.
files holds write, read_only and deny rules, like a task dict. Give at least one rule. deny wins
over read_only, and read_only wins over write.
Returns the record. Its warning names write rules that changed nothing and active siblings that
can write the same files.
A grant gives at most your own access. A write rule outside your writable roots or under your
deny rules fails, and your deny rules stay closed to the child. A write rule under a read_only or
deny rule of the child fails too. A child without write rules already writes where you write, so
a write grant changes nothing for it. The child gets the new access at its next block.(handoff messages model)The model input that a new child inherits from its parent, or nil when the parent has none. It keeps the system messages without the session block of the parent, because the child gets its own, and without the prompt parts that are for a leader only. Then it adds one message with a short tail of the parent conversation. It never sends tool calls, tool results, reasoning or images. The metadata holds one content-free Svar estimate of this prefix, before the child context and the task.
The model input that a new child inherits from its parent, or nil when the parent has none. It keeps the system messages without the session block of the parent, because the child gets its own, and without the prompt parts that are for a leader only. Then it adds one message with a short tail of the parent conversation. It never sends tool calls, tool results, reasoning or images. The metadata holds one content-free Svar estimate of this prefix, before the child context and the task.
(handoff-estimates checkpoint)The estimate captured when this child was created, or nil for an older child.
The estimate captured when this child was created, or nil for an older child.
(interactive? env)True when a person can answer in the session of env. A one-shot :cli run has nobody to
answer or approve.
True when a person can answer in the session of `env`. A one-shot `:cli` run has nobody to answer or approve.
(latest-note db row now)The newest progress note of child row in its current task, clipped, or nil. The leader reads
the same notes when it waits, and the team rows show the newest one.
The newest progress note of child `row` in its current task, clipped, or nil. The leader reads the same notes when it waits, and the team rows show the newest one.
(leader-id db sid)The leader of session sid as a string: the team leader for a subagent, else sid.
The leader of session `sid` as a string: the team leader for a subagent, else `sid`.
(model-settings db sid)The subagent model settings where session sid runs now: {:models [pair]}. :models keeps
the order of the setting, so its first pair is the default model. An empty setting gives [].
The subagent model settings where session `sid` runs now: `{:models [pair]}`. `:models` keeps
the order of the setting, so its first pair is the default model. An empty setting gives `[]`.(open-questions db sid)The open questions that the children of session sid wait on, as {:session_id child :entry_id id} rows. A child asks its own parent, so the row of a deleted child stays out.
The open questions that the children of session `sid` wait on, as `{:session_id child
:entry_id id}` rows. A child asks its own parent, so the row of a deleted child stays out.(open-request sid)The open question that child sid waits on its parent to answer, or nil: {:question text :entry_id id}, plus :budget or :files for a budget or file request.
The open question that child `sid` waits on its parent to answer, or nil: `{:question text
:entry_id id}`, plus `:budget` or `:files` for a budget or file request.(operation! env operation opts)Run one managed-subagent operation for the calling session and answer its plain result.
Gateway routes and extensions call this entry point; model tools call the same functions.
operation is :spawn, :route, :run, :extend, :deny, :answer,
:grant or :timeline. Records answer in their wire form.
Run one managed-subagent operation for the calling session and answer its plain result. Gateway routes and extensions call this entry point; model tools call the same functions. `operation` is :spawn, :route, :run, :extend, :deny, :answer, :grant or :timeline. Records answer in their wire form.
(person-answers? db sid)True when a person answers the questions of session sid. A managed subagent has no
person: its leader answers its questions and decides its grants.
True when a person answers the questions of session `sid`. A managed subagent has no person: its leader answers its questions and decides its grants.
(prepare-run! env tasks)Validate the batch before the runtime reserves any children.
Validate the batch before the runtime reserves any children.
(prompt-cache-key environment)The provider prompt-cache key of environment: a short hash of its workspace root.
Sessions of one workspace share the core and project prefix. A new session and a
subagent then reach the warm cache of earlier requests. Without a workspace root, the
leader id keeps one key for each team. The raw path never leaves the host.
The provider prompt-cache key of `environment`: a short hash of its workspace root. Sessions of one workspace share the core and project prefix. A new session and a subagent then reach the warm cache of earlier requests. Without a workspace root, the leader id keeps one key for each team. The raw path never leaves the host.
(publish-warning env opts)A short warning when Council publication opts of the caller pings a child with write rules
while a verify or audit child of the same leader is queued or running, else nil. New edits then
change the files that the verifier checks.
A short warning when Council publication `opts` of the caller pings a child with write rules while a verify or audit child of the same leader is queued or running, else nil. New edits then change the files that the verifier checks.
(publish-with-files! env opts publish!)Publish Council entry opts with publish!, a function of the opts. With :files, the one
ping recipient must be an idle subagent of the caller. Its grant then changes before the wake,
so its follow-up task starts in that scope (#414). A failed publication or an unavailable reply
restores the old grant. A task id such as a2 in ping names that child.
Publish Council entry `opts` with `publish!`, a function of the opts. With `:files`, the one ping recipient must be an idle subagent of the caller. Its grant then changes before the wake, so its follow-up task starts in that scope (#414). A failed publication or an unavailable reply restores the old grant. A task id such as a2 in ping names that child.
(queue-turn! db sid)Queue subagent sid for a follow-up turn. A Council ping from its parent uses it, so
a new attempt does not change the record of the previous one. An ordinary ping can pass the active cap; only
a new spawn counts against it. Answers a function that undoes the change, or nil when the child
has no iterations left, or is cancelled while its leader runs no turn. A child that already runs
stays as is.
Queue subagent `sid` for a follow-up turn. A Council ping from its parent uses it, so a new attempt does not change the record of the previous one. An ordinary ping can pass the active cap; only a new spawn counts against it. Answers a function that undoes the change, or nil when the child has no iterations left, or is cancelled while its leader runs no turn. A child that already runs stays as is.
(reconcile-child! db row)Store the end of open child row that has no live turn, and return the stored row. A finished
last turn gives its status. A missing or unfinished turn fails the child.
Store the end of open child `row` that has no live turn, and return the stored row. A finished last turn gives its status. A missing or unfinished turn fails the child.
(reconcile-orphans! db live-sids)Fail the children that a dead process left queued or running. Spare a child or a leader
that live-sids names: a live process still owns that team. Returns the count.
Fail the children that a dead process left queued or running. Spare a child or a leader that `live-sids` names: a live process still owns that team. Returns the count.
(refusal-answer env report)The answer of a child turn that claim-iteration! stopped: the stop reason, then the last
report of the turn. Without a report, it names where the parent can read the work.
The answer of a child turn that `claim-iteration!` stopped: the stop reason, then the last report of the turn. Without a report, it names where the parent can read the work.
(register-task! env row cancel! admit)Register this attempt before admitting its child turn.
Register this attempt before admitting its child turn.
(report-result env text)(report-result env text opts)As a subagent, report the result of your task in one line, before your final answer. An example is "All 42 tests pass". text is one line of at most 200 characters. As a verifier, also give outcome "passed" or "failed". A later call replaces the line.
As a subagent, report the result of your task in one line, before your final answer. An example is "All 42 tests pass". text is one line of at most 200 characters. As a verifier, also give outcome "passed" or "failed". A later call replaces the line.
(require-enabled! db sid)Refuse new managed work before bootstrapping a session or consuming a checkpoint.
Refuse new managed work before bootstrapping a session or consuming a checkpoint.
(resolve-child db actor-id ref)The session id that child reference ref names for session actor-id. A task id such as a2
or A2 names a child of the actor, or a sibling for a subagent. A marked session id loses its
mark. Another value, or a task id that no child has, answers as [[child-ref]].
The session id that child reference `ref` names for session `actor-id`. A task id such as a2 or A2 names a child of the actor, or a sibling for a subagent. A marked session id loses its mark. Another value, or a task id that no child has, answers as [[child-ref]].
(restrict-router env router)Apply the routing limits of a subagent to every request and retry, including automatic fallback. The fallback model of the child comes first in automatic fallback, and an inherited allowlist narrows the providers. A 429 ends the request at once, without a wait: it goes to the fallback model of the child, else the parent chooses the next route from the child record.
Apply the routing limits of a subagent to every request and retry, including automatic fallback. The fallback model of the child comes first in automatic fallback, and an inherited allowlist narrows the providers. A 429 ends the request at once, without a wait: it goes to the fallback model of the child, else the parent chooses the next route from the child record.
The subagent roles of the agents contract, in its order: const, title and description.
A role is a label. It sets no tool, file or model limit.
The subagent roles of the agents contract, in its order: `const`, `title` and `description`. A role is a label. It sets no tool, file or model limit.
(routing-change env before)The route command issued for this session since before, as
{:preference {:provider :model} :command command}, or nil. Agent routing and the
engine's authentication rescue issue commands; a manual pick is composer state that
the next submitted turn snapshots, so it never re-routes a running turn.
The route command issued for this session since `before`, as
`{:preference {:provider :model} :command command}`, or nil. Agent routing and the
engine's authentication rescue issue commands; a manual pick is composer state that
the next submitted turn snapshots, so it never re-routes a running turn.(routing-view db sid)The subagent model settings of session sid as session["routing"]["subagents"] shows
them in the sandbox: models is a list of providers and models, where the first is the default
and an empty list allows every model.
The subagent model settings of session `sid` as `session["routing"]["subagents"]` shows them in the sandbox: `models` is a list of providers and models, where the first is the default and an empty list allows every model.
(run env tasks)Use children = await council.run(tasks) to get the SubagentTasks in input order. An attempt can
wait for capacity or a dependency. Only a leader can start subagents. Children share the checkout.
A child gets a short tail of your requests, fold gists and answers, never your tool calls or
output: put every fact that the task needs in the task.
Check every verifier failure before you finish. Give an implementer all findings after the
checks end, then start a follow-up for the verifier. For rate_limited, start the work on a
route from alternatives. For budget_limited, read the answer before you start a follow-up.
To wait for open requests, use council.changed() with the child Tasks and asyncio.wait.
A task is a string or a dict with task and optional title, role, model, provider,
iteration_budget, files, after and child. A title has at most 60 characters. The iteration
budget defaults to 120. Set model and provider together.
Use await child for the final record. If the wait returns child with a question open, answer
the request before you await it again. If a question is already open, the await can return at once.
child.record() reads the current record. await asyncio.wait([child], timeout=seconds) waits
without cancelling; then read child.record(). child.cancel() requests cancellation of this
attempt only.
Awaiting a cancelled attempt raises asyncio.CancelledError.
child.id is the child ID (a1, a2, ...). child.session_id is the child session ID.
child.task_id identifies this attempt. In after, use a handle, a child ID, or a session ID.
Each dependency must be an existing child or an earlier task in the batch. A failed dependency
blocks the task.
In files, write, read_only and deny are lists of paths or globs. To give the same child
more work, use await council.run([{"child": child, "task": "Fix X", "files": {...}}]).
With child, give only task, child, and optional files.
The new attempt has a separate handle. Its files apply to that attempt only. Without files,
the child uses its original grant. A budget-limited attempt has ended. Use await council.extend(...)
before you start a new attempt.
Use `children = await council.run(tasks)` to get the SubagentTasks in input order. An attempt can
wait for capacity or a dependency. Only a leader can start subagents. Children share the checkout.
A child gets a short tail of your requests, fold gists and answers, never your tool calls or
output: put every fact that the task needs in the task.
Check every verifier failure before you finish. Give an implementer all findings after the
checks end, then start a follow-up for the verifier. For `rate_limited`, start the work on a
route from `alternatives`. For `budget_limited`, read the answer before you start a follow-up.
To wait for open requests, use `council.changed()` with the child Tasks and `asyncio.wait`.
A task is a string or a dict with `task` and optional `title`, `role`, `model`, `provider`,
`iteration_budget`, `files`, `after` and `child`. A title has at most 60 characters. The iteration
budget defaults to 120. Set `model` and `provider` together.
Use `await child` for the final record. If the wait returns `child` with a question open, answer
the request before you await it again. If a question is already open, the await can return at once.
`child.record()` reads the current record. `await asyncio.wait([child], timeout=seconds)` waits
without cancelling; then read `child.record()`. `child.cancel()` requests cancellation of this
attempt only.
Awaiting a cancelled attempt raises `asyncio.CancelledError`.
`child.id` is the child ID (a1, a2, ...). `child.session_id` is the child session ID.
`child.task_id` identifies this attempt. In `after`, use a handle, a child ID, or a session ID.
Each dependency must be an existing child or an earlier task in the batch. A failed dependency
blocks the task.
In `files`, `write`, `read_only` and `deny` are lists of paths or globs. To give the same child
more work, use `await council.run([{"child": child, "task": "Fix X", "files": {...}}])`.
With `child`, give only `task`, `child`, and optional `files`.
The new attempt has a separate handle. Its `files` apply to that attempt only. Without `files`,
the child uses its original grant. A budget-limited attempt has ended. Use `await council.extend(...)`
before you start a new attempt.(runtime-op! env operation opts)Validate opts and run one gateway runtime operation: :spawn, :cancel, :route or :grant.
Validate `opts` and run one gateway runtime operation: :spawn, :cancel, :route or :grant.
(settle-task! env row)Save the terminal record before another attempt can change this child's stored state.
Save the terminal record before another attempt can change this child's stored state.
(signal! k)Wake each wait on key k: [:team leader] or [:thread entry-id].
Wake each wait on key `k`: `[:team leader]` or `[:thread entry-id]`.
(stable-prefix env session-context)(stable-prefix env session-context subagent-message)The stable prompt prefix of a child: the parent handoff, then the child's own session block.
Each request of the child starts with it, also after a fold or in a later turn. Nil for a leader.
subagent-message is a system message that the parent did not have, or nil. It goes after
the system messages of the handoff.
The stable prompt prefix of a child: the parent handoff, then the child's own session block. Each request of the child starts with it, also after a fold or in a later turn. Nil for a leader. `subagent-message` is a system message that the parent did not have, or nil. It goes after the system messages of the handoff.
(stop-reason env)Give the cause when claim-iteration! refuses the child session of env.
Give the cause when `claim-iteration!` refuses the child session of `env`.
(task-ordinal id)The ordinal of task id id, such as 2 for a2 or A2, or nil for another value.
The ordinal of task id `id`, such as 2 for a2 or A2, or nil for another value.
(task-record env row)Read a child snapshot without changing its state or consuming progress.
Read a child snapshot without changing its state or consuming progress.
(task-request db sid entry)The trusted request of a Council wake from the parent of managed child sid, or nil for another
author. The final answer holds the evidence. The reply only closes the request.
The trusted request of a Council wake from the parent of managed child `sid`, or nil for another author. The final answer holds the evidence. The reply only closes the request.
(timeline db sid child-id)The steps of child child-id of session sid, oldest first: the start of each child turn, its
progress notes, its Council messages and the end of its current task with its result. Copied
turns of the fork are older than the child, so they never count.
The steps of child `child-id` of session `sid`, oldest first: the start of each child turn, its progress notes, its Council messages and the end of its current task with its result. Copied turns of the fork are older than the child, so they never count.
(wake-allowed? db author-id recipient-id)Automatic resume has two sources: an explicit ping between independent sessions, and a managed team. A child may return to its leader; siblings must share a task team. A managed session keeps its team rule, so an exhausted subagent stays idle. A cancelled subagent wakes only for a running turn of its leader. Only a managed subagent wakes itself; an independent session stays idle.
Automatic resume has two sources: an explicit ping between independent sessions, and a managed team. A child may return to its leader; siblings must share a task team. A managed session keeps its team rule, so an exhausted subagent stays idle. A cancelled subagent wakes only for a running turn of its leader. Only a managed subagent wakes itself; an independent session stays idle.
(watch-requests! owner after)Observe committed child requests newer than after, or all open requests when it is nil.
Observe committed child requests newer than `after`, or all open requests when it is nil.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |