Description
During streaming responses, OpenCode writes to storage (JSON files) on every reasoning-delta event. With fast streaming APIs, this results in hundreds of file writes per second.
Impact
- High I/O overhead from frequent file system operations
- Increased latency between receiving content and displaying it
- Slower perceived response time compared to native CLI tools (e.g., kiro-cli)
Root Cause
In processor.ts, every delta triggers a storage write:
case "reasoning-delta":
if (part.text) await Session.updatePart({ part, delta: value.text })
Session.updatePart calls Storage.write which writes to the file system on every call.
Proposed Solution
Throttle storage writes during streaming:
- Accumulate content in memory
- Only flush to storage every 50ms
- Always flush on
reasoning-end
Environment
- OpenCode version: latest
- Tested with Kiro API streaming responses
Description
During streaming responses, OpenCode writes to storage (JSON files) on every
reasoning-deltaevent. With fast streaming APIs, this results in hundreds of file writes per second.Impact
Root Cause
In
processor.ts, every delta triggers a storage write:Session.updatePartcallsStorage.writewhich writes to the file system on every call.Proposed Solution
Throttle storage writes during streaming:
reasoning-endEnvironment