Assistant API overriding instructions

I’ve developed an app integrating an Assistant through the OpenAI interface. Accessing the Assistant by ID and initiating a thread without additional instructions works flawlessly, adhering to my predefined guidelines.

However, problems occur when I attempt to append extra instructions to a thread. It seems that the Assistant disregards all previous settings and solely follows the new instructions provided in the Thread, hence making it forget its name, how it should answer, etc.

Here’s the JavaScript snippet where the issue happens:

    const run = await openai.beta.threads.runs.create(thread.id, {
      assistant_id: assistant.id,
      instructions: custom_instructions // <-- The assistant only follows these instructions, ignoring the pre-set guidelines.
    });
1 Like

Welcome to the developer forum,

It looks like you are not appending messages to the threads, that seems to be just creating a new thread with it’s initial instruction set.

Basically, you can append messages to threads, and you can change the instructions, but if you want to add more instructions, then add them to the existing instructions, you’re replacing them with that line.

1 Like

Hmm, so in this case I would have to do it like this?

 const run = await openai.beta.threads.runs.create(thread.id, {
      assistant_id: assistant.id,
      instructions: assistant.instructions +  custom_instructions
    });
1 Like

Yea, worth giving that a try, maybe append a space in the middle.

Hi, can you tell me what if I don’t want to add the instructions while running the threads runs function I want to update the instructions for all threads? One use case is once I publish my bot and in production, I want to fix the instructions and don’t want to lose the threads that my users have already created. Is there any way to do that? Or do I need to make a customer_instructions and every time I need to add that in threads? runs?

1 Like

Hi @Foxalabs

I am curious - what is the difference in doing the approach you defined above and using client.beta.assistants.update()

Does the .update() endpoint update the saved assistant and the approach above only update the assistant for the specified thread?

It was just that the instructions were being overwritten, so I suggested appending the new instruction to the old one as a test.

guys, does ‘runs’ instructions still works for you? They suppose to override the assistant base instructions, but instead if I add instructions like this:

const run = await openai.beta.threads.runs.create(thread.id, {
      assistant_id: req.iparams.assistantId,
      instructions: "start your reply with 'AAAAAAAAAAAAAAAA: '",
    });

the instructions are completely ignored , even considering I’m seeing them in the run object

run {
...
  model: 'gpt-3.5-turbo-1106',
  instructions: "start your reply with 'AAAAAAAAAAAAAAAA: '",
...
}

if I don’t provide run instructions

const run = await openai.beta.threads.runs.create(thread.id, {
      assistant_id: req.iparams.assistantId,
    });

it works ok and follow the instructions that assistant been created with.

Does anyone else have this problem? any workaround?

–kr

1 Like

We have been discussing this issue here: Assistants API feature Adjustment| Thread run Optional Instruction - #2 by nikunj

The short version answer to the question here: The optional instruction when initiating a run is meant to override the Assistant’s Instruction

thanks, @derrickob. Yeah, I get it that it’d rewrite the assistant’s instruction, but the problem was, it won’t follow the new (provided, re-written) instructions. But eventually, it turned out, that the new instructions are actually works, but for some reason, assistant just did not want to follow them. I’ve tried many different combinations and sometimes the instructions are eventually followed. So my question could be closed with resolution: “it depends on the will of assistant to follow the instructions provided”. Thanks for looking into this anyway.

Hello everyone, I wanted to inform you that in the recent openai@4.24.1 update, a new field named ‘additional_instructions’ has been added for Runs. This feature enables you to add to the existing assistant instructions rather than replacing them entirely. This might be useful for those who are looking to incorporate dynamic instructions in their projects. I hope you find this information helpful.

2 Likes

this might help.

2 Likes

hi,

I tried to use the additional_instructions and I have some questions:

  1. It works for me only if it is the first run on the thread. Why?
  2. It works only if I add a message with content to the thread (user=‘user’ and content !=‘’). Is this what expected?
  3. Should the additional_instructions affect the thread or only the run that added them?
  4. We need to add additional instructions (‘system’ prompt) duting the chat thread that will affect everything within the thread, but not other threads (that need a differsnt instructions according to the context. What is the best practice for doing that? and you share an example?

Thanks,
Yohay

4 Likes