Skip to main content

Module call

Module call 

Source
Expand description

The one path every ambient Haiku call takes: admit through the gateway, optionally wait for a concurrency permit, do the caller’s own preparation, then run the CLI and judge the reply.

ⓘ
let slot = call::admit(&purpose::ACTIVITY_SUMMARY, block_id, generation).await?;
// ... read the block, build the prompt (slot.is_superseded() is available) ...
let reply = slot.run(&target, &prompt, |raw| reply::judge_line(raw, |t| validate::accept_line(t, &limits))).await;

The slot holds the gateway guard and the permit, so every return path (including an early ? while preparing) releases both, and a newer request for the same key still cancels this one’s CLI. Every admitted call ends in exactly one recorded outcome, taken from the judge’s Verdict.

Structs§

CliTarget
Which CLI to run, and the block meta carrying its auth env (cmd:env).
Reply
What a call produced. text is already judged: empty means there is nothing to use (the model skipped, the reply was refused, or the call failed or was superseded). tokens is reported whenever the CLI reported usage, including when the text is withheld, because the spend happened either way.
Slot
An admitted call. Dropping it (any path) releases the gateway entry and the permit.

Functions§

admit
Admit a call for purpose on entity_id at generation, in the purpose’s own class (limits); None if it is stale on arrival, or was superseded while queued. It waits for a permit raced against cancellation, so a request superseded in the queue never spawns a CLI at all.
admit_as
admit in a class the caller chooses, for the naming calls: interactive for a subagent that just started or a row the user opened, background for the backlog pass over historical ones. With no queue limit: a name arrives as a subagent:named event, not as an RPC reply someone stops waiting for, and an eager name is claimed once (naming_triggered), so one that gave up in the queue would never come.
admit_with_limit 🔒