Skip to content

Conversation

@utsumi-fj
Copy link

Fixes #277

Compatibility Check

  • I have checked whether this change affects the backward compatibility of the plugin declared in README.md
  • I have checked whether this change affects the forward compatibility of the plugin declared in README.md
  • If this change introduces a breaking change, I have discussed it with the project maintainer and specified the release version in the README.md
  • I have described the compatibility impact and the corresponding version number in the PR description
  • I have checked whether the plugin version is updated in the README.md

Compatibility impact

Since this is a bug fix, there is no compatibility impact.

Available Checks

  • Code has passed local tests
  • Relevant documentation has been updated (if necessary)

Before

before

After

after

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @utsumi-fj, 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 resolves a bug where the <think> block, used to encapsulate reasoning content, was not closing correctly under specific conditions, particularly when reasoning_content was an empty string. The changes refine the conditional logic for both opening and closing these blocks, ensuring proper encapsulation and preventing output formatting issues.

Highlights

  • Corrected block closure logic: The condition for closing the block has been refined to ensure it closes correctly when the reasoning process concludes, irrespective of whether reasoning_content is an empty string or None.
  • Explicit None check for opening : The logic for opening a block now explicitly checks reasoning_content is not None instead of just if reasoning_content, preventing unintended behavior when reasoning_content is an empty string.
  • Enhanced test coverage: New test cases have been added to test_wrap_thinking_logic_closure to specifically validate the behavior when reasoning_content is an empty string, ensuring the fix works as expected.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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
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 correctly addresses the bug where an empty reasoning_content string would cause the <think> block to close prematurely. The logic change to explicitly check for None is the right approach, and the removal of the redundant conditional is a good simplification. The accompanying test case has been updated to cover this specific scenario, which is excellent. However, I've identified an issue in the test's assertions that was present before this change and has been carried over. My review includes a suggestion to fix the test to make it more robust and accurate.

Comment on lines 93 to 99
assert "<think>" in full_output
assert "Thinking started. Still thinking." in full_output
assert "Thinking started. Still thinking #1. Still thinking #2." in full_output
assert "</think>" in full_output, "Should verify <think> tag is closed properly"

# Verify the position of the closing tag: should be after the thinking content
expected_part = "Thinking started. Still thinking.\n</think>"
expected_part = "Thinking started. Still thinking #1. Still thinking #2.\n</think>"
assert expected_part in full_output
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The assertions to verify the full_output are not entirely correct. The final assertion assert expected_part in full_output will fail because full_output will be "<think>\nThinking started. Still thinking #1. Still thinking #2.\n</think>", and expected_part is "Thinking started. Still thinking #1. Still thinking #2.\n</think>", which is not a substring of full_output due to the leading "<think>\n".

This issue appears to have existed before this pull request. A more robust and correct way to verify the output is to check for equality against the expected full string. This would make the test stronger and simpler, and it would correctly validate the behavior you're testing.

I suggest replacing all the individual assertions with a single self.assertEqual.

Suggested change
assert "<think>" in full_output
assert "Thinking started. Still thinking." in full_output
assert "Thinking started. Still thinking #1. Still thinking #2." in full_output
assert "</think>" in full_output, "Should verify <think> tag is closed properly"
# Verify the position of the closing tag: should be after the thinking content
expected_part = "Thinking started. Still thinking.\n</think>"
expected_part = "Thinking started. Still thinking #1. Still thinking #2.\n</think>"
assert expected_part in full_output
expected_output = "<think>\nThinking started. Still thinking #1. Still thinking #2.\n</think>"
self.assertEqual(full_output, expected_output)

Signed-off-by: Yuichiro Utsumi <utsumi.yuichiro@fujitsu.com>
@utsumi-fj utsumi-fj force-pushed the fix_multiple_think_tag branch from 4d06545 to e7d9e0a Compare January 8, 2026 09:11
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.

Empty reasoning_content chunks cause multiple <think> blocks / repeated Thoughts entries in chat UI

1 participant