Skip to content

Update OpenAI Responses API compaction and telemetry#308436

Merged
dileepyavan merged 2 commits intomainfrom
Dileepy/compaction_issue
Apr 8, 2026
Merged

Update OpenAI Responses API compaction and telemetry#308436
dileepyavan merged 2 commits intomainfrom
Dileepy/compaction_issue

Conversation

@dileepyavan
Copy link
Copy Markdown
Member

Summary

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.

Details

  • Ensure the previous responseId is passed when ignoreStatefulMarker is false.
  • Centralize computation of the compaction threshold and use it to gate request context_management and WebSocket stateful-marker slicing.
  • Propagate the compaction threshold into Responses API stream processors and emit responsesApi.compactionOutcome telemetry only when compaction is enabled.
  • Add regression coverage for enabled and disabled compaction flows and telemetry emission behavior.
  • Cherry-pick the implementation from Update to Responses API compaction and telemetry vscode-copilot-chat#4931.

Testing

  • Not run in this repo as part of this push/PR creation.

Copilot AI review requested due to automatic review settings April 8, 2026 05:38
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 the OpenAI Responses API “context management / compaction” integration so that compaction-specific behavior (request shaping, stream processing, and telemetry) only occurs when compaction is actually enabled, and adds regression tests around the enabled/disabled flows.

Changes:

  • Centralizes compaction threshold computation and uses it to gate context_management request fields and compaction outcome telemetry.
  • Improves stateful-marker + compaction round-tripping so the latest compaction item is preserved even when it predates the stateful marker.
  • Adds unit tests covering request-body shaping, compaction reconciliation, and telemetry emission behavior.
Show a summary per file
File Description
extensions/copilot/src/platform/networking/node/chatStream.ts Adds a dedicated responsesApi.compactionOutcome telemetry helper + GDPR annotation.
extensions/copilot/src/platform/endpoint/node/responsesApi.ts Centralizes threshold logic, updates request shaping, reconciles latest compaction item in stream processor, emits compaction outcome telemetry when enabled.
extensions/copilot/src/platform/endpoint/node/chatEndpoint.ts Threads computed compaction threshold into processResponseFromChatEndpoint.
extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts Passes compaction threshold (derived from request body) into the Responses stream processor for WebSocket flows.
extensions/copilot/src/extension/externalAgents/node/oaiLanguageModelServer.ts Same as above for pass-through external agent streaming.
extensions/copilot/src/platform/endpoint/node/test/responsesApi.spec.ts Adds regression coverage for compaction enablement, stateful-marker slicing, compaction round-trip, and telemetry emission.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 2

Comment thread extensions/copilot/src/platform/networking/node/chatStream.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dileepyavan dileepyavan enabled auto-merge (squash) April 8, 2026 05:48
@dileepyavan dileepyavan changed the title Update Responses API compaction and telemetry Update OpenAI Responses API compaction and telemetry Apr 8, 2026
@dileepyavan dileepyavan merged commit 5207a1a into main Apr 8, 2026
37 of 38 checks passed
@dileepyavan dileepyavan deleted the Dileepy/compaction_issue branch April 8, 2026 11:13
@vs-code-engineering vs-code-engineering Bot added this to the 1.116.0 milestone Apr 8, 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.

3 participants