GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(streaming): repair sparse Responses snapshots by 0xJingwei · Pull Request #928 · lidge-jun/opencodex Conversation
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds the opt-in ChangesResponses snapshot repair
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant handleResponses
participant ResponsesGateway
participant SnapshotRepair
Client->>handleResponses: Submit Responses request
handleResponses->>ResponsesGateway: Forward request
ResponsesGateway-->>handleResponses: Return sparse SSE or JSON payload
handleResponses->>SnapshotRepair: Repair when responsesSnapshotRepair is true
SnapshotRepair-->>handleResponses: Return repaired payload
handleResponses-->>Client: Relay client-facing response
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/server/responses-snapshot-repair.ts`:
- Around line 226-236: Update the retainCompletedItem call in the event
reconstruction branch to measure the serialized item with
Buffer.byteLength(JSON.stringify(item), "utf8") instead of
encoder.encode(...).byteLength, while preserving the existing validation and
retention flow.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 229cfebe-96ef-4cbe-8823-bb7fd0acc702
docs-site/src/content/docs/ja/reference/configuration/providers.mddocs-site/src/content/docs/ko/reference/configuration/providers.mddocs-site/src/content/docs/reference/configuration/providers.mddocs-site/src/content/docs/ru/reference/configuration/providers.mddocs-site/src/content/docs/zh-cn/reference/configuration/providers.mdsrc/config.tssrc/server/responses-snapshot-repair.tssrc/server/responses/core.tssrc/types.tstests/config.test.tstests/responses-snapshot-repair.test.ts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
src/server/responses-snapshot-repair.ts (1)
216-235: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winTaint reconstruction when a
response.output_item.doneevent is malformed.
reconstructionTaintedis set only whenevent.itemis a plain object. If a done event has noitemor has a non-objectitem, the handler skips this block and keeps previously retained items usable. A laterresponse.completedevent can then reconstructresponse.outputwithout the missing item.Handle
response.output_item.doneindependently of item validation. SetreconstructionTainted = truewhenevent.item,output_index, or the repaired item type is invalid. Add a regression test for a malformed done event followed by a terminal snapshot.Proposed fix
+ if (type === "response.output_item.done" && !isPlainObject(event.item)) { + reconstructionTainted = true; + } + if ((type === "response.output_item.added" || type === "response.output_item.done") && isPlainObject(event.item)) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/server/responses-snapshot-repair.ts` around lines 216 - 235, Update the response event handling around repairOutputItem so response.output_item.done is validated independently of isPlainObject(event.item). For every done event, set reconstructionTainted when event.item is missing or non-object, output_index is not a nonnegative integer, or the repaired item lacks a string type; only retain the completed item when all validations pass. Add a regression test covering a malformed done event followed by response.completed and verify the terminal snapshot does not reconstruct the missing item.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/server/responses-snapshot-repair.ts`:
- Around line 216-235: Update the response event handling around
repairOutputItem so response.output_item.done is validated independently of
isPlainObject(event.item). For every done event, set reconstructionTainted when
event.item is missing or non-object, output_index is not a nonnegative integer,
or the repaired item lacks a string type; only retain the completed item when
all validations pass. Add a regression test covering a malformed done event
followed by response.completed and verify the terminal snapshot does not
reconstruct the missing item.
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4d0e51f2-116d-42d2-abfc-4ed8de09f243
src/server/responses-snapshot-repair.ts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: f42074fad1
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Addressed the incremental CodeRabbit data-integrity finding in fe53d58. Every malformed |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@codex review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/server/auth-cors.ts`:
- Around line 443-445: Update the canonical openai provider key comparison in
the validation logic near the responsesSnapshotRepair type check to exclude
responsesSnapshotRepair, while retaining its boolean validation. Add
management-provider validation coverage for pool and direct modes, ensure the
openai-responses path continues applying the option, and continue rejecting
non-canonical custom authMode "forward" providers.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c67fae7f-6981-464c-ba34-55b1d38b826d
docs-site/src/content/docs/ja/reference/configuration/providers.mddocs-site/src/content/docs/ko/reference/configuration/providers.mddocs-site/src/content/docs/reference/configuration/providers.mddocs-site/src/content/docs/ru/reference/configuration/providers.mddocs-site/src/content/docs/zh-cn/reference/configuration/providers.mdsrc/config.tssrc/server/auth-cors.tssrc/server/responses-snapshot-repair.tssrc/types.tstests/config.test.tstests/management-provider-validation.test.tstests/responses-snapshot-repair.test.ts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is a much better shape than #894 — the scoping problem that closed that one is genuinely fixed here. Default-off behind route.provider.responsesSnapshotRepair, bounded at 256 items / 8 MiB with the translator budget charged and released, both SSE and JSON covered, and the relay design unit left alone. 825 of the 1,013 added lines are the repair module and its test.
One blocker.
src/server/responses-snapshot-repair.ts:108-110 — hasAuthoritativeOutput requires a non-empty array, so an upstream that explicitly sends response.completed.response.output: [] after emitting done items gets its answer replaced with reconstructed content.
That breaks the contract this repair rests on: fill absences, never overwrite what the gateway actually sent. An empty array is a value, not an absence — a gateway that deliberately returns no output is saying something, and we would be contradicting it. tests/responses-snapshot-repair.test.ts:199-227 currently pins the wrong behavior, expecting reconstruction for [].
The fix is to reconstruct only when output is genuinely absent. If a malformed present value also needs handling, that is worth doing — but as its own documented policy with its own test, not folded into the absence path.
The integration test at tests/responses-snapshot-repair.test.ts:362-435 uses a stream containing a full response.output_item.done. Issue #893's reported fixture is more abbreviated than that — added → delta → completed. Running that exact shape produces a canonical terminal snapshot with output: [], which may well be enough for current clients, but nothing here demonstrates it.
Either add the issue's exact stream as a fixture and assert the observable consumer contract, or state in a comment why the canonical empty snapshot is sufficient. Right now the PR fixes a shape adjacent to the reported one, and the gap is not written down.
Verified on your head c08772c: typecheck passes, 172 focused tests pass across snapshot repair, config, and provider management.
Fix the empty-output case and I will take another look.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@lidge-jun Addressed the requested changes in
Validation on the new head:
Please take another look when convenient. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@codex review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: 27a88c1634
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Addressed both current GitHub Codex findings in
Current-head validation:
One transparent local-suite note: a current-head @lidge-jun the two automated follow-up findings are now handled without expanding the PR scope. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@codex review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
src/server/responses-snapshot-repair.ts (1)
249-257: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReject blank output item types before retention.
Line 249 accepts
item.type: ""and whitespace-only values. The code then clears the unfinished index and retains the invalid item. A terminal event can reconstruct this item intoresponse.output, although it has no usable canonical type.Require a non-empty trimmed type before calling
retainCompletedItem. Otherwise, taint reconstruction and emit canonicaloutput: [].Proposed fix
- if (outputIndex !== undefined && typeof item.type === "string") { + if (outputIndex !== undefined + && typeof item.type === "string" + && item.type.trim().length > 0) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/server/responses-snapshot-repair.ts` around lines 249 - 257, Update the retention condition in the reconstruction flow around retainCompletedItem to require item.type to be a non-empty, trimmed string, not merely any string. For blank or whitespace-only types, leave the unfinished index intact, set reconstructionTainted, and ensure the existing tainted-output path emits canonical output: [].
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/server/responses-snapshot-repair.ts`:
- Around line 249-257: Update the retention condition in the reconstruction flow
around retainCompletedItem to require item.type to be a non-empty, trimmed
string, not merely any string. For blank or whitespace-only types, leave the
unfinished index intact, set reconstructionTainted, and ensure the existing
tainted-output path emits canonical output: [].
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 85aee37a-8a67-4e80-b954-21ca157eb2bc
src/server/responses-snapshot-repair.tstests/responses-snapshot-repair.test.ts
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Addressed the CodeRabbit outside-diff blank-type finding in The retention gate now requires Regression evidence:
Latest validation remains: focused 151/151 with 619 assertions, management 4/4, typecheck pass, privacy scan pass, and |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@coderabbitai review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@codex review |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
✅ Action performedReview finished.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Superseded by #1025 (head This PR was the strongest source for #893's design, and most of its shape survives in the successor. Adopted from this PR
Deliberately not matched
Status disclosure #1025 is rebased onto current Full equivalence reasoning: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…dge-jun#893) Responses-compatible gateways can omit canonical lifecycle fields and closing events, leaving Codex clients stuck on an uncommitted turn. - block-level SSE rewrite contract (zero-or-more blocks out per event) in the pull relay and the eager relay - responses-snapshot-repair: field backfills (adopted from PR lidge-jun#928 with attribution) + lifecycle injection — content_part.added on first text delta for an open item, and output_text.done/content_part.done/ output_item.done before terminal events, with terminal output reconstruction only when the gateway omitted it entirely - fail closed on ambiguous/gapped/malformed/oversized/contradictory shapes; explicit output: [] stays authoritative - provider config responsesSnapshotRepair (boolean), management-plane writes permitted on canonical OpenAI pool/direct seeds - JSON (non-stream) path repairs fields after raw inspection
…dge-jun#893) Responses-compatible gateways can omit canonical lifecycle fields and closing events, leaving Codex clients stuck on an uncommitted turn. - block-level SSE rewrite contract (zero-or-more blocks out per event) in the pull relay and the eager relay - responses-snapshot-repair: field backfills (adopted from PR lidge-jun#928 with attribution) + lifecycle injection — content_part.added on first text delta for an open item, and output_text.done/content_part.done/ output_item.done before terminal events, with terminal output reconstruction only when the gateway omitted it entirely - fail closed on ambiguous/gapped/malformed/oversized/contradictory shapes; explicit output: [] stays authoritative - provider config responsesSnapshotRepair (boolean), management-plane writes permitted on canonical OpenAI pool/direct seeds - JSON (non-stream) path repairs fields after raw inspection
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[Bug]: Responses-compatible gateways can return sparse lifecycle snapshots that Codex clients do not commit
There was an error while loading. Please reload this page.