Title: muse-proxy (PR #479): streaming responses silently drop the terminal text tail that non-streaming returns · Issue #484 · developing-today/code · GitHub
Open Graph Title: muse-proxy (PR #479): streaming responses silently drop the terminal text tail that non-streaming returns · Issue #484 · developing-today/code
X Title: muse-proxy (PR #479): streaming responses silently drop the terminal text tail that non-streaming returns · Issue #484 · developing-today/code
Description: Finding In PR #479 (bin/muse-proxy.mjs, commit 9e7dcbd), a streaming chat-completions response can silently lose the tail of the assistant's reply. The proxy tracks two sources of response text: run.output.delta events are appended to fu...
Open Graph Description: Finding In PR #479 (bin/muse-proxy.mjs, commit 9e7dcbd), a streaming chat-completions response can silently lose the tail of the assistant's reply. The proxy tracks two sources of response text: ru...
X Description: Finding In PR #479 (bin/muse-proxy.mjs, commit 9e7dcbd), a streaming chat-completions response can silently lose the tail of the assistant's reply. The proxy tracks two sources of response text...
Opengraph URL: https://github.com/developing-today/code/issues/484
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"muse-proxy (PR #479): streaming responses silently drop the terminal text tail that non-streaming returns","articleBody":"## Finding\n\nIn PR #479 (`bin/muse-proxy.mjs`, commit 9e7dcbde15e35bd71b7e50dd5762285477255c65), a streaming chat-completions response can silently lose the tail of the assistant's reply.\n\nThe proxy tracks two sources of response text:\n\n- `run.output.delta` events are appended to `fullContent` and, in stream mode, written to the client immediately as SSE chunks (bin/muse-proxy.mjs:317-336 in the PR head).\n- The `run.terminal.*` event carries the authoritative final text in `payload.text`, stored as `terminalText` (bin/muse-proxy.mjs:341-342).\n\nOn child close, the non-streaming path reconciles them:\n\n```js\n// Prefer the terminal event's authoritative text if deltas missed any\nif (terminalText !== null && terminalText.length >= fullContent.length) {\n fullContent = terminalText;\n}\n```\n(bin/muse-proxy.mjs:376-377)\n\nBut the streaming branch (bin/muse-proxy.mjs:~390-410) only writes a final chunk with `delta: {}`, `finish_reason: 'stop'`, and usage, then `data: [DONE]`. It never emits the part of `terminalText` that was not already streamed. So whenever the terminal text is longer than the sum of the deltas — the exact case the comment says the reconciliation exists for (\"if deltas missed any\") — streaming clients receive a truncated reply that nevertheless claims `finish_reason: \"stop\"`, while non-streaming clients receive the full text for the identical run.\n\n## Evidence (reproduced against the PR head)\n\nRan the PR's `bin/muse-proxy.mjs` (fetched via the contents API at the PR head sha, byte-count matches the `gh pr diff` hunk: 459 lines) with a stub `muse` binary emitting:\n\n```json\n{\"payload_type\":\"run.output.delta\",\"payload\":{\"text\":\"Hel\"}}\n{\"payload_type\":\"run.usage\",\"payload\":{\"models\":[{\"input_tokens\":100,\"output_tokens\":3}]}}\n{\"payload_type\":\"run.terminal.completed\",\"payload\":{\"terminal\":\"completed\",\"text\":\"Hello world\"}}\n```\n\n- Non-streaming `POST /v1/chat/completions` returned content `\"Hello world\"` (correct).\n- Streaming (`\"stream\": true`) returned exactly one content chunk `\"Hel\"`, then a finish chunk with `finish_reason: \"stop\"` and `data: [DONE]` — `\"lo world\"` was never sent.\n\nDeduped: issue searches for \"muse-proxy streaming terminal\" and \"run.terminal\" return no existing issue. The sibling `bin/codex-proxy.mjs` has no terminal-text concept (its CLI stream differs), so this is muse-proxy only; `git grep muse-proxy` on the other three repos' mains (opencode/openchamber/nix) is empty.\n\n## Why it matters\n\nOpenCode (the stated consumer, wired as provider `muse`) typically consumes these bridges in streaming mode. A response that ends mid-sentence while reporting a clean `stop` is worse than an error: downstream code and users treat the truncated text as the complete answer, and the discrepancy is invisible unless someone compares against a non-streaming call.\n\n## Acceptance criteria\n\n- [ ] In stream mode, before the finish chunk, emit any suffix of the terminal text that was not already streamed (when `terminalText` starts with the streamed `fullContent`), or otherwise guarantee streamed content equals the non-streamed content for the same run.\n- [ ] If the terminal text diverges from the streamed deltas in a way that cannot be reconciled as a suffix, the behaviour is explicit (documented) rather than silently truncated.\n- [ ] A regression test with a stub `muse` emitting deltas that are a strict prefix of the terminal text passes in both stream and non-stream modes, asserting identical final content.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-21T14:51:22Z","url":"https://github.com/developing-today/code/issues/484"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f9314306-a21b-d723-2238-698934e9228b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A95A:3CF71B:5C6756:7B90D8:6B0624F9 |
| html-safe-nonce | 9044800f352742ca2ea116284b6d2f62755bccdbc7fd99e86a2a2694eef5ef63 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOTVBOjNDRjcxQjo1QzY3NTY6N0I5MEQ4OjZCMDYyNEY5IiwidmlzaXRvcl9pZCI6IjQyNjk2Mjk1NzYzMTk0NzY5ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c55ef72e3cd8c57d045329ccf6303574a1094edf4dfeb843eb1a5dac81ed53f3 |
| hovercard-subject-tag | issue:5962868483 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/484/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1974c863d68cd0fc55bc8bf98782e8aa6e4f2863c2db354ae88ce96a9d1ff8f8/developing-today/code/issues/484 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1974c863d68cd0fc55bc8bf98782e8aa6e4f2863c2db354ae88ce96a9d1ff8f8/developing-today/code/issues/484 |
| og:image:alt | Finding In PR #479 (bin/muse-proxy.mjs, commit 9e7dcbd), a streaming chat-completions response can silently lose the tail of the assistant's reply. The proxy tracks two sources of response text: ru... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9e10bb0ecc0bd0f8692aa89586ee9b54e498d7ab9f244a44cdb5b93653a125ce |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 32e57d5cc2ce6ce92ec6dceb65858344750c27c2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width