Skip to content

feat(coding-agent): smooth streamed response pacing - #396

Merged
code-yeongyu merged 3 commits into
code-yeongyu:mainfrom
changeroa:feat/adaptive-streaming-buffer
Jul 28, 2026
Merged

feat(coding-agent): smooth streamed response pacing#396
code-yeongyu merged 3 commits into
code-yeongyu:mainfrom
changeroa:feat/adaptive-streaming-buffer

Conversation

@changeroa

@changeroa changeroa commented Jul 27, 2026

Copy link
Copy Markdown

Summary

  • add an 80ms startup jitter buffer for streamed assistant responses
  • estimate provider grapheme arrival rate with EWMA and adapt reveal speed between 45–240 graphemes/sec
  • retain roughly 140ms of queued text while preserving lifecycle/tool-call flush behavior and 30–120 FPS consistency

Why

The previous fixed catch-up policy emptied provider bursts quickly, producing visible output/pause cycles when the next chunk arrived later. A small adaptive reserve bridges typical chunk gaps without delaying completion.

Verification

  • npx vitest run test/streaming-reveal.test.ts (20 passed)
  • npx vitest run test/assistant-message-incremental-render.test.ts (11 passed)
  • node --test --import tsx --import ./test/setup-multiplexer-env.mjs --test-reporter=dot --test-reporter-destination=stdout test/tui-render.test.ts (45 passed)
  • npm run check
  • real CLI TUI smoke via senpi-qa (5/5 passed)

QA receipt: local-ignore/qa-evidence/20260727-adaptive-streaming-buffer/


Summary by cubic

Smooths streamed assistant response pacing with an adaptive buffer and learned rate control to eliminate bursty output/pause cycles. Keeps ~140ms queued and follows the provider’s arrival rate (no hard cap) for steady, readable updates.

  • New Features
    • Adds an 80ms startup buffer to gate the first reveal.
    • Learns arrival rate via EWMA with bounded samples (min 45 u/s); removes the 240 u/s cap and limits extra catch-up to 600 u/s.
    • Maintains ~140ms reserve with a 267ms convergence window; frame-rate independent pacing (30–120 FPS) with fractional carry, and resets carry after fully drained bursts.
    • Splits content and pacing into streaming-reveal-content.ts and streaming-reveal-pacing.ts; exports helpers from streaming-reveal.ts.
    • Shares pacing with tool-arg streaming; parses JSON in bounded batches while preserving surrogate pairs and lifecycle/tool-call flush behavior.

Written for commit 766ea19. Summary will update on new commits.

Review in cubic

@code-yeongyu
code-yeongyu enabled auto-merge July 28, 2026 05:32
@code-yeongyu
code-yeongyu merged commit d9df80b into code-yeongyu:main Jul 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants