Skip to content

Preserve Responses API output item order#326410

Draft
dileepyavan wants to merge 3 commits into
mainfrom
DileepY/318813
Draft

Preserve Responses API output item order#326410
dileepyavan wants to merge 3 commits into
mainfrom
DileepY/318813

Conversation

@dileepyavan

@dileepyavan dileepyavan commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve the original Responses API ordering of assistant message, reasoning, and compaction items when replaying stateless history
  • propagate message and reasoning output_index metadata through tool-call rounds
  • render commentary before reasoning when that is the order returned by the API
  • add regression coverage for stream metadata, request serialization, and prompt rendering

fixes #318813

Copilot AI review requested due to automatic review settings July 17, 2026 21: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

Preserves Responses API output ordering when replaying stateless tool-call history.

Changes:

  • Propagates message and reasoning output indices.
  • Serializes assistant, reasoning, and compaction content in rendered order.
  • Adds stream, serialization, and prompt-rendering regression tests.
Show a summary per file
File Description
extensions/copilot/src/platform/thinking/common/thinking.ts Adds reasoning output-index metadata.
extensions/copilot/src/platform/networking/common/fetch.ts Exposes message output indices in response deltas.
extensions/copilot/src/platform/endpoint/node/test/responsesApi.spec.ts Tests serialization and streamed indices.
extensions/copilot/src/platform/endpoint/node/responsesApi.ts Preserves content order and emits indices.
extensions/copilot/src/extension/prompts/node/panel/toolCalling.tsx Reorders replayed response and reasoning content.
extensions/copilot/src/extension/prompts/node/panel/test/toolCalling.spec.ts Tests commentary-before-reasoning rendering.
extensions/copilot/src/extension/prompt/common/toolCallRound.ts Stores output-index metadata.
extensions/copilot/src/extension/prompt/common/intents.ts Extends the tool-round contract.
extensions/copilot/src/extension/intents/node/toolCallingLoop.ts Accumulates and propagates message indices.

Review details

  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment on lines +142 to +144
const responsePrecedesThinking = round.responseOutputIndex !== undefined
&& round.thinking?.outputIndex !== undefined
&& round.responseOutputIndex < round.thinking.outputIndex;
<AssistantMessage toolCalls={assistantToolCalls}>
{statefulMarker}
{responsePrecedesThinking ? phase : undefined}
{responsePrecedesThinking ? round.response : undefined}
@dileepyavan
dileepyavan marked this pull request as draft July 18, 2026 00:43
@dileepyavan dileepyavan added the ~requires-eval-assessment Evals will be run and will generate a report upon completion label Jul 18, 2026
@vs-code-engineering

Copy link
Copy Markdown
Contributor

❌ Failed to queue vscode build for 6ac8a16200a8f0a2d1948271f072b1350861af5b due to an Azure DevOps permission issue — eval-assessment did not start.

The federated identity vscode-bot-managed-identity is missing Queue builds permission on pipeline ⭐️ VS Code (id 111) in project Monaco.

Fix: in Azure DevOps, open the pipeline → ⋮ → Security, and grant vscode-bot-managed-identity the Queue builds permission, then re-apply the ~requires-eval-assessment label.

az pipelines run output
WARNING: Auto-detect was enabled but no Azure DevOps remote was found in the current git repository. Ensure your git remote points to an Azure DevOps URL (e.g., https://dev.azure.com/MyOrganization/...).
{
  "createdDate": "2026-07-18T00:46:10.032760+00:00",
  "finalYaml": null,
  "finishedDate": null,
  "id": 456878,
  "name": "20260718.4 (insider)",
  "pipeline": {
    "folder": "\\VS Code",
    "id": 111,
    "name": "⭐️ VS Code",
    "revision": 108,
    "url": "https://dev.azure.com/monacotools/a6d41577-0fa3-498e-af22-257312ff0545/_apis/pipelines/111?revision=108"
  },
  "resources": {
    "repositories": {
      "self": {
        "refName": "refs/pull/326410/merge",
        "repository": {
          "connection": {
            "id": "f793c475-5810-4ec1-8665-9856460d64f0"
          },
          "fullName": "microsoft/vscode",
          "type": "gitHub"
        },
        "version": "ae1317842168760dbacaf038c9af4f93a44f9b48"
      }
    }
  },
  "result": null,
  "state": "inProgress",
  "templateParameters": {
    "CARGO_REGISTRY": "sparse+https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/Cargo/index/",
    "NPM_REGISTRY": "https://pkgs.dev.azure.com/monacotools/Monaco/_packaging/vscode/npm/registry/",
    "VSCODE_BUILD_ALPINE": "false",
    "VSCODE_BUILD_ALPINE_ARM64": "false",
    "VSCODE_BUILD_LINUX": "true",
    "VSCODE_BUILD_LINUX_ARM64": "false",
    "VSCODE_BUILD_LINUX_ARMHF": "false",
    "VSCODE_BUILD_LINUX_SNAP": "false",
    "VSCODE_BUILD_MACOS": "false",
    "VSCODE_BUILD_MACOS_ARM64": "false",
    "VSCODE_BUILD_MACOS_UNIVERSAL": "false",
    "VSCODE_BUILD_TYPE": "Product",
    "VSCODE_BUILD_WEB": "false",
    "VSCODE_BUILD_WIN32": "false",
    "VSCODE_BUILD_WIN32_ARM64": "false",
    "VSCODE_CLI_CANARY_VERSION": "auto",
    "VSCODE_PUBLISH": "true",
    "VSCODE_QUALITY": "insider",
    "VSCODE_RELEASE": false,
    "VSCODE_SDK_CANARY_VERSION": "none",
    "VSCODE_STEP_ON_IT": "true",
    "VSCODE_USE_LEGACY_OSS_NOTICE": false
  },
  "url": "https://dev.azure.com/monacotools/a6d41577-0fa3-498e-af22-257312ff0545/_apis/pipelines/111/runs/456878",
  "variables": null
}

@vs-code-engineering vs-code-engineering Bot removed the ~requires-eval-assessment Evals will be run and will generate a report upon completion label Jul 18, 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.

Preserve Original Prompt Structure When Constructing CAPI Responses API Input Messages

2 participants