Emit explicit message item types in Responses API serializer#318169
Open
jimstrang wants to merge 3 commits into
Open
Emit explicit message item types in Responses API serializer#318169jimstrang wants to merge 3 commits into
jimstrang wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the Responses API request body generation to emit explicit type: 'message' for user/system message inputs (and for user messages synthesized from tool-result images), and adds/updates tests to lock in the new wire format.
Changes:
- Add tests asserting
type: 'message'is emitted for system/user inputs and for tool-result image attachment messages. - Update existing tests to include
type: 'message'in expectations for sliced inputs. - Update request-body construction to always include
type: 'message'for user/system message items.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| extensions/copilot/src/platform/endpoint/node/test/responsesApi.spec.ts | Adds/updates unit tests to validate explicit type: 'message' in request input items. |
| extensions/copilot/src/platform/endpoint/node/responsesApi.ts | Ensures generated Responses API input items for system/user messages include type: 'message'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #318125.
Adds explicit
type: 'message'fields when converting user/system message items to the OpenAI Responses API input format.I found this while validating the Azure BYOK work in #318118, tracked by #318110, #318111, and #318114. Once the auth/provider/scope pieces were working, the newer Azure AI Foundry
openai/v1/responsesstyle endpoint exposed a shared request-shape bug: user/system Responses input items were missing the explicittype: 'message'discriminator and failed withinvalid_valueforinput[1].This updates the shared Responses API serializer so that:
Raw.ChatRole.Useremits{ type: 'message', role: 'user', ... }Raw.ChatRole.Systememits{ type: 'message', role: 'system', ... }{ type: 'message', role: 'user', ... }Some Responses-compatible backends are strict about message item shape and reject input items that omit the
typediscriminator, even whenroleandcontentare present.Validation
Automated tests:
responsesApi.spec.tsresponsesApiToolSearch.spec.tsLive validation:
Default signed-in Copilot Responses path:
Raw.ChatRole.SystemandRaw.ChatRole.Userboth reached the shared Responses serializer with explicittype: 'message'Azure Government BYOK Responses path:
Raw.ChatRole.SystemandRaw.ChatRole.Usermessage serializationAzure AI Foundry BYOK Responses path:
openai/v1/responsesstyle endpoint using Microsoft authRaw.ChatRole.SystemandRaw.ChatRole.Usermessage serializationOpenAI-compatible non-Azure BYOK Responses path:
customendpointwithapiType: responsesRaw.ChatRole.SystemandRaw.ChatRole.Usermessage serializationTool-result image follow-up path:
asImages.lengthbranch emitted an explicittype: 'message'user follow-up item