fix(providers): normalize GitHub Copilot Responses streams - #1111
fix(providers): normalize GitHub Copilot Responses streams#1111Simon-Opopeee wants to merge 3 commits into
Conversation
📝 WalkthroughWalkthroughThe change adds bounded rollout inspection and a stateful GitHub Copilot Responses SSE rewriter. It normalizes identifiers, sequences, reasoning fields, and tool-call data. The response pipeline composes rewrites, pins completed IDs, and handles dropped partial blocks. ChangesCopilot Responses compatibility
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CopilotProvider
participant BlockRewriter
participant SSEInspector
participant ResponsesRelay
participant CodexClient
CopilotProvider->>BlockRewriter: Send provider SSE blocks
BlockRewriter->>BlockRewriter: Normalize IDs, sequences, reasoning, and tool calls
BlockRewriter->>SSEInspector: Forward rewritten response records
SSEInspector->>ResponsesRelay: Pin completed response ID when enabled
ResponsesRelay->>CodexClient: Send canonical SSE blocks and [DONE]
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
3/4 boxes ticked. This PR stays in draft until every box above is ticked. |
1fd536a to
2bf0062
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with 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.
Inline comments:
In `@src/server/github-copilot-responses-repair.ts`:
- Around line 178-195: Update rememberItem to avoid throwing
TranslatorBudgetExceededError when MAX_TRACKED_ITEMS is reached; instead stop
retaining additional output indices and mark the repair as tainted, following
the degraded behavior used by relay handling. Ensure emitProcessedBlocks can
continue processing and streaming output beyond the retained-item limit while
preserving existing byte-budget enforcement.
In `@tests/github-copilot-sse-rewrite.test.ts`:
- Around line 89-93: Replace the hard-coded 137 split in the
relaySseWithBlockRewrite test with an offset derived from the upstream fixture
content, ensuring it falls within the intended frame rather than at a fixed byte
position. Keep the two-chunk stream split and existing assertions unchanged so
edits to the frame fixtures preserve mid-frame boundary coverage.
In `@tests/sse-inspector-bounds.test.ts`:
- Around line 61-78: Add a default-off test alongside the existing
pinCompletedResponseIdToFirstSeen test in the SSE inspector suite. Create the
inspector without setting the flag, feed the same client-visible creation and
upstream terminal events, and assert the completed response retains the upstream
terminal id rather than rewriting it.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c2776e7c-f08f-41bc-89e9-ac89bdeefbd5
📒 Files selected for processing (12)
src/codex/native-residue.tssrc/server/github-copilot-responses-repair.tssrc/server/relay.tssrc/server/responses/core.tssrc/server/sse-payload-rewrite.tstests/ci-workflows.test.tstests/codex-native-residue.test.tstests/github-copilot-sse-rewrite.test.tstests/github-copilot-stream-contract.test.tstests/passthrough-abort.test.tstests/sse-inspector-bounds.test.tstests/sse-payload-rewrite.test.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Reviewed in a sweep of the The gap is real: Please split the native-history bound into its own PR. The 64 MiB cap on rollout inspection is a genuinely useful fix — Second blocker: the verification claim. Your description says the full suite was interrupted, which I appreciate you stating rather than rounding up. The readiness gate needs a green Your branch is on the latest Good instinct on preserving the raw wire shape while repairing the client-facing view. That is the distinction most stream-normalization patches get wrong. |
4d168f3 to
b754e97
Compare
b754e97 to
840a57c
Compare
|
Thanks for the review. I addressed the requested scope and verification changes.
I also removed the now-obsolete native-history sentence from issue #1110 and updated this PR description to match the split and the exact verification results. The three previous CodeRabbit findings are resolved and their review threads are marked resolved. The remaining repository CI workflows ( |
Summary
/v1/responsesSSE streams before they reach Codex clients: remove provider-only encrypted/obfuscation fields, pin client-visible response and item ids, and emit canonical function/custom-tool completion events.Verification
bun run test— 9,236 pass, 8 skip, 0 fail (9,244 tests across 583 files).bun test tests/github-copilot-sse-rewrite.test.ts tests/github-copilot-stream-contract.test.ts tests/sse-payload-rewrite.test.ts tests/sse-inspector-bounds.test.ts tests/passthrough-abort.test.ts— 47 pass, 0 fail.bun run typecheck— pass.bun run privacy:scan— pass.git diff --check— pass.ocx --versionreportsopencodex 2.10.2;ocx startandocx syncstay alive/exit 0 with Codex integration enabled andopenai_base_urlathttp://127.0.0.1:10101/v1.10101usinggithub-copilot/gpt-5.6-luna: reasoning, function-tool, and custom-tool streams all returned HTTP 200, canonical event names,response.completed,[DONE], zeroencrypted_content, zeroobfuscation, and no event-name mismatches.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.