Runtime Hooks
Hook for accessing message part state within parts.
useAui (Message Part Actions)
Access message part actions via useAui:
import { useAui } from "@assistant-ui/react";
const aui = useAui();
// Add a tool result to a tool-call message part
aui.part().addToolResult({ result: "Tool output" });
// Resume an interrupted tool call
aui.part().resumeToolCall({ approved: true });MessagePartRuntimeaddToolResult: (result: any) => voidresumeToolCall: (payload: unknown) => voidpath: MessagePartRuntimePathgetState: () => MessagePartStatesubscribe: (callback: () => void) => UnsubscribeuseAuiState (Message Part State)
Access the message part state reactively:
import { useAuiState } from "@assistant-ui/react";
const status = useAuiState((s) => s.part.status);
const type = useAuiState((s) => s.part.type);For imperative access, use useAui:
import { useAui } from "@assistant-ui/react";
const aui = useAui();
const partState = aui.part().getState();TextMessagePartStatetype: "text"text: stringparentId?: stringstatus: { readonly type: "running"; } | { readonly type: "complete"; } | { readonly type: "incomplete"; readonly reason: "length" | "cancelled" | "content-filter" | "other" | "error"; readonly error?: unknown; } | { readonly type: "requires-action"; readonly reason: "interrupt"; }