Repository navigation
Conversation
Since openclaw#125149 any OpenAI-completions stream that carries native reasoning hides every byte of visible text until the stream ends: the first reasoning chunk marks the message terminal-bound and arms the reasoning-tag partitioner's strict mode, and text sharing a chunk with reasoning is routed through the tag-aware path, which also arms strict mode. With a reasoning model on vLLM the answer therefore arrives as one delta at the end, minutes after the reasoning finished, even though the server streamed it token by token. That deferral exists so text interrupted by resumed reasoning can be classified as commentary or final answer at terminal. Reasoning that precedes every visible byte leaves nothing to reclassify, so defer only when reasoning resumes after visible text: mark the message terminal-bound and switch the partitioner to strict mode only then, and route same-chunk text through the tag-aware path only once the message is terminal-bound. Resumed-reasoning streams behave exactly as before. Measured against vLLM (qwen38-flash-next, reasoning low): before, one 2,924-character text delta at 16.8 s; after, 92 deltas starting 50 ms after the last thinking delta. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesStreams visible Chat Completions text after initial or resumed reasoning while preserving final-answer classification. Example: A stream emits reasoning, “Initial text.”, more reasoning, then “Final text.”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a useful, maintainer-approved streaming repair that current main still needs; no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared Chat Completions transport converts provider chunks into assistant events; the embedded-agent subscriber sends live previews and separately prepares classified final replies. flowchart LR
A[Provider stream] --> B[Completions transport]
B --> C[Reasoning tag parser]
C --> D[Assistant events]
D --> E[Embedded subscriber]
E --> F[Live previews]
E --> G[Classified final reply]
Technical reviewBest possible solution: Land the shared producer and subscriber repair with the accepted live-preview tradeoff and preserved terminal filtering. Do we have a high-confidence way to reproduce the issue? Current-main source shows both withholding gates, corroborated by the supplied before/after Gateway measurements; this review executed no target code. Is this the best way to solve the issue? The patch addresses both shared owners without adding a parallel preview API or configuration, and preserves final classification, explicit strict-tag consumers, and durable-block withholding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ec2d3267cd3f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -20, Tests +97, Docs +4. Total +81 across 7 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 10, 2026, 3:13 PM ET / 19:13 UTC (Revision 5). |
Stream visible Chat Completions text through initial and resumed reasoning while keeping final delivery limited to the confirmed answer. Preserve unfinished reasoning-tag privacy and content followed only by reasoning. Co-authored-by: Aron Hsiao <[email protected]>
|
@clawsweeper re-review Please review head 3cbae23. Peter Steinberger's product decision of October 10, 2026 explicitly permits live interim text after reasoning and supersedes #125149's no-transient-interim policy. Final reply classification is preserved: the real producer/subscriber regression and isolated Qwen3 4B Gateway interleaving proof show the interim segment live and exclude it from the final reply. The PR body records the decision, before/after timings, tests, and clean Codex review. No compatibility flag or provisional-preview mechanism was added. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…nclaw#150685) * fix(ai): stream completions text live when reasoning precedes it Since openclaw#125149 any OpenAI-completions stream that carries native reasoning hides every byte of visible text until the stream ends: the first reasoning chunk marks the message terminal-bound and arms the reasoning-tag partitioner's strict mode, and text sharing a chunk with reasoning is routed through the tag-aware path, which also arms strict mode. With a reasoning model on vLLM the answer therefore arrives as one delta at the end, minutes after the reasoning finished, even though the server streamed it token by token. That deferral exists so text interrupted by resumed reasoning can be classified as commentary or final answer at terminal. Reasoning that precedes every visible byte leaves nothing to reclassify, so defer only when reasoning resumes after visible text: mark the message terminal-bound and switch the partitioner to strict mode only then, and route same-chunk text through the tag-aware path only once the message is terminal-bound. Resumed-reasoning streams behave exactly as before. Measured against vLLM (qwen38-flash-next, reasoning low): before, one 2,924-character text delta at 16.8 s; after, 92 deltas starting 50 ms after the last thinking delta. * fix(ai): stream reasoning completions before final classification Stream visible Chat Completions text through initial and resumed reasoning while keeping final delivery limited to the confirmed answer. Preserve unfinished reasoning-tag privacy and content followed only by reasoning. Co-authored-by: Aron Hsiao <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Aron Hsiao <[email protected]>
What Problem This Solves
Fixes answers arriving in one burst at the end when an OpenAI-compatible Chat Completions model streams reasoning before visible text.
User Impact
Visible text now streams after initial or resumed reasoning wherever live streaming is enabled. A live update may briefly contain text that later becomes commentary; the final reply still excludes that commentary and delivers the confirmed answer. Content followed only by reasoning remains deliverable. No new configuration is required.
Maintainer product decision — Peter Steinberger, October 10, 2026: live interim text is deliberately allowed. This supersedes #125149's no-transient-interim delivery policy while preserving its final-answer classification. No compatibility flag or provisional-preview mechanism was added.
Why This Change Was Made
The shared completion transport no longer turns reasoning into an all-text buffer, and the subscriber no longer treats terminal-phase metadata as a live-delivery hold. The producer retains that metadata for final/error classification, preserves confirmed final boundaries, and keeps unfinished reasoning tags private. Durable unclassified block replies retain their existing terminal-resolution contract.
Thanks @leapdragon (Aron Hsiao) for the diagnosis, original implementation, and live vLLM measurements. Contributor history is preserved; current main was merged into the branch, never rebased. The maintainer revision removes the extra phase helpers and strengthens the tests to observe text before the next input chunk rather than merely counting deltas after completion.
Evidence
Real local Qwen3 4B through an isolated CLI-launched Gateway, using the same synthetic prompt and llama.cpp's
reasoning_contentstream:These are separate model generations, so total generation speed varies. The important boundary result is that main withheld content until backend completion, while the candidate forwarded it as generated.
A second real-model Gateway run inserted one synthetic
INTERIM_LIVE_MARKERcontent chunk after the first native reasoning chunk, then forwarded the remaining real reasoning and model answer. The marker appeared live at 1.306s; streaming continued after resumed reasoning; the final reply at 4.798s excluded it. The final reply on main also excluded the marker, while main emitted no interim preview. This is synthetic interleaving over actual local inference, not a claim that the unmodified model naturally emitted that sequence. No Telegram or other live channel-server proof is claimed.Commands used:
node scripts/worktree-setup.mjs gateway,pnpm build, thenpnpm openclaw --profile completions-stream gateway run --port 19371with isolated state/config. The observer used the production Gateway client andchat.send/chatevents. No operator Gateway or state was changed.Validation:
3cbae23fae46494ecb8c6345efc7ce3d57196c70. Exact-head CI passed, includingopenclaw/ci-gate; ClawSweeper reports no findings or Before merge items on that head. Changed-test CI jobs took 95–242s including setup; individual-file hosted times were not extracted.Relative to the merged main baseline: production +6/-26 (net -20); tests/fixtures +133/-36 (net +97); docs +6/-2. No model-facing prompt text changed, so no prompt snapshot or token delta applies.
Gateway Chat Completions HTTP SSE retains its existing append-only correction contract; this change does not add stream retraction. Channel-specific preview settings and explicit strict-tag consumers remain supported.
Additional Telegram Test Server coverage remains unrun; the maintainer proof-only override applies. The real Gateway/local-model and producer-to-subscriber evidence above is the validation supplied for this change.