Overview
Returns a function to send model context updates to the host. UnlikeuseAppState (which automatically syncs structured state), this hook gives direct control over when and what is sent to the model context — including text content blocks.
Each call overwrites the previous context. The host includes the last update in the model’s next turn.
Import
Signature
UpdateModelContextParams
Array of content blocks to include in model context.
Structured data to include in model context. Serialized as JSON.
Returns
Function to push context updates to the host. Each call replaces the previous context.
Usage
Structured Content
Text Content
Comparison with useAppState
| Feature | useAppState | useUpdateModelContext |
|---|---|---|
| Automatic sync | Yes — syncs on every state change | No — you call it explicitly |
| Content types | Structured data only | Text blocks + structured data |
| State management | Built-in (like useState) | Bring your own |
| Use case | Simple persistent state | Custom sync logic, text content |
See Also
useAppState
Automatic state persistence and sync.