Skip to content

[Bug] A truncated native-compaction SSE terminal header can authorize a rebase #6137

Closed

Description

@Afloat16

Reproduction

At e1e33a9, pass observeResponsesTerminalState an SSE stream containing only "event: response.completed" and one newline. It reports completed even though no data or blank-line dispatch boundary arrived. A complete data line without the final blank line also completes; malformed JSON is accepted beneath a completed header.

Impact and expected behavior

The relay uses this verdict to authorize native-compaction rebase. A truncated terminal event can leave the client retaining history while the proxy schedules that context state to be cleared. Only complete dispatchable terminal events should authorize rebase. Multiline data and supported line endings must work across chunks, and explicit failure data must override a conflicting success header.

Verified patch

Assemble full SSE frames using the existing line-ending helpers and parse joined data before classifying. Nine new cases fail against unchanged source. All 26 targeted tests, including local upstream/proxy integration, typecheck and build pass. This addresses event boundaries in #323, independently of summary extraction and whole-body JSON status.

Activity

  1. ranxianglei commented on Nov 10, 2026

    @ranxianglei
    Owner

    🤖 Powered by ework · qwen3.8-27b

    (ai: vllm-qwen/qwen3.8-27b)

    Duplicate screening: not a duplicate — and PR #6138 already targets this thread. Searched open+closed issues/PRs for the same symptom/mechanism (truncated terminal frame authorizing rebase): no other matching item; #6137 stands alone. @Afloat16's PR #6138 ("fix: classify native compaction only from complete SSE events", base e1e33a9, head d48b0a9) is the verified patch this issue describes — same repro, same nine-case suite, same base sha. Per the one-fix-PR-per-thread rule I will NOT open a parallel PR; I am reviewing and independently verifying #6138 against this issue's acceptance criteria instead.

    Triage — defect confirmed at source level:

    • src/stream-terminal.ts:17-36 (terminalFromSseLine): a bare event: response.completed line returns "completed" immediately — before any data line and before the blank-line dispatch boundary. All three reported repro shapes (header-only line; data line without final blank line; malformed JSON beneath a completed header) hit this early-return path.
    • Impact chain confirmed at src/server/relay.ts:2116-2119: terminal === "completed" → markNativeCompactionBoundary(session) → "rebase scheduled for next Responses turn". A false "completed" on a truncated stream rebases onto a compaction the client never received — the Fix Codex Responses session continuity #249 valid-blocks-discarded failure mode.
    • Adjacency check: [PR] fix: honor native compaction JSON terminal status #6136 (whole-body JSON terminal status) and [PR] fix: parse summary SSE data fields as complete events #6102 (summary-extraction multi-data-field parsing) are distinct mechanisms as the issue states, but both touch the same file — merge-order/conflict risk noted, will verify.

    Next: running the nine framing cases against master (expect fail) and against #6138's head (expect pass), plus the existing terminal suites, typecheck/build, and CI status. Structured review (八问) to follow in this thread.

    Labels: bug / scope/wiring / p1 — silent context-state loss class (false rebase discards valid blocks), narrow trigger window but data-loss severity per the 2026-10-19 p1 ruling.

  2. ranxianglei commented on Nov 12, 2026

    @ranxianglei
    Owner

    Fixed in batch PR #6439 (merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions