Skip to content

fix(avatar): resolve duplicate avatars in multi-agent conversations#123

Merged
hongxicheng merged 5 commits into
agentscope-ai:mainfrom
zhijianma:fix/avatar
Mar 5, 2026
Merged

fix(avatar): resolve duplicate avatars in multi-agent conversations#123
hongxicheng merged 5 commits into
agentscope-ai:mainfrom
zhijianma:fix/avatar

Conversation

@zhijianma
Copy link
Copy Markdown
Member

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

As title says.

  • Code has been formatted with npm run format command in the root directory
  • Docstrings/comments are in appropriate style (TSDoc/JSDoc for TypeScript/JavaScript, Google style for Python)
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @zhijianma, 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 an issue where multiple agents in a multi-agent conversation could be assigned identical avatars. It introduces a comprehensive solution by implementing a new unique avatar assignment system that pre-calculates and maps distinct avatar paths to each agent's name, ensuring visual differentiation and enhancing the clarity of multi-agent interactions.

Highlights

  • Unique Avatar Assignment: Implemented a new strategy to ensure each agent in a multi-agent conversation receives a unique avatar, resolving previous duplication issues.
  • Refactored Avatar Selection Logic: Replaced the previous hash-based avatar path selection with a seededShuffle and assignUniqueAvatars mechanism for more robust and distinct assignments.
  • Component Prop Update: Modified the AsAvatar component to accept a pre-assigned avatarPath directly, simplifying its usage and centralizing avatar assignment logic.
Changelog
  • packages/client/src/components/chat/AsChat/avatar.tsx
    • Removed the hashString and getAvatarPathByName utility functions.
    • Added getFilteredPaths, seededShuffle, and assignUniqueAvatars functions to manage avatar selection and assignment.
    • Updated the AsAvatar component to accept an avatarPath prop instead of avatarSet and seed.
  • packages/client/src/components/chat/AsChat/index.tsx
    • Imported the new assignUniqueAvatars function.
    • Introduced a useMemo hook to precompute a map of unique avatar assignments for all active agents.
    • Modified the AsAvatar component instantiation to use the precomputed avatarPath.
Activity
  • No human activity (comments, reviews, etc.) has occurred on 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

@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 robust mechanism for assigning unique avatars to agents in a multi-agent conversation, effectively resolving potential duplicate avatars. The approach of pre-computing avatar assignments using a seeded shuffle is sound. The refactoring of the AsAvatar component to accept a pre-assigned path simplifies its logic and is a good improvement. I've identified a potential race condition in an asynchronous operation within the AsAvatar component and provided a suggestion to address it. Overall, this is a great fix.

Comment thread packages/client/src/components/chat/AsChat/avatar.tsx
@zhijianma zhijianma requested a review from hongxicheng March 5, 2026 08:42
@hongxicheng hongxicheng merged commit ce281bd into agentscope-ai:main Mar 5, 2026
4 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.

[Bug]:There is a relatively high probability that different characters will have the same avatar.

2 participants