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
and a child
Conversationis created. The transfer is one-way: the child’s result never returns to the parent. 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 joinsrun_turn_with’s ordinarytool_futuresalongside every other call in the batch, and its result is just anothertool_resultthe 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§
- Delegate
Descriptor - A resolved, self-contained worker configuration for one
can_delegate_totarget (#870). - Delegate
Request - Parsed
__delegate_toarguments, produced byparse_delegate_args. - Share
InCeiling - Operator-declared ceiling on the parent files a delegated worker may be
seeded with (
#2295). - Worker
Handoff - A delegated worker’s re-rooted executor plus what was seeded into it
(
#2295). - Worker
Scope - One delegated worker’s identity and share-in request, handed to
crate::ToolExecutor::for_worker(#2295).
Enums§
- Share
InError - 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
DelegateDescriptoris configured — seedelegate_tool_spec. - find_
descriptor - Find the
DelegateDescriptormatchingtarget_agent_idby trailing name. - parse_
delegate_ args - Parse the JSON arguments of a
__delegate_totool call into a structuredDelegateRequest.