Non-streaming chat feels slow (~6s for tool-using turns). Streaming makes the agent feel alive on stage.
Plan
- Switch `/api/chat/route.ts` to return a `ReadableStream` instead of JSON.
- Use Anthropic SDK's `client.messages.stream(...)` — yields `content_block_delta`, `tool_use_start`, etc.
- Server emits SSE frames: `text`, `tool_call`, `tool_result`, `done`.
- `components/chat-widget.tsx` uses `EventSource` or `fetch` + `ReadableStream.getReader()`.
- Render text deltas as they arrive; render tool chips on `tool_call` events.
Done when
- Typing effect appears within ~500ms of pressing send
- Tool chips slot in as the agent calls them, not all at once at the end
Risk
Mid-stream errors are harder to handle. Add a final `{ done: true }` marker so the client knows when to stop reading.
Non-streaming chat feels slow (~6s for tool-using turns). Streaming makes the agent feel alive on stage.
Plan
Done when
Risk
Mid-stream errors are harder to handle. Add a final `{ done: true }` marker so the client knows when to stop reading.