Unable to create messages as “assistant” role in assistant api

It appears that when using the Assistants API, the assistantsClient.createMessage(assistantThread.id,'user', content); method only functions with the role parameter set to “user” and not “assistant.” This means you can only create messages as if they were sent by a user, rather than an assistant. As for adding previous message history directly as in the chat API, it seems that this capability may not be directly available within the Assistants API

Welcome to the dev forum @hjk.arab47

The Assistants API is a stateful API where messages are managed by the Assistant and not the dev/client/user.

Simply put, you don’t need to manage the conversation history as this is one of the utilities/advantages of assistants.

Currently, assistant messages can’t be injected into the conversation history.

1 Like

if at a later point of time the user restarts the conversation then how will that happen? Does assistants api have a solution for this?
I know about thread but it can only store messages for 60 days …What if i need same conversation later…

Does this also apply when creating a thread? Because it is documented this is allowed for both roles.

  • assistant: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation.

It isn’t possible to seed the thread with user-assistant interaction?

Reason I ask is I have some system instructions in which the Assistant is instructed to use some functions but I’d like to do what one might do with Chat Completions and write some initial example dialogue with tool calls and responses to demonstrate the Assistant understands. Is this not possible at all with Assistants?

My plan was, to mock tool calls, to interrupt the example dialogue at every step (with a required call) and submit tool call results but it sounds like if I can’t add Assistant messages to an existing thread then is impossible to do what I want. Do I have that right?

If so, the documentation should probably be altered for both createThread and createMessage since it does claim it’s allowed:

API Reference - createMessage

Yes, @mdegans , it’s now possible to add assistant messages to threads. Earlier it wasn’t.

1 Like