The result of the useCompletion hook.
API
interface UseCompletionResult<State = unknown> {error: Error | undefined;exhaustedRetries: boolean;generatingError: Error | undefined;getRecoveryConfiguration(): ConversationRecoveryConfiguration;isGenerating: boolean;isLoading: boolean;isReceiving: boolean;readonly isResuming: boolean;isRunningToolCalls: boolean;isSending: boolean;lastRunFinishReason: FinishReason | undefined;lastRunResult: JsonValue | undefined;lastRunUsage: readonly TokenUsage[] | undefined;output: string | null;readonly pendingConversationRecovery: PendingConversationRecovery | undefined;readonly pendingInterrupts: PendingInterruptBatch | undefined;readonly recovery: ConversationRecoveryState;reload: () => void;restoreConversation(snapshot: ConversationSnapshot<State>, options: ConversationRestoreOptions): void;resume(options: ResumeOptions): void;resumeConversationRecovery(options: ResumeConversationRecoveryOptions): void;sendingError: Error | undefined;setState(state: State): void;readonly state: State | undefined;stop(clearStreamingMessage?: boolean): void;}@typeStateError | undefinedThe error encountered during chat operations, if any.
booleanWhether the current request has exhausted retries.
Error | undefinedError emitted during generation events.
booleanWhether the chat is currently generating.
booleanAggregate loading flag across transport, generation, and tool calls.
booleanWhether the chat is receiving a response.
booleanWhether the whole resumed interaction is executing.
booleanWhether the chat is running tool calls.
booleanWhether the chat is sending a response.
FinishReason | undefinedWhy the model stopped in the last run that completed, such as length
when the answer was cut off by a token limit, or undefined when the
server did not say. Cleared when the next run starts.
JsonValue | undefinedThe return value the agent attached to the last run that completed
(AG-UI's RUN_FINISHED.result), or undefined when it attached none.
Cleared when the next run starts. Interrupted, cancelled, and failed
runs never set it.
readonly TokenUsage[] | undefinedThe token usage of the last run that completed (AG-UI's
RUN_FINISHED.usage), one entry per provider and model, or undefined
when the server reported none. Cleared when the next run starts, so a turn
that calls tools reports only its final run.
string | nullThe output from the model.
PendingConversationRecovery | undefinedThe inert browser recovery batch awaiting explicit settlement.
PendingInterruptBatch | undefinedThe current interrupt batch, retained until resume is acknowledged.
ConversationRecoveryStateThe local recovery revision and whether an explicit restore is required.
() => voidReload the chat, useful for retrying when an error occurs.
Error | undefinedTransport/request failure before generation events arrive.
State | undefinedThe currently visible shared agent state.