Any way to duplicate a Thread?

I want to be able to ask our Code Interpreter Assistant to give me the code used to arrive at an answer. But I don’t want that to affect the thread history for the user if they want to ask more questions.

Simply grabbing the RunSteps doesn’t work, because it seems like the code for each RunStep almost act as cells inside a Python Notebook, building on the last RunStep. But when you ask the Assistant, it is able to intelligently include the relevant portions of the code, rather than naively including all the steps.

It doesn’t look like you can create Steps programmatically either, I assume to avoid being able to maliciously infiltrate the environment that the code runs in

3 Likes

Nope. No duplicating or snapshot. No branching. No editing. No retrying. No re-creating. No ability to place assistant replies in a new thread. No ability to get unseen tool messages. No limiting or expiring. No obsoleting uploaded attached files. No observing what the AI is sending.

Assistants come with a mantra that as an application developer, you are not to be trusted with an AI.

Chat Completions can be turned into code interpreter, just by putting hand-specified tools before the API’s injection of the dummy function you wrote. Then doing stuff with the output. And rejecting OpenAI’s “tools” and using functions.

5 Likes

I would love to see this. There could be some really good applications to cloning a thread state for later.

It seems like can be done using thread create and message add methods . Or am I missing something?

You can only add user messages. Assistant role is blocked, so you cannot re-create a conversation. There are also tool call and return messages completely blocked.

Assistants is a denial machine.

Edit: assistant role messages can now be placed in a thread.

1 Like

Not sure if this has been properly answered already I couldnt bother to read the discussion, but a way I have been doing this is simply using the threads.messages.list function to extract the messages in a desired thread, creating a seperate messages list, and then iterating through the messages.list object while appending the objects containing roles and contents (since thats all the data you need to create an additional thread). Then you can use the threads.create with the messages parameter = the messages list created.

current_thread_messages = client.beta.threads.messages.list(thread.id)
current_messages = []

for message in current_thread_messages.data:
    current_messages.append(
        {
            "role": message.role,
            "content": message.content[0].text.value
        }
    )

current_messages.reverse()

duplicate_thread = client.beta.threads.create(messages=current_messages)