* docs(kanban): correct the delegate_task comparison table The table described delegate_task as a blocking call with no resume, no human control and no audit trail. Top-level calls return a handle and deliver the result as a later message; a finished or stopped child can be continued; a running child can be steered or stopped; each child's transcript is a stored session under the parent's. The Kanban column overstated three things: a creating chat is subscribed to completion and block events by default, a dispatched worker can change only its own card, and `hermes kanban gc` prunes old events of done and archived tasks. * docs(delegation): describe delegate_task as the code runs it Corrections found by checking each statement on the delegation pages against the source: - Nesting is decided from depth. delegate_task has no role parameter; a passed role is accepted and ignored. The background parameter is deprecated and ignored. - Top-level calls are backgrounded only where the session can receive a later message. One-shot runs, cron jobs, Kanban workers, stateless API requests, inline gateway chats and a full pool join in the call. - The blocked tools are delegate_task, clarify, memory, send_message and cronjob_manage. execute_code is not blocked. - A background process survives its session only with persist_on_release=true, and never a gateway or host shutdown. - A crashed or restarted child resumes when delegation.auto_resume is on, and stays continuable for delegation.resumable_ttl_hours. - The schema retry appends the output contract again. Subagent context files use the flat 20,000 character cap. - Routing: native-SDK providers ignore base_url precedence, a provider default model applies before the parent's, max output tokens are not carried, and /review follows the delegation section by default. - Failure line, status values, diagnostic dump name and contents, /agents rows, the steer delivery point, live transcript fidelity, Slack's notice default and the worktree archive step now match the strings and behaviour in the code. * docs(config): delegation defaults and limits match the code - max_concurrent_children defaults to 10, not 3. - delegation.max_iterations defaults to 250, not 50. - max_spawn_depth has a floor of 1 and no ceiling. - DELEGATION_MAX_CONCURRENT_CHILDREN is read only when the config key is null; the shipped default otherwise wins. - An omitted delegation.api_key inherits the parent's key or uses the named provider's own key. OPENAI_API_KEY is not read. - A task's context rides the child's first user message, not its system prompt. - role="orchestrator" is gone from the delegation section. * docs(delegation): state when the concurrency env var is read DELEGATION_MAX_CONCURRENT_CHILDREN is read whenever no config value is loaded: under --ignore-user-config or --safe-mode, and with the key set to null. The previous commit named only the null case. The Delegation page no longer offers the variable as a way to configure the limit. * docs(kanban): say which chats are subscribed on create Only a session with a delivery channel is subscribed to a task it creates: a gateway chat, or a TUI or Desktop session. A classic CLI run, a cron job or a scripted create is not, and kanban_create reports it in the result's subscribed flag.
4.4 KiB
title, sidebar_label
| title | sidebar_label |
|---|---|
| Public Subagent Lifecycle API | Subagent lifecycle API |
Public Subagent Lifecycle API
Plugins can launch and supervise fresh Hermes child sessions without importing
tools.delegate_tool, gateway internals, TUI state, or AIAgent fields.
The service resolves its parent from the current agent turn, so it works in
CLI, gateway, non-interactive, and kanban-worker sessions. Launching outside an
active agent turn fails closed with No active Hermes parent session.
The facade also works when a plugin runs under plugins.isolation: host.
Requests accept goal, context, role, model, provider, allowed_toolsets,
blocked_tools, working_directory, parent_session_id, correlation_id,
metadata, and timeout_seconds, subject to the restrictions below.
from agent.subagent_lifecycle import SubagentLaunchRequest
def launch_review(ctx):
# Call from a plugin tool or hook while an agent turn is active.
service = ctx.subagent_lifecycle
handle = service.launch(SubagentLaunchRequest(
goal="Review this change for regressions.",
context="Only inspect the supplied repository.",
role="leaf",
correlation_id="review-42",
allowed_toolsets=("file",),
))
# Persist handle.to_dict() if desired.
if service.wait(handle, timeout_seconds=2).timed_out:
return handle.to_dict()
return service.result(handle)
SubagentHandle is serializable and carries a versioned, opaque capability.
Requests and handles may also arrive as mappings, including plugin-host wire records.
Pass a handle back to status, wait, cancel, steer, result, or reconnect; malformed
or forged handles return UNKNOWN/UNKNOWN_HANDLE and cannot access a child.
steer(handle, text) queues text for the child's next iteration boundary and
returns True while the child accepts steering. It returns False for empty
text, unknown or forged handles, handles owned by another parent session, or a
child that has finished or stopped accepting steering.
The stable states are PENDING, STARTING, RUNNING, SUCCEEDED, FAILED,
INTERRUPTED, CANCEL_REQUESTED, CANCELLED, and UNKNOWN.
cancel(handle, reason=...) is cooperative: it asks the child agent to
interrupt at its next safe boundary and returns CANCEL_REQUESTED; it never
claims completion until wait or result observes a terminal state. Terminal
results are immutable, idempotent, bounded to 32k characters, omit transcripts
and hidden reasoning, and include a stable result hash.
This API is lifecycle-managed asynchronous execution. Child construction and
completion use the same host-owned path as delegate_task, including parent
tool-resolution restoration, memory notification, serialized subagent_stop
hooks, resource cleanup, and child-cost rollup. It does not change the
delegate_task tool, batch delegation, or its gateway/TUI display.
The initial implementation retains metadata and terminal results in-process for
one hour.
After a process restart, reconnect returns RECONNECT_UNAVAILABLE and never
starts a replacement child. Running Python threads also cannot survive process
exit; callers must treat those handles as interrupted by process exit.
Requests are fail-closed: goal/context/metadata sizes are capped, unknown or
parent-broadening toolsets are rejected (plugin-registered toolsets count as
known), and per-tool blocks, working-directory overrides, and per-launch
timeouts are explicitly rejected until Hermes can
support them without weakening isolation. Use allowed_toolsets to narrow a
child; Hermes's existing unsafe-tool block remains enforced.
Routing
Children follow the delegation config (provider, model, base_url,
api_key, api_mode, request_overrides) exactly as delegate_task children do.
The request's model overrides the configured model. Its optional provider
names a configured provider for this launch, with precedence request >
delegation config > parent; the selected provider supplies its own credential
bundle. An unresolvable provider raises SubagentLifecycleError before launch.
Core does not expose provider to the model: the plugin chooses it, for example
from operator config.
The lifecycle API does not consult delegation.backend: the plugin that launches a child already chooses
its route. To change how delegate_task routes the model's subagents, write a
delegation provider plugin.