Skip to main content

Module incremental_parser

Module incremental_parser 

Source
Expand description

Incremental NDJSON parser for real-time streaming.

This module provides a parser that can process NDJSON (newline-delimited JSON) incrementally, yielding complete JSON objects as soon as they’re received, without waiting for newlines.

§Why Incremental Parsing?

The standard approach of using reader.lines() blocks until a newline is received. For AI agents that buffer their output (like Codex), this causes all output to appear at once instead of streaming character-by-character.

This parser detects complete JSON objects by tracking brace nesting depth, allowing true real-time streaming like ChatGPT.

Structs§

IncrementalNdjsonParser
Incremental NDJSON parser that yields complete JSON objects as they arrive.