Streaming이 parsing 문제 바꿔
Structured output stream하면 partial JSON 받아: {"verdict": "app… 등등. naïve json.loads()가 모든 chunk에 실패. Pipeline은 done까지 buffer하거나 streaming JSON parser로 incremental parse 필요.
왜 stream
- UX — 8초 후가 아니라 200ms 안에 user한테 뭐 보여줘.
- Pipelining — 마지막 후가 아니라 첫 complete field 후 downstream work 시작.
- Cancellation — user가 navigate away하거나 verifier가 reject하자마자 request kill.
Streaming specific failure mode
- JSON output 중간 truncation (max_tokens, network drop).
- 조각으로 도착하는 tool call (start, delta, stop).
- Output 토큰이랑 별도로 streaming하는 reasoning 토큰.
- Cancellation race — consumer disconnect하면 너의 코드가 cancellation wire 안 하면 계속 돌아.