Assistants API - Access to multiple assistants

So I’ve been playing around with panels of Assistants, and the shared thread approach works. From my experiments it works best if you do the following in the instructions for each Assistant:

  1. Tell the Assistant its name. They don’t have access to the “name” parameter for assistants.create().
  2. Tell the Assistant to always respond with "$name: " so we know who is doing the talking.
  3. Optional, but it can be helpful to tell the Assistants the names of the other Assistants, as well as some information about their purpose or specialty.

If you want to select the order the Assistants respond, this is all you need to do. You can do a simple round robin, or you can use some other logic.

You might instead want the Assistants to determine who speaks next. You could do this in a free-flowing conversation by asking each Assistant who should respond next, or you can have a moderator Assistant who chooses who speaks next. The trick here is parsing the reply to determine who should respond next. I had trouble getting this to work reliably, so I instead created a bogus function with one parameter, Name, and in the instructions told the Assistants they should use this function to determine who goes next. When the Run indicates a function call is waiting, my code notes the Name and Prompt and then returns an empty function completion to the Run. Then the code has the named agent respond next.

There are lots of variations on this approach. The key thing is to make sure the Assistants have a thread where it is clear who said what.

An alternative approach is to have a separate thread for each Assistant, and use user messages to tell each Assistant what happened. For example imagine Alice and Bob, who are both riddle master Assistants. The chat begins by the user prompting Alice to give Bob a riddle. Alice responds on its own thread, and the code takes the response and sends it as a user message on Bob’s thread. And so forth. So after a few rounds, you’ll have something like this:

Alice’s thread

  1. user: Give Bob a riddle
  2. assistant: Bob, here’s a riddle. I speak without a mouth and hear without ears. I have no body, but I come alive with the wind. What am I?
  3. user: Bob said “It’s an echo.”
  4. assistant: Bob is correct. Now I want him to give me a riddle.

Bob’s thread

  1. user: Alice said: “Bob, here’s a riddle. I speak without a mouth and hear without ears. I have no body, but I come alive with the wind. What am I?”
  2. assistant: An echo.
  3. user: Alice said: “Bob is correct. Now I want him to give me a riddle.”

I haven’t come up with any great reason to use this model, however.