Skip to content

feat: chat-responses-reasoning#602

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

feat: chat-responses-reasoning#602
zijiren233 merged 2 commits into
labring:mainfrom
zijiren233:chat-responses-reasoning

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 enhances OpenAI Responses→Chat Completions compatibility by adding support for reasoning summaries, and tightens request/response body-detail handling for safer logging and persistence (including dropping invalid UTF-8 and skipping request bodies for certain upstream-only status codes).

Changes:

  • Map Responses API reasoning summaries into Chat Completions reasoning_content (both non-stream and stream delta events).
  • Improve body-detail capture/storage: drop invalid UTF-8 bodies, refine error logging to include only available details, and skip saving request bodies for specific status codes unless forced.
  • Refactor permission checks by introducing ChannelStatusHasPermission(statusCode int) and add targeted unit tests.

Reviewed changes

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

Show a summary per file
File Description
core/relay/plugin/monitor/monitor.go Adds status-code-based permission helper and keeps existing error-based wrapper.
core/relay/plugin/monitor/monitor_test.go Tests ChannelStatusHasPermission behavior for relevant HTTP codes.
core/relay/model/response.go Adds InputItemTypeReasoning constant for consistent output item typing.
core/relay/controller/handle.go Adds request-body skip policy helper and refactors debug error logging into logHandleError.
core/relay/controller/dohelper.go Centralizes body-detail conversion, adds UTF-8 validation behavior, and refines response body capture helpers.
core/relay/controller/dohelper_test.go Adds tests for invalid UTF-8 body dropping and logging behavior.
core/relay/adaptor/openai/chat.go Converts Responses reasoning summaries/deltas into Chat Completions reasoning_content.
core/relay/adaptor/openai/chat_test.go Adds coverage for reasoning effort mapping, summary mapping, and stream delta mapping.
core/model/log.go Adds RequestDetail.DropInvalidUTF8Bodies() to sanitize stored log bodies.
core/model/log_test.go Tests invalid UTF-8 body dropping and truncated-flag behavior.
core/controller/relay-controller.go Extracts request-detail build logic, applies UTF-8 dropping, and conditionally clears request bodies based on status.
core/controller/relay-controller_test.go Tests request-detail retention/clearing and invalid UTF-8 dropping across status scenarios.

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

Comment thread core/relay/controller/handle.go Outdated
Comment on lines +40 to +44
func logHandleError(log *logrus.Entry, respErr adaptor.Error, detail *BodyDetail) {
if detail == nil || !config.DebugEnabled {
log.Errorf("handle failed: %+v", respErr)
return
}
Comment thread core/relay/controller/dohelper_test.go Outdated
Comment on lines +407 to +411
oldDebug := config.DebugEnabled
config.DebugEnabled = true
t.Cleanup(func() {
config.DebugEnabled = oldDebug
})
@zijiren233 zijiren233 merged commit 3092a51 into labring:main Jun 13, 2026
14 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