useAssistant.
Import
Usage
Options
| Option | Type | Required | Description |
|---|---|---|---|
messages | Message[] | Yes | Messages from the assistant |
onAction | (action: ToolAction) => void | Yes | Called for each action |
How It Works
- Watches
messagesfor new tool invocations - Filters for
performActionstool calls with state"result" - Extracts the action from the result
- Calls
onActionwith the extracted action
When to Use
Usually you don’t need this directly—useAssistant handles it. Use it when:
- Building a custom assistant implementation
- Need finer control over action execution timing
- Processing messages from a different source
Example
Related
- useDynamicUIToolExecution — Similar hook for dynamic UI operations
- useAssistant — Main hook that uses this internally