Skip to content

Improved so that the AI bot responds to personal messages and to messages in which it was mentioned #9334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

RoadRoller
Copy link

@RoadRoller RoadRoller commented Jun 23, 2025

  • Improved so that the AI bot responds to personal messages and to messages in which it was mentioned
  • Previous functionality of responding to direct messages is preserved
  • A small refactoring of checks was made to ensure that messages need to be processed
  • Added tests for the changed functionality

I would also suggest switching from the openai library to https://ai-sdk.dev in the ai-bot service so as not to depend on OpenAI as a provider, but I did not understand how to test the functionality of calling tools from the UI and I am afraid of breaking something.

Resolves #9328

Copy link

Connected to Huly®: UBERF-11731

@BykhovDenis BykhovDenis requested review from kristina-fefelova and Copilot and removed request for kristina-fefelova June 23, 2025 14:39
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors the AI bot response logic to improve the handling of personal messages and mentions while preserving existing direct message functionality. Key changes include:

  • Extraction of helper functions (findAiBotSocialIdentity, findAiBotAllSocialIds, isThreadMessage, getMessageDoc, isDirectAvailable, isAiBotShouldReplay, and OnAiBotShouldReplay) to organize message processing logic.
  • Update of message filtering and condition checks to decide when the AI bot should send a response.
  • Removal of duplicate code and streamlining of direct and thread message handling.
Comments suppressed due to low confidence (1)

server-plugins/ai-bot-resources/src/index.ts:154

  • [nitpick] Consider renaming 'isAiBotShouldReplay' to 'isAiBotShouldReply' to more clearly reflect its purpose of determining whether the AI bot should reply to a message.
): Promise<boolean> {

@RoadRoller RoadRoller force-pushed the ai-bot-improvements branch from 4917372 to 6179dba Compare June 23, 2025 19:19
…at mention it (hcengineering#9328)

Signed-off-by: Evgeny Tarasenko <tarasenko.evgeny@gmail.com>
Signed-off-by: Evgeny Tarasenko <tarasenko.evgeny@gmail.com>
@RoadRoller RoadRoller force-pushed the ai-bot-improvements branch from d245b1c to 018d43c Compare June 30, 2025 13:51
const isDirect =
messageDoc._class === chunter.class.DirectMessage && (await isDirectAvailable(messageDoc as DirectMessage, control))
const isAiBotPersonalChat = messageDoc._id === aiBotPersonId
const isAiBotMentioned = message.message.includes(aiBotPersonId)
Copy link
Member

Choose a reason for hiding this comment

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

It's not enough to check just includes(id). We need to ensure there's a mention node and inspect its attributes to confirm it's indeed referencing ai. You can look at how isDocMentioned works in server-plugins/activity-resources/src/references.ts.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, refactored with honest checking in references.

Signed-off-by: Evgeny Tarasenko <tarasenko.evgeny@gmail.com>
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.

AI Bot does not respond to personal messages and to message that mention it
2 participants