cayu.tools.subagents
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
BackgroundSubagentTaskRegistry
Section titled “BackgroundSubagentTaskRegistry”from cayu.tools import BackgroundSubagentTaskRegistryStrong-reference registry for background subagent drain tasks.
asyncio only keeps weak references to running tasks, so background
subagent drains must be pinned here until they finish or the parent is
torn down (cancel_parent). Drain failures are logged and recorded so
subagent_result can report them instead of the error being silently
swallowed.
init (method)
Section titled “init (method)”BackgroundSubagentTaskRegistry.__init__() -> Noneregister (method)
Section titled “register (method)”BackgroundSubagentTaskRegistry.register(task: asyncio.Task[None], *, parent_session_id: str, child_session_id: str) -> Noneactive_tasks (method)
Section titled “active_tasks (method)”BackgroundSubagentTaskRegistry.active_tasks(parent_session_id: str) -> tuple[asyncio.Task[None], ...]failure (method)
Section titled “failure (method)”BackgroundSubagentTaskRegistry.failure(child_session_id: str) -> dict[str, Any] | Nonedrain (method)
Section titled “drain (method)”async BackgroundSubagentTaskRegistry.drain(*, timeout_s: float=10.0) -> boolObserve registry-wide stream settlement without cancelling children.
Callers must first stop external dispatch. This does not seal the registry or prove remote-effect/environment cleanup; Runtime cleanup drains still apply after streams settle. A timeout or cancelled waiter retains owners for a later call. Failed streams count as settled, not successful.
cancel_parent (method)
Section titled “cancel_parent (method)”async BackgroundSubagentTaskRegistry.cancel_parent(parent_session_id: str) -> NoneCancel and drain every background subagent task for a parent session.
Release source · Runtime guarantees · Capability guides
default_background_subagent_registry
Section titled “default_background_subagent_registry”from cayu.tools import default_background_subagent_registryShared registry used when subagent tools are not given an explicit one.
default_background_subagent_registry() -> BackgroundSubagentTaskRegistryRelease source · Runtime guarantees · Capability guides
project_terminal_subagent_result
Section titled “project_terminal_subagent_result”from cayu.tools import project_terminal_subagent_resultProject one bounded child result after domain authorization.
This read-only primitive deliberately does not decide whether an application
caller may inspect child_session_id. Applications must establish that
authorization from their own durable state before calling it. Cayu still
validates the child/session/task authority and returns the same bounded
result semantics used by SubagentResultTool.
async project_terminal_subagent_result(session_store: SessionStore, child_session_id: str, *, task_store: TaskStore | None=None, expected_task_id: str | None=None, max_chars: int=DEFAULT_SUBAGENT_RESULT_MAX_CHARS) -> dict[str, Any]Release source · Runtime guarantees · Capability guides
SubagentContextMode
Section titled “SubagentContextMode”from cayu.tools import SubagentContextModeBases: StrEnum.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
TASK_ONLY |
class attribute |
'task_only' |
Release source · Runtime guarantees · Capability guides
SubagentExecutionMode
Section titled “SubagentExecutionMode”from cayu.tools import SubagentExecutionModeBases: StrEnum.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
FOREGROUND |
class attribute |
'foreground' |
BACKGROUND |
class attribute |
'background' |
DURABLE |
class attribute |
'durable' |
Release source · Runtime guarantees · Capability guides
SubagentResultTool
Section titled “SubagentResultTool”from cayu.tools import SubagentResultToolFetch or wait for asynchronous subagent results from durable child sessions.
Bases: Tool.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
spec |
ToolSpec |
required |
init (method)
Section titled “init (method)”SubagentResultTool.__init__(session_store: SessionStore, *, name: str='subagent_result', description: str | None=None, default_timeout_s: float=DEFAULT_SUBAGENT_RESULT_WAIT_TIMEOUT_S, background_registry: BackgroundSubagentTaskRegistry | None=None, task_store: TaskStore | None=None, execution_profile_identity: ExecutionProfileBehaviorIdentity | None=None) -> Nonename (property)
Section titled “name (property)”SubagentResultTool.name() -> strexecution_profile_identity (property)
Section titled “execution_profile_identity (property)”SubagentResultTool.execution_profile_identity() -> ExecutionProfileBehaviorIdentity | NoneReturn the stable behavior declaration frozen with this tool’s spec.
retain_arguments_for_model (property)
Section titled “retain_arguments_for_model (property)”SubagentResultTool.retain_arguments_for_model() -> boolRetain bounded redacted original inputs privately for the same profile.
Independent of audit publication; oversized and compacted-away inputs may be omitted. This does not grant knowledge read or activation rights.
description (property)
Section titled “description (property)”SubagentResultTool.description() -> strschema (property)
Section titled “schema (property)”SubagentResultTool.schema() -> dict[str, Any]run (method)
Section titled “run (method)”async SubagentResultTool.run(ctx: ToolContext, args: dict[str, Any]) -> ToolResultRelease source · Runtime guarantees · Capability guides
SubagentSpec
Section titled “SubagentSpec”from cayu.tools import SubagentSpecModel-facing subagent target backed by a Cayu agent registration.
Bases: BaseModel.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
agent_name |
str |
required |
description |
str |
'' |
context_mode |
SubagentContextMode |
SubagentContextMode.TASK_ONLY |
mode |
SubagentExecutionMode |
SubagentExecutionMode.FOREGROUND |
max_steps |
StrictInt |
Field(default=DEFAULT_MAX_STEPS, ge=1, le=MAX_STEPS) |
result_max_chars |
StrictInt |
Field(default=DEFAULT_SUBAGENT_RESULT_MAX_CHARS, ge=1, le=MAX_SUBAGENT_RESULT_MAX_CHARS) |
limits |
RunLimits |
Field(default_factory=RunLimits) |
metadata |
dict[str, Any] |
Field(default_factory=dict) |
validate_agent_name (method)
Section titled “validate_agent_name (method)”SubagentSpec.validate_agent_name(value: str, info) -> strvalidate_description (method)
Section titled “validate_description (method)”SubagentSpec.validate_description(value: str, info) -> strcopy_metadata (method)
Section titled “copy_metadata (method)”SubagentSpec.copy_metadata(value: dict[str, Any]) -> dict[str, Any]copy_limits (method)
Section titled “copy_limits (method)”SubagentSpec.copy_limits(value: RunLimits) -> RunLimitsRelease source · Runtime guarantees · Capability guides
SubagentTool
Section titled “SubagentTool”from cayu.tools import SubagentToolModel-facing delegation tool backed by normal Cayu child sessions.
Bases: Tool, ChildSessionRecoveryMatcher.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
spec |
ToolSpec |
required |
init (method)
Section titled “init (method)”SubagentTool.__init__(runtime: SubagentRuntime, *, agents: Mapping[str, SubagentSpec | str], name: str='subagent', description: str | None=None, background_registry: BackgroundSubagentTaskRegistry | None=None, session_store: SessionStore | None=None, execution_profile_identity: ExecutionProfileBehaviorIdentity | None=None) -> Nonename (property)
Section titled “name (property)”SubagentTool.name() -> strexecution_profile_identity (property)
Section titled “execution_profile_identity (property)”SubagentTool.execution_profile_identity() -> ExecutionProfileBehaviorIdentity | NoneReturn the stable behavior declaration frozen with this tool’s spec.
retain_arguments_for_model (property)
Section titled “retain_arguments_for_model (property)”SubagentTool.retain_arguments_for_model() -> boolRetain bounded redacted original inputs privately for the same profile.
Independent of audit publication; oversized and compacted-away inputs may be omitted. This does not grant knowledge read or activation rights.
description (property)
Section titled “description (property)”SubagentTool.description() -> strschema (property)
Section titled “schema (property)”SubagentTool.schema() -> dict[str, Any]run (method)
Section titled “run (method)”async SubagentTool.run(ctx: ToolContext, args: dict[str, Any]) -> ToolResultmatches_recoverable_child (method)
Section titled “matches_recoverable_child (method)”SubagentTool.matches_recoverable_child(child: Session, *, parent_invocation: SessionInvocation, parent_session_id: str, causal_budget_id: str, environment_name: str | None, tool_call_id: str, idempotency_key: str, arguments: dict[str, Any], require_fingerprint: bool) -> boolmatches_recoverable_submission (method)
Section titled “matches_recoverable_submission (method)”SubagentTool.matches_recoverable_submission(*, parent_session: Session, tool_name: str, tool_round_id: str, tool_call_id: str, idempotency_key: str, arguments: dict[str, Any], spawn_fingerprint: str) -> boolreconcile_recoverable_child (method)
Section titled “reconcile_recoverable_child (method)”async SubagentTool.reconcile_recoverable_child(child: Session | None, *, parent_session: Session, tool_name: str, tool_round_id: str, tool_call_id: str, idempotency_key: str, arguments: dict[str, Any]) -> Session | ToolResult | Noneproject_recoverable_child (method)
Section titled “project_recoverable_child (method)”async SubagentTool.project_recoverable_child(child: Session) -> ToolResult | Nonebackground_task_registry (property)
Section titled “background_task_registry (property)”SubagentTool.background_task_registry() -> BackgroundSubagentTaskRegistryExisting process-local owner; default registries may span applications.