executeWithTrackedPromptExecutor

abstract suspend fun <T> executeWithTrackedPromptExecutor(name: String, retryPolicy: RetryPolicy? = null, execute: suspend CapturingPromptExecutor.() -> T): Result<T>

Helper function that creates a consumption-capturing executor, runs execute with it, records the result as a PromptExecutionRecord, and recomputes metrics. Notice that this function only produces one record, so you should only make a single LLM call inside the execute block.

Transient-failure retries are applied automatically per the session's retry configuration — each call returns with either a successful result or a non-transient failure (the inner retry layer has already absorbed transient blips). Per-attempt detail for retried operations lives in the resulting record's previousAttempts.

Generally, it's better to use more clean variants like executePrompt or executePromptStructured.

Parameters

retryPolicy

override for the session-default retry policy. null (default) = use the session-resolved policy. RetryPolicy.None = disable transient retries for this call (useful in tests or where deterministic single-attempt behavior is required).