feat: chat-responses-reasoning#602
Merged
Merged
Conversation
There was a problem hiding this comment.
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 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 on lines
+407
to
+411
| oldDebug := config.DebugEnabled | ||
| config.DebugEnabled = true | ||
| t.Cleanup(func() { | ||
| config.DebugEnabled = oldDebug | ||
| }) |
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.
No description provided.