Skip to content

TaskResult

TaskResult = object

The response payload for a completed run() execution, for every task kind; output.type tells the content representation apart (text, managed playback, retrievable artifact). A full execution failure (validation, routing, or every attempted provider failing) is surfaced by run() throwing an IndeRunError instead of returning a TaskResult; finishReason and telemetry.errorClass are reserved for a provider reporting a non-fatal, degraded outcome on an otherwise-successful result (finishReason ‘error’ is produced by the Android ML Kit GenAI provider; telemetry.errorClass is not currently set by any provider in this codebase).

[property: string]: unknown

finishReason: FinishReason

How generation ended: ‘stop’ (natural end), ‘length’ (hit maxOutputTokens), or ‘cancelled’. ‘error’ is reserved for a provider reporting a non-fatal issue on an otherwise-returned result — the Android ML Kit GenAI provider produces it when Gemini Nano reports a finish reason that is neither a natural stop nor the token limit. A full execution failure is instead surfaced by run() throwing an IndeRunError.


output: TaskOutput

The normalized output of the selected provider. See task-output.schema.json.


optional provenance?: ExecutionProvenance

Normalized execution provenance: which target ran, its declared locality, the configured and reported model, and how fallback and routing played out. See execution-provenance.schema.json.


runId: string

A unique, opaque identifier assigned by the engine for this specific execution attempt.


schemaVersion: "1.0"

Contract schema version used to interpret the result payload.


telemetry: Telemetry

Required metadata providing an overview of the execution result and performance metrics.


optional usage?: Usage

Optional metadata regarding the quantity of tokens processed by the provider.