Skip to content

fix: chat responses mode finish_reason#601

Merged
zijiren233 merged 2 commits into
labring:mainfrom
zijiren233:chat-responses-finish_reason
Jun 13, 2026
Merged

fix: chat responses mode finish_reason#601
zijiren233 merged 2 commits into
labring:mainfrom
zijiren233:chat-responses-finish_reason

Conversation

@zijiren233

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

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 adjusts the OpenAI Responses→Chat Completions adapter so finish_reason is correctly derived when using Responses API-backed models, including streaming support for response.incomplete and tool-call termination.

Changes:

  • Add responseToChatFinishReason to map Responses API incomplete_details.reason into Chat Completions finish_reason.
  • Update streaming conversion to emit a final chunk for response.incomplete and to use tool_calls when a tool call occurred.
  • Update non-stream conversion to produce choices for function-call output items and to handle responses that contain no message items.

Reviewed changes

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

File Description
core/relay/adaptor/openai/chat.go Maps Responses status/incomplete reasons to chat finish_reason, adds tool-call finish reason handling, and supports response.incomplete in streaming.
core/relay/adaptor/openai/chat_test.go Adds test coverage for incomplete responses (reasoning-only, content filter) and tool-call-only scenarios in both non-stream and stream conversions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1269 to +1276
case "", relaymodel.InputItemTypeMessage:
choice := relaymodel.TextResponseChoice{
Index: len(chatResp.Choices),
Message: relaymodel.Message{
Role: outputItem.Role,
Content: "",
},
}
Comment thread core/relay/adaptor/openai/chat.go Outdated
},
},
},
FinishReason: relaymodel.FinishReasonToolCalls,
@zijiren233 zijiren233 merged commit 739bbfa into labring:main Jun 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants