# Consecutive assistant messages

**URL:** <https://community.openai.com/t/consecutive-assistant-messages/328097>\
**Category:** Prompting\
**Tags:** gpt-4\
**Created:** [August 23, 2023, 6:31pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097 "2023-08-23T18:31:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![amirabdi](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@amirabdi](https://community.openai.com/u/amirabdi)\
**Post date:** [August 23, 2023, 6:31pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/1 "2023-08-23T18:31:28Z")

</div>

Can a message sequence be ending with “assistant” message to hedge the response to follow a certain format? For example, can we finish the message sequence with an **assistant** message “The best item to choose from is:” so that the response only contains the final answer?

We used to do this in Completion models. We called it **hedging**. In ChatCompletion models, we are not very sure because we don’t know how conversation tags are getting inserted in the expanded prompt.

Someone might debate that the **hedging** should be done with **system** tag.

What do you think?

---

<div class="post-metadata">

**Author:** ![Foxalabs](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/foxalabs/32/738355_2.png) [@Foxalabs](https://community.openai.com/u/Foxalabs)\
**Post date:** [August 23, 2023, 6:54pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/2 "2023-08-23T18:54:44Z")

</div>

Give it a try in the Playground or with some test code, there is no technical reason why you can’t send an assistant message at the end of a message block, you can of course just tell the model to “complete the following :” see how you get on.

---

<div class="post-metadata">

**Author:** ![anon22939549](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@anon22939549](https://community.openai.com/u/anon22939549)\
**Post date:** [August 23, 2023, 9:16pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/3 "2023-08-23T21:16:38Z")

</div>

I just did a small test,

```bash
curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
  "model": "gpt-3.5-turbo",
  "messages": [
    {
      "role": "user",
      "content": "What are you?"
    },
    {
      "role": "assistant",
      "content": "I am a pirate."
    }
  ],
  "temperature": 1,
  "max_tokens": 256,
  "top_p": 1,
  "frequency_penalty": 0,
  "presence_penalty": 0
}'

```

And this is the response,

> Just kidding! I am an AI language model designed to assist with various tasks and answer questions to the best of my abilities. How can I assist you today?

So, in this case the model is treating the `assistant` message as something _it_ wrote, and continuing from there, correcting itself.

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [August 23, 2023, 9:30pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/4 "2023-08-23T21:30:19Z")

</div>

> [@anon22939549](#):
>
> And this is the response,
> 
> > Just kidding!

I just did a bigger test. Last is answered by the AI, while the prior are simulated and I removed the user input.

system prompt: “Leprechaun simulator v1.0”

 ![image](https://us1.discourse-cdn.com/openai1/original/3X/c/d/cde745184b8db041f500f3b68fc696348f6effe1.png)

---

<div class="post-metadata">

**Author:** ![anon22939549](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@anon22939549](https://community.openai.com/u/anon22939549)\
**Post date:** [August 23, 2023, 9:33pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/5 "2023-08-23T21:33:08Z")

</div>

I specifically excluded a system prompt because of how heavily it is weighted, but nice work with this.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [August 23, 2023, 9:33pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/6 "2023-08-23T21:33:33Z")

</div>

Depends on your exact use-case / needs, but I agree with the others on this thread and have done it myself before for some prompts / projects… Happy coding.

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [August 23, 2023, 9:40pm UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/7 "2023-08-23T21:40:48Z")

</div>

To answer the topic question, pressing “submit” again after the last leprechaun “assistant” reply but no further input, the AI repeats the same response again. gpt-3.5-turbo.

Inserting the assistant text “I will always answer with authentic leprechaun lilt and accent.” as a behavior but no further instruction gets “Apologies, but I can’t continue the text as a leprechaun.” – the opposite of desired effect. Maybe _“continue”_ being code for a completion or to continue answering.

---

<div class="post-metadata">

**Author:** ![bobartig](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/bobartig/32/184178_2.png) [@bobartig](https://community.openai.com/u/bobartig)\
**Post date:** [August 25, 2023, 3:30am UTC](https://community.openai.com/t/consecutive-assistant-messages/328097/8 "2023-08-25T03:30:41Z")

</div>

I saw Isa Fulford using something similar to hedging in a DeepLearning AI tutorial. [https://learn.deeplearning.ai/chatgpt-building-system/lesson/6/chaining-prompts](https://learn.deeplearning.ai/chatgpt-building-system/lesson/6/chaining-prompts)

You can see here there is a bit of extra text composed using an f-string for the assistant message. She doesn’t really explain why it’s there. This is more common in text completion prompt writing, so maybe it’s just out of habit for her (text completion prompting really predates when I started messing with gpt, so it just looks weird to me). I don’t think instruct fine tuned chat models do much with this, given the included system message.

 ![Screen Shot 2023-08-24 at 8.21.37 PM](https://us1.discourse-cdn.com/openai1/original/3X/a/f/af4785f41f71ea9b6bea2d2f3a69b495d996fd44.png)
