Skip to content

fix(github-copilot): GPT-5.4 should use Responses API#1064

Merged
looplj merged 1 commit intolooplj:release/v0.9.xfrom
imlonghao:fix/github-copilot-gpt-5.4
Mar 15, 2026
Merged

fix(github-copilot): GPT-5.4 should use Responses API#1064
looplj merged 1 commit intolooplj:release/v0.9.xfrom
imlonghao:fix/github-copilot-gpt-5.4

Conversation

@imlonghao
Copy link
Copy Markdown
Contributor

去掉了 codex 关键字

close #1060

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求重构了 GitHub Copilot 转换器,以通用化 Responses API 的使用。它从“codex 特定”检查转向更灵活的机制,该机制识别需要 Responses API 的模型,包括 gpt-5.4。这确保了更广泛模型的正确路由和转换。

Highlights

  • 通用化 Responses API 使用: 确定模型使用 Responses API 的逻辑已通用化。现在不仅检查“codex”模型,还检查一个预定义的、明确需要 Responses API 的模型列表(responsesOnlyModels)。
  • 支持 GPT-5.4: gpt-5.4 模型现在被明确配置为使用 Responses API。
  • 重构“codex”引用: 将内部变量和函数从 codexResponsesisCodexModel 重命名为更通用的 responsesusesResponsesAPI,以反映 Responses API 更广泛的适用性。
  • 增强测试覆盖: 增加了新的单元测试,以确保 usesResponsesAPI 逻辑对各种模型名称正确工作,并且 gpt-5.4 和 codex 模型正确路由到 Responses API 端点。
Changelog
  • llm/transformer/openai/copilot/constants.go
    • 添加了一个新的 responsesOnlyModels 映射,明确列出使用 Responses API 的模型。
    • 将 "gpt-5.4" 添加到 responsesOnlyModels 中。
  • llm/transformer/openai/copilot/outbound.go
    • OutboundTransformer 结构体中的 codexResponses 字段重命名为 responses
    • 更新了 NewOutboundTransformer 以初始化 responses 字段。
    • 修改了 TransformRequest 以使用 usesResponsesAPItransformResponsesRequest
    • 更新了 TransformResponseTransformStream 以使用通用化的 responses 转换器。
    • transformCodexResponsesRequest 重命名为 transformResponsesRequest
    • isCodexModel 重命名为 usesResponsesAPI,并更新其逻辑以包含 responsesOnlyModels
  • llm/transformer/openai/copilot/outbound_test.go
    • 添加了 TestUsesResponsesAPI 以验证新的模型检测逻辑。
    • gpt-5.4 和 codex 模型在 TestOutboundTransformer_TransformRequest 中添加了测试用例,以确认正确的 API 端点使用。
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the GitHub Copilot transformer to correctly route requests for gpt-5.4 to the Responses API. The changes generalize the logic that was previously specific to "codex" models by introducing a configurable map of models that require this API. This refactoring improves extensibility. Key functions and variables have been renamed for better clarity, such as isCodexModel to usesResponsesAPI. The pull request also includes comprehensive unit tests to validate the new logic, ensuring the changes are robust. The overall implementation is clean and enhances the maintainability of the codebase.

@imlonghao imlonghao force-pushed the fix/github-copilot-gpt-5.4 branch from a99e280 to d573e0e Compare March 15, 2026 06:51
@imlonghao
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 的目标是更新 GitHub Copilot 的转换逻辑,使其不再仅限于 codex 模型,而是能够支持使用 Responses API 的新 GPT 模型(如 GPT-5.4 及更高版本)。为此,引入了 usesResponsesAPI 函数来替代原有的 isCodexModel,通过解析模型版本号来判断应使用哪个 API。相关的字段和函数名也进行了重构,使其更具通用性(例如 codexResponses -> responses)。

整体来看,代码变更逻辑清晰,结构良好,并且为新增的逻辑编写了全面的单元测试,确保了功能的正确性。我只有一个关于代码可读性的次要建议。


// parseModelVersion parses a model version string into major and minor components.
func parseModelVersion(version string) (major int, minor int, ok bool) {
parts := strings.SplitN(version, ".", 3)
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.

medium

为了提高代码的可读性和健壮性,建议使用 strings.Split() 代替 strings.SplitN()Split() 会将版本字符串按 . 全部分割,这样代码就不依赖于版本号中点的数量(例如,处理 6.1.2.3 这样的版本),使得意图更清晰,也更符合 Go 的惯例。

Suggested change
parts := strings.SplitN(version, ".", 3)
parts := strings.Split(version, ".")

@imlonghao imlonghao force-pushed the fix/github-copilot-gpt-5.4 branch from d573e0e to f426104 Compare March 15, 2026 07:05
@imlonghao
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 的主要目标是更新判断何时使用 Responses API 的逻辑,做得很好。代码修改清晰地反映了意图,即除了 "codex" 模型外,还要支持 GPT-5.4 及更高版本的模型。

我发现 parseModelVersion 函数中存在一个关于版本字符串解析的边界情况 bug,并提供了一个修复建议。修复这个问题将使版本解析逻辑更加健壮。

除此之外,代码的重构(例如,将 codexResponses 重命名为 responses)提高了代码的可读性和通用性。相关的测试也写得很好,覆盖了大部分情况。

@looplj looplj merged commit fd9fded into looplj:release/v0.9.x Mar 15, 2026
2 checks passed
@imlonghao imlonghao deleted the fix/github-copilot-gpt-5.4 branch March 15, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug/错误]: GitHub Copilot API 格式不支持 GPT-5.4

2 participants