Title: agy-proxy: stream resume-retry judges 'no output' before flushing the final line — an unterminated partial delta is silently retried as a fresh conversation (PR #679) · Issue #683 · developing-today/code · GitHub
Open Graph Title: agy-proxy: stream resume-retry judges 'no output' before flushing the final line — an unterminated partial delta is silently retried as a fresh conversation (PR #679) · Issue #683 · developing-today/code
X Title: agy-proxy: stream resume-retry judges 'no output' before flushing the final line — an unterminated partial delta is silently retried as a fresh conversation (PR #679) · Issue #683 · developing-today/code
Description: Finding PR #679 (fixes #678, head f935ce0e) judges a failed resume's "no output" condition inconsistently between the two modes of bin/agy-proxy.mjs, because the stream close handler checks hasOutput before flushing the final unterminate...
Open Graph Description: Finding PR #679 (fixes #678, head f935ce0e) judges a failed resume's "no output" condition inconsistently between the two modes of bin/agy-proxy.mjs, because the stream close handler checks hasOutp...
X Description: Finding PR #679 (fixes #678, head f935ce0e) judges a failed resume's "no output" condition inconsistently between the two modes of bin/agy-proxy.mjs, because the stream close handler ...
Opengraph URL: https://github.com/developing-today/code/issues/683
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"agy-proxy: stream resume-retry judges 'no output' before flushing the final line — an unterminated partial delta is silently retried as a fresh conversation (PR #679)","articleBody":"## Finding\n\nPR #679 (fixes #678, head `f935ce0e`) judges a failed resume's \"no output\" condition inconsistently between the two modes of `bin/agy-proxy.mjs`, because the stream close handler checks `hasOutput` **before** flushing the final unterminated line, while the non-stream handler parses the whole stdout buffer before its retry gate:\n\n- Stream (`bin/agy-proxy.mjs` on PR head): `child.on('close', (code, signal) => …)` runs the resume-retry check first — `if (code !== 0 && !hasOutput && allowRetry && targetConvId)` at :471 — and only afterwards flushes the tail line (`if (lineBuffer.trim()) { processJsonLine(lineBuffer.trim()); }` at :479-481) and the new exit-code failure check (:489). A `step_update` text delta that arrives as the child's final stdout bytes **without a trailing newline** is still sitting in `lineBuffer` at the retry decision, so `hasOutput` is `false` even though the run produced output.\n- Non-stream (same file, PR head): `stdoutBuffer` is fully parsed into `responseText` before the `if (code !== 0)` block (:580), and the retry inside it is gated on `!responseText` — so the same run shape is correctly treated as \"produced output\": no retry, HTTP 502.\n\nConsequence in stream mode: a resumed conversation whose run emits a partial delta in an unterminated final line and then exits non-zero is silently retried as a **fresh conversation**, and the client receives the fresh run's answer with `finish_reason: \"stop\"` and the resumed conversation's id — the failure is never reported, the partial output is discarded, and a second `agy` run executes even though the retry's own precondition (\"failed without output\", #678's acceptance criteria) does not hold. Whether the failure is reported or silently swapped for a fresh-conversation answer depends only on whether `agy` newline-terminated its last JSON line. The sibling proxies flush first: `bin/muse-proxy.mjs` and `bin/codex-proxy.mjs` both process a non-empty `lineBuffer` as the first step of their `close` handlers before judging the run.\n\nNote the success path already relies on the flush at :479-481 to deliver an unterminated final line, so unterminated tails are a shape this file explicitly handles — just not at the retry decision.\n\n## Evidence (reproduced on PR #679 head `f935ce0e1a5e4a2caf1880ee4f1badeec1638865`)\n\nRan the PR-head `bin/agy-proxy.mjs` with a stub `agy` at `$HOME/.local/bin/agy` (the proxy's own binary resolution; the `bin/agy-proxy.test.mjs` pattern from the PR), requests carrying `x-conversation-id: conv-123`:\n\n- Stub, on `--conversation`: emits `{\"event\":\"step_update\",\"step_update\":{\"text_delta\":\"partial answer\"}}` with **no trailing newline** (non-stream shape: `{\"response\":\"partial answer\"}` likewise unterminated), prints `stub agy: run failed midway` to stderr, exits 3; a fresh (no-conversation) run succeeds with `Hello world`:\n - stream → **200**, fresh run's `Hello world` chunk + `finish_reason: \"stop\"` + `[DONE]`; proxy log shows exactly 1 `retrying as fresh conversation` line — no error event, partial output never sent\n - non-stream → **502** `{\"error\":\"agy process exited with non-zero code\",\"code\":3,\"stderr\":\"stub agy: run failed midway\"}` (correct — the control)\n- Control, same stub but the partial line **is** newline-terminated:\n - stream → `partial answer` chunk, then `data:`-framed `agy execution failed: stub agy: run failed midway` error event + `[DONE]`, no `stop` chunk (the PR's intended new behaviour)\n - non-stream → **502**, same as above\n\nSo the two modes disagree on identical run shapes, and stream mode disagrees with itself based on a trailing newline. PR #679's new tests cover the resume-retry case only with no output at all (`RETRYME`) and the partial-output case only without a conversation (`FAILPARTIAL`, newline-terminated) — the resume + unterminated-partial shape is untested. This is filed against the PR as a follow-up; fixing it inside PR #679 before merge also satisfies this issue.\n\nDedup: issue searches for `agy-proxy` return only #678 (OPEN, the exit-code masking this PR fixes — its acceptance requires the retry be preserved for a failed resume with **no output**, which is exactly the precondition misjudged here) and unrelated port/discovery issues; searches for `lineBuffer` / `unterminated` / `resume retry` return only #678. Cross-repo: `bin/agy-proxy.mjs` exists only in this repo (no copy in developing-today/opencode, developing-today/openchamber, dezren39/nix — verified by `git grep` on each clone's `origin/main`).\n\n## Why it matters\n\nThe retry exists to recover from a stale conversation id, not to replace a run that already answered in part. Triggering it on a run that produced output hides a real failure (expired auth, CLI crash) behind an unrelated fresh conversation's answer, presented under the resumed conversation's id as a clean `stop` — the same silent-substitution failure mode #678 was filed for, reachable only in stream mode (the mode OpenCode actually consumes) and only when the final line is unterminated.\n\n## Acceptance criteria\n\n- [ ] The stream close handler flushes any non-empty `lineBuffer` (via `processJsonLine`) **before** the resume-retry decision, so `hasOutput` reflects all output the child produced — mirroring the non-stream ordering in the same file and the flush-first ordering in `bin/muse-proxy.mjs` / `bin/codex-proxy.mjs`.\n- [ ] A failed resume (non-zero exit or signal) whose only output is an unterminated final `step_update` delta is reported as a failure in stream mode — `data:`-framed error event naming the failure + `data: [DONE]`, no chunk claiming `finish_reason: \"stop\"`, no fresh-conversation retry — matching the non-stream 502 for the same shape.\n- [ ] A failed resume with genuinely no output still retries once as a fresh conversation in both modes (the existing `RETRYME` behaviour), and successful runs with an unterminated final line still deliver that line before the `stop` chunk.\n- [ ] A new stub case in `bin/agy-proxy.test.mjs` pins the resume + unterminated-partial + non-zero-exit shape in stream mode (and the non-stream control); ablating the flush-reorder fails exactly that case, and the `agy-proxy` + `muse-proxy` + `codex-proxy` + `proxy-port` suites pass.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-23T19:22:25Z","url":"https://github.com/developing-today/code/issues/683"}
| 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:e92d4ef1-c4fb-5029-0827-6d590cbb53bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6AE:30F58B:95F591:C23CFE:6B063154 |
| html-safe-nonce | 0dd7d3048144324e7c52595dbd7ddfb250a864b10d1fbc52e1cfac8e0b8cd46c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkFFOjMwRjU4Qjo5NUY1OTE6QzIzQ0ZFOjZCMDYzMTU0IiwidmlzaXRvcl9pZCI6IjMwODYzMjIxODMxMTU3ODA0MzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 052222c2a46af99ccf26faf6a5badd19129f2178919221ed2f0773ee6309de34 |
| hovercard-subject-tag | issue:6004090043 |
| 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/683/issue_layout |
| twitter:image | https://opengraph.githubassets.com/93fd5c9f0c98df36f741b227ebb27a225daa85304151798c290eee5fc5cd78d3/developing-today/code/issues/683 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/93fd5c9f0c98df36f741b227ebb27a225daa85304151798c290eee5fc5cd78d3/developing-today/code/issues/683 |
| og:image:alt | Finding PR #679 (fixes #678, head f935ce0e) judges a failed resume's "no output" condition inconsistently between the two modes of bin/agy-proxy.mjs, because the stream close handler checks hasOutp... |
| 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 | c3584c853cd39700ecff6e2cf8364295ffdb5313e571046c41cd2479270f7df0 |
| 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 | 9eb3bb1597d09170a5f282cd38ae376dee1a5ec1 |
| 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