Skip to content

Conversation

Jintao-Huang
Copy link
Collaborator

No description provided.

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.

Summary of Changes

Hello @Jintao-Huang, 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 focuses on updating and refining the GLM-4.5 agent template. The changes primarily involve enhancing how tool responses and specific tokens like <|observation|> are processed during message encoding, ensuring more accurate and robust template application. Additionally, general improvements to message content handling and data integrity during encoding have been implemented, complemented by the introduction of a new test case to validate the GLM-4.5 template's functionality.

Highlights

  • GLM-4.5 Template Refinement: The GLM-4.5 template's logic for handling tool call responses and special tokens like <|observation|> has been refined, ensuring cleaner and more accurate message processing.
  • Improved Message Content Processing: The stripping of </answer> tags from assistant messages has been made more robust, preventing partial content removal and ensuring correct message formatting.
  • Data Integrity in Encoding: Input messages are now deep-copied before encoding, which prevents unintended modifications to the original data and ensures data integrity throughout the template processing pipeline.
  • New Test Coverage: A dedicated test case for the GLM-4.5 template has been added, validating its encoding behavior and ensuring the new changes function as expected.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 updates the agent template for glm4.5 and includes a critical bug fix in string manipulation. The changes to support the glm4.5 template seem reasonable, including preventing side effects by deep-copying messages. The bug fix in utils.py correctly replaces a faulty rstrip call with a more robust endswith check. A new test for glm4.5 has been added, which is great. However, a hardcoded CUDA_VISIBLE_DEVICES setting in the test file should be removed to ensure test portability.

Comment on lines 60 to 62
message['content'] = message['content'].split('<answer>')[-1].rstrip()
if message['content'].endswith('</answer>'):
message['content'] = message['content'][:-len('</answer>')].strip()
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This is an excellent and critical fix. The previous implementation using rstrip('</answer>') was incorrect because str.rstrip(chars) treats its argument as a set of characters to remove from the end, not as a suffix string. For example, 'great</answer>'.rstrip('</answer>') would incorrectly result in 'g'. The new implementation using endswith and slicing is robust and correctly removes the suffix. Great catch!

@@ -1,6 +1,7 @@
import os

os.environ['SWIFT_DEBUG'] = '1'
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1,2,3'
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Hardcoding CUDA_VISIBLE_DEVICES in a test file is not recommended as it can cause tests to fail on machines with different GPU configurations (e.g., fewer than 4 GPUs, or no GPUs) or for other developers. This kind of configuration should be managed by the environment where the tests are run (e.g., a CI script or a local shell setup) rather than in the code itself. Please consider removing this line to improve test portability.

@Jintao-Huang
Copy link
Collaborator Author

#5305

@Jintao-Huang Jintao-Huang merged commit 85f519f into modelscope:main Aug 25, 2025
1 of 2 checks passed
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.

2 participants