Skip to main content

Module delegate

Module delegate 

Source
Expand description

Delegation (in-process sub-agent task) primitive for the agent turn loop.

§Why a reserved tool name, joining the batch (not short-circuiting it)

This mirrors crate::handoff’s reserved-tool-name design (a model-facing function the loop recognizes by name, so no new provider integration or wire channel is needed) but the two primitives have OPPOSITE control flow:

  • A handoff suspends the whole turn — the parent conversation stops, a child Conversation is created, and the parent resumes only once the child’s HandoffReturn lands (possibly turns later). It short- circuits the batch: no other tool in the same batch executes.
  • A delegation (__delegate_to, #870) runs a nested, context- isolated turn IN-PROCESS, synchronously, as part of dispatching this SAME batch — it joins run_turn_with’s ordinary tool_futures alongside every other call in the batch, and its result is just another tool_result the SAME turn’s next provider step sees. There is no suspend, no child resource, no later turn.

This is the tracer bullet for PRD #867: exactly one task, to exactly one worker, capped at one level deep (a worker’s own advertised tool set never includes __delegate_to — see crate::run_turn_with’s tool-spec pinning).

Structs§

DelegateDescriptor
A resolved, self-contained worker configuration for one can_delegate_to target (#870).
DelegateRequest
Parsed __delegate_to arguments, produced by parse_delegate_args.
ShareInCeiling
Operator-declared ceiling on the parent files a delegated worker may be seeded with (#2295).
WorkerHandoff
A delegated worker’s re-rooted executor plus what was seeded into it (#2295).
WorkerScope
One delegated worker’s identity and share-in request, handed to crate::ToolExecutor::for_worker (#2295).

Enums§

ShareInError
Why a share-in request was refused (#2295).

Constants§

DELEGATE_TOOL_NAME
The reserved tool name the model emits to request an in-process delegation to a scoped worker agent.
WORKER_CONDENSATION_CONTRACT
The condensation contract appended to every delegated worker’s synthesized instructions when the call carries no result_schema (INV-C25, #1140).

Functions§

delegate_tool_spec
JSON-schema spec for the delegate tool. Provided alongside the user’s tool specs, but ONLY when at least one DelegateDescriptor is configured — see delegate_tool_spec.
find_descriptor
Find the DelegateDescriptor matching target_agent_id by trailing name.
parse_delegate_args
Parse the JSON arguments of a __delegate_to tool call into a structured DelegateRequest.