Skip to content

agentHost: use Responses API for BYOK models - #328146

Merged
Vritant Bhardwaj (vritant24) merged 10 commits into
mainfrom
agents/byok-agent-host-api-translation-review
Jul 31, 2026
Merged

Vritant Bhardwaj (vritant24) merged 10 commits into
mainfrom
agents/byok-agent-host-api-translation-review

Conversation

@vritant24

@vritant24 Vritant Bhardwaj (vritant24) commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • replace the Agent Host BYOK Chat Completions proxy contract with OpenAI Responses
  • preserve ordered text, structured reasoning, encrypted reasoning state, function/custom tool calls, usage, and continuation data across the renderer bridge
  • support the SDK's default non-streaming Responses path and stream: true SSE
  • opt into encrypted thinking only for Agent Host BYOK requests so other vscode.lm consumers retain their existing behavior
  • round-trip OpenAI encrypted reasoning and provider continuation metadata such as Anthropic signatures/redacted thinking and Gemini thought signatures
  • preserve all assistant text parts and keep reasoning chunks separated by reasoning ID
  • add focused unit coverage and a real Copilot SDK multi-turn reasoning integration test

Why

The Chat Completions translation loses fidelity for thinking-capable models and tool continuations. Responses provides first-class reasoning and output items that match the Copilot SDK agent loop more closely. Some providers also require opaque reasoning state on later turns; this change carries that state only for the Agent Host BYOK path.

Testing

  • npm run typecheck-client
  • npm --prefix extensions/copilot run typecheck
  • targeted Agent Host BYOK translation, proxy, handler, channel, launcher, and prompt-rendering tests
  • ./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/providerIntegration/copilotByokResponses.integrationTest.ts
  • core and Copilot builds
  • precommit hygiene

Preserve structured reasoning, tool calls, continuation metadata, and usage across the Agent Host renderer bridge while replacing the Chat Completions proxy contract.

Co-authored-by: Copilot <[email protected]>

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

Replaces the Agent Host BYOK Chat Completions proxy with OpenAI Responses, preserving structured outputs and continuation state.

Changes:

  • Adds Responses request, response, and SSE translation.
  • Bridges reasoning, tools, usage, and continuation metadata.
  • Expands unit and SDK integration coverage.
Show a summary per file
File Description
agentHostByokLmHandler.test.ts Tests Responses bridge mapping.
agentHostByokLmHandler.ts Translates Responses DTOs to the LM API.
copilotByokResponses.integrationTest.ts Adds SDK multi-turn integration coverage.
copilotSessionLauncher.test.ts Updates provider expectations.
byokResponsesTranslation.test.ts Tests Responses translation and SSE.
byokOpenAiTranslation.test.ts Removes Chat Completions tests.
byokLmProxyService.test.ts Tests Responses proxy routes.
byokLmBridgeRegistry.test.ts Updates result fixtures.
agentHostClientByokLmChannel.test.ts Tests structured DTO round-tripping.
copilotSessionLauncher.ts Selects the Responses wire API.
byokResponsesTranslation.ts Implements Responses translation.
byokOpenAiTranslation.ts Removes Chat Completions translation.
byokLmProxyService.ts Serves JSON and SSE Responses requests.
agentHostByokLm.ts Defines structured bridge DTOs.
languageModelAccessPrompt.tsx Aggregates reasoning parts and metadata.
languageModelAccess.ts Exposes encrypted reasoning parts.

Review details

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostByokLmHandler.ts:267

  • Metadata-only reasoning callbacks become blank summary entries. The Responses processor emits a thinking callback without text for every response.reasoning_summary_part.done and again for the encrypted item completion; languageModelAccess.ts converts each missing text to ''. Appending those values produces summaries such as ['first', '', 'second', '', ''] and the proxy emits spurious empty reasoning parts. Filter empty callback values while still merging their metadata.
		const summary = Array.isArray(part.value) ? part.value : [part.value];
  • Files reviewed: 16/16 changed files
  • Comments generated: 3
  • Review effort level: Medium

Carry encrypted reasoning through a private data part only for Agent Host BYOK requests, preserving existing vscode.lm behavior for other consumers.

Co-authored-by: Copilot <[email protected]>
Replace the Agent Host BYOK model-options sentinel and private MIME payload with a typed provider request option while retaining encrypted thinking metadata only for opted-in requests.

Co-authored-by: Copilot <[email protected]>
Keep assistant text complete, group reasoning chunks by ID, and round-trip provider-specific continuation metadata through Responses encrypted content.

Co-authored-by: Copilot <[email protected]>

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

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.

Review details

Comments suppressed due to low confidence (2)

src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostByokLmHandler.ts:300

  • This branch cannot currently preserve Anthropic redacted_thinking as claimed. anthropicProvider.ts:638-642 captures the redacted blob, but anthropicProvider.ts:772-774 only clears it and never reports a LanguageModelThinkingPart containing metadata.redactedData; a repository-wide search shows no producer of that metadata. Consequently redactedData can never reach this encoder or be replayed by anthropicMessageConverter.ts:18-22. Emit the captured blob as reasoning metadata before clearing it and cover the round trip.
			...(this._stringMetadata(metadata, 'redactedData') ? { redactedData: this._stringMetadata(metadata, 'redactedData') } : {}),

extensions/copilot/src/extension/conversation/vscode-node/languageModelAccess.ts:849

  • Please add direct coverage for this opt-in privacy gate. The existing CopilotLanguageModelWrapper tests exercise emitted response parts, but none feeds an encrypted thinking delta and verifies both required cases: the default options suppress it, while includeEncryptedThinking: true emits it. The new proxy/integration tests fake the bridge result, so they do not execute this branch and would not catch encrypted state leaking to ordinary vscode.lm consumers.
					if (options.includeEncryptedThinking) {
						progress.report(new vscode.LanguageModelThinkingPart(
							delta.thinking.text ?? '',
							delta.thinking.id,
							{ encrypted_content: delta.thinking.encrypted },
						));
  • Files reviewed: 19/20 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@vritant24
Vritant Bhardwaj (vritant24) marked this pull request as ready for review July 30, 2026 22:10
@vritant24
Vritant Bhardwaj (vritant24) merged commit 767ea24 into main Jul 31, 2026
46 of 47 checks passed
@vritant24
Vritant Bhardwaj (vritant24) deleted the agents/byok-agent-host-api-translation-review branch July 31, 2026 00:36
@vs-code-engineering vs-code-engineering Bot added this to the 1.132.0 milestone Jul 31, 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.

4 participants