Skip to main content

Module deliver

Module deliver 

Source
Expand description

agents queue deliver — wake every queue-pending target in the caller’s subtree.

Targets come from db::message_queue::list_delivery_targets, in two kinds: AIHs with active queued prompts (direct rows + rows parked against BOUND tags, resolved; deduped, caller itself excluded), and un-upgraded (GROUPED) tags whose group parent sits in the subtree. Per target, the matching lock (crate::command::agents::locks) is try-acquired with no waiting:

  • lock held by a live owner → AgentActive {aih} / TagActive {tag} — the agent is already running (or the tag is already being materialized) and will drain its own queue;
  • lock won → AgentSpawned {aih} / TagSpawned {tag}, then the SAME spawn machinery agents spawn / agents message use (spawn::run_multi_pass, empty messages; AIHs resume via the stored continuation, tags spawn fresh from the group’s stored agent spec with the tag threaded into the conduit upgrade) streams the agent’s output as Value {aih, value} envelopes. An AIH claim is preseeded into the run’s [AgentInstanceRegistry], so the lock is released the moment THAT task’s stream ends — never held for the slowest. A tag claim goes in via hold_tag_claim: released as soon as the spawn claims its minted AIH lock (first chunk, just before the Id first item), held to stream end otherwise. For tag spawns the minted AIH isn’t known up front — it arrives as the FIRST inner item (the spawn Id), which also keys the Value envelopes.

Each per-target stream’s FIRST item is always its resolution (AgentActive / AgentSpawned / TagActive / TagSpawned / a setup Err); once every target has resolved, the bare string "AllAgentsActive" is emitted mid-stream and spawn output keeps flowing after it.

Mode split on dangerous_advanced.stream_spawns (mirrors agents spawn’s stream): unset/false re-execs this binary as a DETACHED ORPHAN with stream_spawns=true and yields the child’s status items (spawn Value output is skipped) up to and including AllAgentsActive, then returns — the orphan keeps running the spawns to completion.

Modules§

request_schema
response_schema

Functions§

execute