hashbrown

ChatRuntime

A stateful client runtime for sending messages, processing AG-UI events, executing tools, and exposing reactive chat state.

API

ChatRuntime
@typeOutput
@typeTools
Chat.AnyTool
@typeState
error
StateSignal<Error | undefined>
exhaustedRetries
StateSignal<boolean>
generatingError
StateSignal<Error | undefined>
isGenerating
StateSignal<boolean>
isLoading
StateSignal<boolean>
isReceiving
StateSignal<boolean>
isResuming
StateSignal<boolean>

Whether the whole resumed interaction is still executing.

isRunningToolCalls
StateSignal<boolean>
isSending
StateSignal<boolean>
lastAssistantMessage
StateSignal<Chat.AssistantMessage<Output, Tools> | undefined>
messages
StateSignal<Chat.Message<Output, Tools>[]>
pendingInterrupts
StateSignal<PendingInterruptBatch | undefined>

The current batch, retained until the server acknowledges resume.

resendMessages
() => void

Resend messages and update state. Often used manually after an error.

sendingError
StateSignal<Error | undefined>
sendMessage
(message: Chat.Message<Output, Tools>) => void

Send a new message to the LLM and update state.

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

Replace the current set of messages in the chat state.

start
() => () => void

Start the runtime effect loop and return a function that disposes it.

state
StateSignal<State | undefined>

The currently visible shared agent state.

stop
(clearStreamingMessage?: boolean) => void

Stop the current LLM interaction.

threadId
StateSignal<string | undefined>

The opaque AG-UI thread identity used by the current and subsequent runs.

updateOptions
(options: Partial<{
        debugName?: string;
        system: string;
        tools: Tools[];
        responseSchema: s.SchemaOutput;
        debounce: number;
        retries: number;
        transport: TransportOrFactory;
        ui?: boolean;
        threadId?: string | undefined;
    }>) => void

Update the chat options after initialization