Skip to content

copilot: preserve HTTP correlation for incomplete Responses streams - #345630

Merged
Dileep Yavanmandha (dileepyavan) merged 1 commit into
mainfrom
agents/fix-responses-request-id-344706
Nov 2, 2026
Merged

Dileep Yavanmandha (dileepyavan) merged 1 commit into
mainfrom
agents/fix-responses-request-id-344706

Conversation

@dileepyavan

Copy link
Copy Markdown
Member

Fixes #344706

Problem

An HTTP Responses stream can end without emitting a terminal completion, for example after a reasoning item or with an unterminated completion frame. The final classifier correctly returns unknown with Response contained no choices., but previously obtained correlation only from retained completions. With none available, it discarded the actual HTTP request ID, making service-side investigation harder.

This fixes diagnostic correlation loss, not the underlying cause of an incomplete upstream stream.

Changes

  • Retain HTTP request metadata on the internal successful-HTTP response independently of its completion iterable.
  • Use the retained X-Request-ID, Copilot service request ID, and raw X-GitHub-Copilot-Request-Te in the no-choices fallback.
  • Preserve completion-derived metadata when present and preserve all existing response classifications. Empty header IDs remain absent rather than being replaced with invented IDs.
  • Add six regression/control cases that exercise the real Responses SSE parser and final fetcher classifier: empty body, reasoning followed by EOF, unterminated completion frame, valid completion, explicit stream error, and incomplete stream with no correlation headers.

No truncated frame is accepted as a completion, and no incomplete response is converted into success.

Validation

The three incomplete-stream correlation cases were verified to fail when HTTP metadata retention was temporarily removed; the completed-response and explicit-error controls still passed. The fix was restored before final validation.

From extensions\copilot:

$env:NODE_OPTIONS='--preserve-symlinks --preserve-symlinks-main'
pnpm run test:unit src\extension\prompt\node\test\chatMLFetcherResponseApiTelemetry.spec.ts src\platform\endpoint\node\test\responsesApi.spec.ts src\extension\prompt\node\test\chatMLFetcherRetry.spec.ts src\extension\prompt\node\test\chatMLFetcherTelemetry.spec.ts

Passed: 118 tests across four files. The module-resolution options are needed for this worktree's existing dependency junctions; without them, Vitest fails during initialization, including in the existing parser suite.

From the repository root:

pnpm run eslint extensions\copilot\src\platform\openai\node\fetch.ts extensions\copilot\src\extension\prompt\node\chatMLFetcher.ts extensions\copilot\src\extension\prompt\node\test\chatMLFetcherResponseApiTelemetry.spec.ts
git diff --check

Passed: targeted ESLint and whitespace checks.

From extensions\copilot:

pnpm run compile

Failed: the installed @typescript/native package does not export @typescript/native/ast or @typescript/native/async, producing 16 resolution errors in the unchanged TypeScript-context code. The existing shared dependency installation was not modified.

No standalone type-check, live provider request, integration suite, or smoke suite was run.

Retain HTTP request metadata independently of streamed completions so the no-choices failure retains diagnostic correlation. Keep completion-derived metadata and existing response classifications unchanged.

Fixes #344706

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the correlation-metadata retention change.

No open issues 🎉

What changed in this PR

Preserves HTTP correlation metadata when Copilot Responses streams end without a terminal completion, addressing #344706 without treating incomplete streams as successful.

Changes:

  • Retains HTTP request metadata independently of streamed completions.
  • Uses retained metadata in the no-choices fallback while preserving completion-derived values and existing classifications.
  • Adds six regression and control cases covering incomplete streams, valid completion, explicit errors, and absent correlation headers.
File Description
extensions/​copilot/​src/​platform/​openai/​node/​fetch.ts Adds optional HTTP correlation metadata to ChatResults.
extensions/​copilot/​src/​extension/​prompt/​node/​test/​chatMLFetcherResponseApiTelemetry.spec.ts Tests correlation retention through the real Responses parser and final classifier.
extensions/​copilot/​src/​extension/​prompt/​node/​chatMLFetcher.ts Captures HTTP metadata and uses it when no completion supplies correlation.

Review effort: Balanced

@dileepyavan
Dileep Yavanmandha (dileepyavan) merged commit f044b24 into main Nov 2, 2026
56 checks passed
@dileepyavan
Dileep Yavanmandha (dileepyavan) deleted the agents/fix-responses-request-id-344706 branch November 2, 2026 20:58
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot LM API: Responses HTTP request ID is lost when the stream ends after reasoning

4 participants