baibot icon indicating copy to clipboard operation
baibot copied to clipboard

The bot cannot distinguish between different users

Open CybotTM opened this issue 1 year ago • 6 comments

When starting a thread with Baibot, it seems the Baibot doesn't recognize multiple participants in the thread.

He always answers to the thread opener.

John:

!bai - kannst du dir dinge merken?

baibot:

Ich kann Informationen innerhalb des aktuellen Chats ...

Sebastian:

Gute Neuigkeiten, mit dem nächsten Update für dich, kennst du dann auch immer die aktuelle Zeit und Datum.

baibot:

Das klingt wirklich spannend, John! 🎉😄

Wenn es mit dem nächsten Update tatsächlich möglich wird, ...

And he does not understand that not every message in the thread addresses him exclusively.

Is this a known behaviour? Is there some way to tweak this?

It seems the author of a message is missing in the query, right?

Thanks for your help.

CybotTM avatar Oct 09 '24 06:10 CybotTM

It seems like the last-but-one message is from Sebastian and the bot correctly replied as a result of it.

This means that the bot considers Sebastian an authorized bot user and responds to messages by him.

It just cannot differentiate between different users.


Perhaps your issue would be better phrased: "The bot cannot distinguish between different users".

This is true. The bot only sees role=assistant for its own messages and role=user for user messages sent to the chat completion API. It doesn't receive the name of the person talking to it.

From a usability perspective, it'd be great if API automatically received the name of people talking to it.

From a privacy perspective, not sending names could be seen as a feature that allows you to hide all your bot users behind the same role=assistant identifier. If you have many many users, this works even better, because it allows individuals to "hide in the crowd".

From the perspective of a server admin who wants to be in control and have traceability (in case something happens and OpenAI provides fulls logs which include names), perhaps sending static Matrix IDs to the API would work best in letting the server admin figure out who sent what to the bot.

There's lots of variation and different people will have different opinions about this.


To allow for the bot to distinguish between users, we need to:

  • start making use of the optional name field (messages[*].name) to provide a name, not just a role. See the chat completion request parameters

  • make it possible for people to enable this user-exposing behavior and possibly default it to "disabled" to retain privacy

  • possibly make the name that gets sent configurable. I can think of at least the following options (discussed here):

    • Don't send: never sends a name for anyone (the current behavior of baibot)
    • Auto-Generate identifier: sends an auto-generated identifier (likely derived from the Matrix ID of the person and possibly the current conversation thread id). Making identifiers different per-thread allows for better anonymization
    • Matrix ID: sends the Matrix ID of the person (e.g. @john:example.com)
    • Display Name: sends the display name of the person (e.g. John). This display name could be different in different rooms and could change over time
    • Matrix ID + Display Name (a combination of the Matrix ID and the Display Name). This could be useful to guarantee uniqueness, as multiple users can share the same display name and get the bot confused

To pass the current test (mentioned by you in this issue), perhaps even unique (auto-generated) identifiers would work. If the bot associates name=91a2764c-2d89-4870-80ab-59d07fe776c9 with John (because John previously shared his name in the conversation), then it may remember it for later and refer to the user as John (not as 91a2764c-2d89-4870-80ab-59d07fe776c9).

That said:

  • I haven't verified if this works
  • The bot may refer to the 91a2764c-2d89-4870-80ab-59d07fe776c9 user by that name, unless the user explicitly shared his real name ( John). Having to share your name each and every time can be annoying - usability is poor compared to sending your Display Name by default, etc.

For many others (who mostly use the bot 1-on-1 or in rooms where it doesn't matter "who said what"), this potential feature may only decrease privacy and not offer real benefits.

spantaleev avatar Oct 09 '24 07:10 spantaleev

Just as an FYI, I tested out the optional "name" parameter for OpenAI and it works exactly how you expect it to. Passing this allows the bot to distinguish between different users.

jhsparks avatar May 17 '25 15:05 jhsparks

I'm definitely in favor of at least passing "Matrix ID" for my use case.

jhsparks avatar May 17 '25 15:05 jhsparks

Just as an FYI, I tested out the optional "name" parameter for OpenAI and it works exactly how you expect it to. Passing this allows the bot to distinguish between different users.

Do you mind sharing where you made this change? This is a limiting factor for my use case and would make my life easier. I've already dug through the code a bit trying to figure out where to make the change but any headstart you can provide would be great

electronite avatar Nov 08 '25 20:11 electronite

@electronite

In src/agent/provider/openai/utils.rs:

Image Image Image

In src/agent/provider/openai/controller.rs:

Image

jhsparks avatar Nov 08 '25 21:11 jhsparks

@jhsparks thank you so much!

electronite avatar Nov 08 '25 22:11 electronite