fix: accept reasoning-only OpenAI completions#6115
fix: accept reasoning-only OpenAI completions#6115stablegenius49 wants to merge 1 commit intoAstrBotDevs:masterfrom
Conversation
Summary of ChangesHello, 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! This pull request enhances the system's ability to process OpenAI API responses by allowing the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Hey - 我在这里给出一些整体性的反馈:
- 新的解析条件依赖于
llm_response.reasoning_content一定存在;如果这个属性不能在所有llm_response实例上得到保证,建议在构造时统一进行初始化(例如设为None),以避免属性访问错误。 - 你可能需要增加一个负向测试用例:当
reasoning_content是空字符串(或仅包含空白字符)时,验证这种响应仍然会被视作无法解析,从而确保只接受真正“仅推理内容”的补全结果这一意图得以保持。
给 AI 智能体的提示词
Please address the comments from this code review:
## Overall Comments
- The new parsing condition relies on `llm_response.reasoning_content` being present; if that attribute is not guaranteed on all `llm_response` instances, consider initializing it consistently (e.g., to `None`) at construction to avoid attribute errors.
- You might want to add a negative test case where `reasoning_content` is an empty string (or only whitespace) to confirm that such responses are still treated as unparseable, matching the intent to only accept genuinely reasoning-only completions.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English
Hey - I've left some high level feedback:
- The new parsing condition relies on
llm_response.reasoning_contentbeing present; if that attribute is not guaranteed on allllm_responseinstances, consider initializing it consistently (e.g., toNone) at construction to avoid attribute errors. - You might want to add a negative test case where
reasoning_contentis an empty string (or only whitespace) to confirm that such responses are still treated as unparseable, matching the intent to only accept genuinely reasoning-only completions.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new parsing condition relies on `llm_response.reasoning_content` being present; if that attribute is not guaranteed on all `llm_response` instances, consider initializing it consistently (e.g., to `None`) at construction to avoid attribute errors.
- You might want to add a negative test case where `reasoning_content` is an empty string (or only whitespace) to confirm that such responses are still treated as unparseable, matching the intent to only accept genuinely reasoning-only completions.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request modifies _parse_openai_completion to correctly handle OpenAI completions that only contain reasoning_content, preventing a parsing failure. The logic is updated to consider reasoning_content as a valid output, alongside completion_text and tools_call_args. A corresponding regression test has been added to ensure these reasoning-only responses are parsed successfully. The changes are logical and the new test effectively covers the fix. The implementation looks solid.
Modifications / 改动点
allow
_parse_openai_completionto accept reasoning-only responses whencontentis empty and there are no tool callsadd a regression test covering a completion that only carries
reasoning_contentkeep the existing parse failure for completions that have neither text, tool calls, nor reasoning output
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Closes #6108.
Summary by Sourcery
处理仅包含推理内容的 OpenAI 聊天补全结果,而不再将其视为解析失败。
Bug 修复:
测试:
Original summary in English
Summary by Sourcery
Handle OpenAI chat completions that contain only reasoning content without treating them as parse failures.
Bug Fixes:
Tests: