SIGN IN SIGN UP

fix: decode SSE incrementally without limiting event size (#3687)

## Summary

- Share an amortized-linear incremental SSE line framer between
synchronous and asynchronous decoding.
- Process complete lines as they arrive so comments and ignored fields
are discarded before the event finishes.
- Preserve historical unlimited line/event sizes, CR/LF/CRLF framing,
UTF-8 chunking, and response cleanup. No new size-limit API,
dependencies, exported client APIs, or `[DONE]` drain changes.

This removes quadratic prefix copying and unnecessary whole-frame
retention. It does not impose a memory bound on arbitrarily large data
events or unfinished lines.

## Validation

- 62 focused streaming/framing tests passed, including synchronous and
asynchronous events larger than 64 MiB, fragmented and unterminated
input, all newline forms, transport interruption, and cancellation.
- Ruff, targeted Mypy, targeted Pyright, and `git diff --check` passed.
- Final separate local review (round 3 of 3) was clean at
`d3667578e1a4e8da9d1962bfd403d98f4a0f945c`; its exhaustive short-input
CR/LF fragmentation matrix also passed.

Independent PR against public main. Please confirm this handwritten
shared-runtime patch is preserved in the next Castiron Python candidate;
no schema or generation-metadata change is needed.
A
Alex Chang committed
2598d530cf682784465e9f82558a830ac5f94486
Parent: 96f966d
Committed by GitHub <noreply@github.com> on 8/19/2026, 10:11:15 PM