Project releases
LLM Stream Reformat splits thinking from answer as tokens arrive
Reasoning models emit their working alongside the answer. This Rust and WebAssembly library separates the two channels inflight, collapses repetition loops and normalises whitespace across three provider stream formats.
GitHub activity: · Published:
What it is
If you have ever streamed a reasoning model into a chat window, you have seen the mess: internal thinking, the actual answer, and the same sentence repeating four times, all in one flow of tokens.
This library parses the provider's server sent events and emits typed events instead, each tagged as thinking or answer, so your interface can render them differently.
What changed
Recent activity is protocol and verification work rather than new runtime features. Commit 74e1d2c added ADR-392 describing the AGL and AAP protocol alongside ADR-393, and the day before, commit c3d718f added continuous integration that runs cargo test and a WASM build on every push and pull request.
Stated plainly: this window is documentation and CI, not a feature release. It is covered here because the library is small, stable and useful, not because something large shipped.
Get started
Node 18 or newer, or a Rust toolchain:
npm install llm-stream-reformat
# or, in Rust:
cargo add stream-reformat
Feed the raw stream lines through a reformatter:
const { Reformatter } = require('llm-stream-reformat');
const rf = new Reformatter();
for (const line of sseLines) {
for (const ev of rf.pushSse('google', line)) {
if (ev.channel === 'thinking') showReasoning(ev.text);
else appendAnswer(ev.text);
}
}
rf.finish().forEach(ev => appendAnswer(ev.text));
Expected result: each event arrives as a channel and a text fragment. The provider argument is google, openrouter or metallm.
No documented MCP server. The supported routes are the npm package and the Rust crate.
Use it today
Practical case: a chat interface that should show reasoning in a collapsible panel. Input is the provider stream. Workflow is push each line, route by channel, flush at the end. Output is a clean answer plus optional visible working.
Acceptance test: stream a response that loops, and confirm the collapsed output contains the repeated sentence once.
Push it further
Experimental commentary. Combined with inflight watermark detection and MidStream analysis, the stream becomes a place to enforce policy rather than a pipe you inspect afterwards.
Limitation: three provider formats are supported, and provider formats change. Falsifiable test: capture a raw stream from your provider today and confirm the parser still splits the channels correctly.
Read the original on GitHub commit
Commit 74e1d2c — ADR-392 AGL/AAP protocol and ADR-393 product thesis