中文 | English
Why does Claude Code use async generators as the core query abstraction instead of callbacks or plain async functions?
python examples/l8_streaming.pyThis requires DEEPSEEK_API_KEY.
query.tsservices/api/claude.ts
yieldyield*queryModelWithStreamingstream_request_start
- how text chunks, tool events, and results all become one event stream
- why cancellation aligns naturally with generator semantics
- why
yield*makes nested agent composition simpler
The demo keeps only the event shape and the minimum streaming loop. The real implementation also handles SDK event conversion, recovery, throughput, and UI integration.
- What does Promise, callback, or generator each fail to provide in this specific runtime?
- Why is
yield*crucial for multi-agent and nested event forwarding? - Where is the boundary between
services/api/claude.tsandquery.ts?