hashbrown

UseStructuredChatResult

The result object-type returned by the useStructuredChat hook that provides functions and state for interacting with the chat.

UseStructuredChatResult
@typeOutput
@typeTools
Chat.AnyTool
@typeState
error
Error | undefined

The error encountered during chat operations, if any.

exhaustedRetries
boolean

Whether the current request has exhausted retries.

generatingError
Error | undefined

Error emitted during generation events.

isGenerating
boolean

Whether the chat is currently generating.

isLoading
boolean

Aggregate loading flag across transport, generation, and tool calls.

isReceiving
boolean

Whether the chat is receiving a response.

isResuming
boolean

Whether the resumed interaction is still running.

isRunningToolCalls
boolean

Whether the chat is running tool calls.

isSending
boolean

Whether the chat is sending a response.

lastAssistantMessage
Chat.AssistantMessage<Output, Tools> | undefined

The last assistant message.

lastRunFinishReason
FinishReason | undefined

Why 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.

lastRunResult
JsonValue | undefined

The 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.

lastRunUsage
readonly TokenUsage[] | undefined

The 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.

messages
Chat.Message<Output, Tools>[]

An array of chat messages.

pendingConversationRecovery
PendingConversationRecovery | undefined

The inert browser recovery batch awaiting explicit settlement.

pendingInterrupts
PendingInterruptBatch | undefined

The complete pending interrupt batch, including while claimed.

recovery
ConversationRecoveryState

The local recovery revision and whether an explicit restore is required.

reload
() => void

Reload the chat, useful for retrying when an error occurs.

resendMessages
() => void

Function to cause current messages to be resent. Can be used after an error in chat.

sendingError
Error | undefined

Transport/request failure before generation events arrive.

sendMessage
(message: Chat.MessageInput<Output, Tools>) => void

Function to send a new chat message.

setMessages
(messages: Chat.MessageInput<Output, Tools>[]) => void

Function to update the chat messages.

state
State | undefined

The currently visible shared agent state.

stop
(clearStreamingMessage?: boolean) => void

Function to stop the chat.

subagents
readonly SubagentRun[]

Observed native subagent invocations in the current conversation.