Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Update to Responses API compaction and telemetry#4931

Closed
dileepyavan wants to merge 1 commit into
mainfrom
DileepY/compaction_issue
Closed

Update to Responses API compaction and telemetry#4931
dileepyavan wants to merge 1 commit into
mainfrom
DileepY/compaction_issue

Conversation

@dileepyavan
Copy link
Copy Markdown
Member

@dileepyavan dileepyavan commented Apr 2, 2026

Summary

  • Ensure previous responseId is being passed when ignoreStatefulMarker is false.
  • add server-side compaction outcome telemetry and regression coverage for enabled and disabled compaction flows

Details

  • createResponsesRequestBody now computes the compaction threshold once and uses it to gate both request context_management and websocket stateful-marker slicing behavior
  • websocket and pass-through OpenAIResponsesProcessor call sites now receive the request compaction threshold from the request body
  • responsesApi.compactionOutcome emits only when compaction is enabled and reports the outcome, request IDs, model, threshold, and token counts
  • compaction telemetry intentionally does not include completionId or compactionMessageId

Testing

  • runTests on src/platform/endpoint/node/test/responsesApi.spec.ts (16 passed)
  • verified start-watch-tasks output showed no compile errors

Copilot AI review requested due to automatic review settings April 2, 2026 01:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 refines how the OpenAI Responses API “context-management compaction” feature is enabled and observed, ensuring compaction-specific behavior only runs when compaction is actually enabled and adding outcome telemetry plus regression coverage.

Changes:

  • Centralizes computation of the compaction threshold and uses it to gate request context_management and WebSocket stateful-marker slicing.
  • Propagates the compaction threshold into Responses API stream processors (HTTP, WebSocket, and pass-through) and emits responsesApi.compactionOutcome telemetry only when compaction is enabled.
  • Adds unit tests covering enabled/disabled compaction flows and telemetry emission behavior.

Reviewed changes

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

Show a summary per file
File Description
src/platform/networking/node/chatStream.ts Adds responsesApi.compactionOutcome telemetry emitter helper with GDPR annotation.
src/platform/endpoint/node/responsesApi.ts Computes compaction threshold once, adjusts marker/compaction slicing, plumbs threshold into processor, and emits compaction outcome telemetry.
src/platform/endpoint/node/chatEndpoint.ts Passes computed compaction threshold through to Responses API response processing.
src/extension/prompt/node/chatMLFetcher.ts Ensures WebSocket Responses API processing receives compaction threshold parsed from request body.
src/extension/externalAgents/node/oaiLanguageModelServer.ts Ensures pass-through Responses API processing receives compaction threshold parsed from request body.
src/platform/endpoint/node/test/responsesApi.spec.ts Adds tests for request-body threshold extraction, WebSocket slicing behavior, and compaction telemetry emission gating.
.vscode/settings.json Enables terminal tool sandbox in workspace settings.
.vscode/launch.json Adds preLaunchTask: "compile" to the primary extension launch configuration.

Comment thread src/platform/endpoint/node/test/responsesApi.spec.ts
Comment thread src/platform/endpoint/node/responsesApi.ts Outdated
Comment thread src/platform/endpoint/node/responsesApi.ts
Comment thread .vscode/settings.json Outdated
Comment thread .vscode/launch.json
@dileepyavan dileepyavan changed the title Improve Responses API compaction gating and telemetry Update to Responses API compaction gating and telemetry Apr 2, 2026
@dileepyavan dileepyavan requested a review from chrmarti April 2, 2026 01:42
@dileepyavan dileepyavan changed the title Update to Responses API compaction gating and telemetry Update to Responses API compaction and telemetry Apr 2, 2026
@dileepyavan dileepyavan removed the request for review from chrmarti April 2, 2026 17:41
messages = messages.slice(statefulMarkerAndIndex.index + 1);
if (latestCompactionMessageIndex !== undefined) {
if (latestCompactionMessageIndex > statefulMarkerAndIndex.index) {
messages = messages.slice(latestCompactionMessageIndex - (statefulMarkerAndIndex.index + 1));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We still set previousResponseId in this case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This PR is no longer valid. I had to leave this, thought I closed it and made some changes in this commit: microsoft/vscode@5207a1a

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

validated the changes and for websockets compaction is being sent.

messages = messages.slice(latestCompactionMessageIndex);
}

const latestCompactionMessage = latestCompactionMessageIndex !== undefined ? createCompactionRoundTripMessage(messages[latestCompactionMessageIndex]) : undefined;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: looks like this could be moved into the if block below

@dileepyavan dileepyavan closed this Apr 9, 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.

3 participants