Skip to content

Fix BYOK invalid stateful marker retries - #317292

Merged
Dmitriy Vasyura (dmitrivMS) merged 9 commits into
microsoft:mainfrom
PenguinDOOM:atlas/vscode-byok-openai-ignorestatefulmarker
May 27, 2026
Merged

Fix BYOK invalid stateful marker retries#317292
Dmitriy Vasyura (dmitrivMS) merged 9 commits into
microsoft:mainfrom
PenguinDOOM:atlas/vscode-byok-openai-ignorestatefulmarker

Conversation

@PenguinDOOM

Copy link
Copy Markdown
Contributor

This fixes the BYOK Responses retry path for InvalidStatefulMarker errors.

When the shared retry flow retries with ignoreStatefulMarker=true, the BYOK OpenAI endpoint now preserves that explicit suppression instead of overwriting it back to false. This keeps retry requests from re-sending a stale previous_response_id while preserving the existing non-ZDR initial-request behavior and ZDR semantics.

Tests added and verified:

  • add focused BYOK regression coverage for explicit retry-time marker suppression
  • preserve non-ZDR initial-request behavior coverage
  • preserve ZDR marker suppression and store=false coverage
  • verify shared Responses API regression coverage remains green

Fixes #316747

 - add BYOK Responses retry regression for ignored stateful marker
 - preserve non-ZDR initial request and ZDR guard coverage
 - keep explicit ignoreStatefulMarker on non-ZDR retries
 - retain existing ZDR and shared Responses behavior
- clarify initial-request default vs retry override
- point retry-time override at parent retry flow
Copilot AI review requested due to automatic review settings May 19, 2026 11:20

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.

Pull request overview

This PR targets a BYOK (OpenAI-compatible) Responses API retry regression where InvalidStatefulMarker retries are supposed to re-send the request without previous_response_id, but the BYOK endpoint path can overwrite the retry’s ignoreStatefulMarker: true.

Changes:

  • Preserve an explicit ignoreStatefulMarker: true in OpenAIEndpoint.createRequestBody() while still enforcing ZDR behavior.
  • Add BYOK unit tests asserting previous_response_id inclusion/omission behavior and store semantics for ZDR vs non-ZDR.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
extensions/copilot/src/extension/byok/node/openAIEndpoint.ts Adjusts how ignoreStatefulMarker is derived for Responses bodies; updates comment around initial-request defaults in makeChatRequest2.
extensions/copilot/src/extension/byok/node/test/openAIEndpoint.spec.ts Adds regression coverage for previous_response_id suppression/preservation and ZDR store behavior.

Comment thread extensions/copilot/src/extension/byok/node/openAIEndpoint.ts Outdated
- keep caller-supplied ignoreStatefulMarker values
- add makeChatRequest2 regression coverage
@PenguinDOOM

Copy link
Copy Markdown
Contributor Author

I built and tested it locally and it works without any problems.

roblourens
roblourens previously approved these changes May 19, 2026
- add missing ChatResponse success fields
- keep makeChatRequest2 regression tests typed
@PenguinDOOM

Copy link
Copy Markdown
Contributor Author

Fixed two type checks in the tests.

@PenguinDOOM

Copy link
Copy Markdown
Contributor Author

All tests have passed, and there are no conflicts at the moment, so all that's left is the approval review.

@PenguinDOOM

Copy link
Copy Markdown
Contributor Author

Code OSS / Copilot - Test (Linux) (pull_request)
Code OSS / Linux / Remote (pull_request)
These two checks are not yet complete, and the setup is stuck for an unknown reason.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) enabled auto-merge (squash) May 27, 2026 04:41
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit c317ef0 into microsoft:main May 27, 2026
25 checks passed
@PenguinDOOM
Penguin (PenguinDOOM) deleted the atlas/vscode-byok-openai-ignorestatefulmarker branch May 27, 2026 04:44
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 27, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BYOK Responses retry for previous_response_not_found re-sends previous_response_id because OpenAIEndpoint overwrites ignoreStatefulMarker

5 participants