Skip to content

[bugfix] fix qwen3_5 agent template#8161

Merged
Jintao-Huang merged 4 commits intomodelscope:mainfrom
Jintao-Huang:fix_qwen3_5_agent_templaet
Mar 2, 2026
Merged

[bugfix] fix qwen3_5 agent template#8161
Jintao-Huang merged 4 commits intomodelscope:mainfrom
Jintao-Huang:fix_qwen3_5_agent_templaet

Conversation

@Jintao-Huang
Copy link
Copy Markdown
Collaborator

No description provided.

@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!

This pull request addresses a bug by introducing a dedicated agent template for the Qwen 3.5 model, ensuring its tool calling mechanism is correctly configured. It refactors a repetitive tool description string into a constant for better code organization and updates the main Qwen template to utilize this new, specific agent template. This change improves the accuracy and maintainability of agent interactions with the Qwen 3.5 model.

Highlights

  • New Agent Template for Qwen 3.5: A new agent template, Qwen3_5AgentTemplate, has been introduced to specifically handle the Qwen 3.5 model's tool calling format.
  • Agent Template Mapping Update: The mapping.py file has been updated to include Qwen3_5AgentTemplate in the AGENT_TEMPLATE_MAPPING, allowing it to be referenced by the key 'qwen3_5'.
  • Tool Description Suffix Refactoring: A common tool description suffix string has been extracted into a new constant, TOOL_DESC_SUFFIX, in qwen3_coder.py to improve code reusability and maintainability.
  • Qwen Template Configuration: The qwen.py template now defaults to using the newly defined qwen3_5 agent template in its _post_encode method.

🧠 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.

Changelog
  • swift/agent_template/mapping.py
    • Imported the new Qwen3_5AgentTemplate.
    • Added 'qwen3_5' to the AGENT_TEMPLATE_MAPPING dictionary, associating it with the new template.
  • swift/agent_template/qwen3_coder.py
    • Defined a new constant TOOL_DESC_SUFFIX to encapsulate the detailed tool calling format description.
    • Replaced the inline tool description suffix in Qwen3CoderAgentTemplate._format_tools with the new TOOL_DESC_SUFFIX constant.
    • Introduced the Qwen3_5AgentTemplate class, inheriting from Qwen3CoderAgentTemplate, and customized its _format_tools and _get_tool_responses methods to align with Qwen 3.5 requirements.
  • swift/template/templates/qwen.py
    • Modified the _post_encode method to set the default agent_template to 'qwen3_5', ensuring the Qwen template uses the correct agent for Qwen 3.5 models.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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 introduces a new agent template for qwen3_5 and refactors some existing code for better maintainability. The changes correctly wire up the new template. However, I've found a bug in the implementation of the new Qwen3_5AgentTemplate where the system prompt is being ignored. I've provided a suggestion to fix this issue.

@Jintao-Huang
Copy link
Copy Markdown
Collaborator 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

This pull request introduces a new agent template for qwen3_5 and appears to fix its implementation as per the title. The changes include refactoring a shared prompt suffix into a constant for better code reuse, which is a good practice. A new Qwen3_5AgentTemplate class is added with specific overrides for tool formatting and response generation, tailored for the new model. The new template is also correctly registered in the mapping and used in the model template definition. Overall, the changes are logical and well-contained. I have one minor suggestion to improve code conciseness.

@Jintao-Huang Jintao-Huang changed the title [bugfix] fix qwen3_5_agent template [bugfix] fix qwen3_5 agent template Mar 2, 2026
@Jintao-Huang Jintao-Huang merged commit e1e9688 into modelscope:main Mar 2, 2026
2 of 3 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.

3 participants