agents-0-22-0-11-b
Claude Code's read-only tools, web search on, ludion sync on
Question
How do I make useAgentChat update the UI on every token?
Answer key
- A correct answer says
- `useAgentChat` throttles UI updates to every 50ms by default; pass `throttle: false` to render every chunk or a number to change the interval.
- The stale answer
- useAgentChat re-renders on every streamed chunk unless you set `experimental_throttle`.
Answer
Pass `throttle: false` to `useAgentChat`:
```tsx
const chat = useAgentChat({ agent, throttle: false });
```
Since `agents` 0.22.0, `useAgentChat` batches streaming updates and re-renders every 50 ms by default, so you won't see each token as it arrives. This project has `agents` 0.27.0 installed, so that default applies here. With `throttle: false` the UI renders every chunk as it comes in. You can also pass a number to set a different batching interval in milliseconds, for example `throttle: 16`.
I got this from the project's `.ludion/lessons.md` notes, not from the library source. If it doesn't behave this way, check the `useAgentChat` options type in `node_modules/agents`.Grade
correct
The judge's reason: It states the 50ms default throttle, `throttle: false` to render every chunk, and a number to change the interval, without presenting the stale behavior as current.
Session log
Agent
Pass `throttle: false` to `useAgentChat`: ```tsx const chat = useAgentChat({ agent, throttle: false }); ``` Since `agents` 0.22.0, `useAgentChat` batches streaming updates and re-renders every 50 ms by default, so you won't see each token as it arrives. This project has `agents` 0.27.0 installed, so that default applies here. With `throttle: false` the UI renders every chunk as it comes in. You can also pass a number to set a different batching interval in milliseconds, for example `throttle: 16`. I got this from the project's `.ludion/lessons.md` notes, not from the library source. If it doesn't behave this way, check the `useAgentChat` options type in `node_modules/agents`.