Skip to main content

invoke_haiku

Function invoke_haiku 

Source
pub async fn invoke_haiku(
    cli_path: &str,
    prompt: &str,
    meta: &HashMap<String, Value>,
    cancel: CancellationToken,
    timeout: Duration,
) -> Result<(String, Option<TokenCounts>), String>
Expand description

Invoke the Claude CLI on AMBIENT_MODEL for one ambient call, within timeout (the purpose’s own, purpose::Purpose::timeout).

cancel is this call’s Ambient Model Call gateway cancellation token — if a newer request for the same (entity, purpose) key is admitted while this one is still running, cancel fires and the child process is killed immediately rather than left to run to completion (and keep burning tokens) only to have its result discarded on arrival.

Returns the response text plus token usage parsed from the CLI’s result stream-json line (same usage shape the main turn pipeline parses — see agents::translator::claude::parse_usage), so ambient calls are never silently excluded from token accounting.