The assistant communicates with itself

Good afternoon!
I am working on implementing an assistant. The logic of the work is as follows: the user provides a problem, and the assistant returns a JSON response with step-by-step instructions. The structure of the response looks something like this:

My idea was that the UI (client part) should display the main_answer and offer the user to choose one of the user_inputs, and only then send a new request.

However, the assistant behaves strangely: it seems to ignore external interaction and uses the options from the user_inputs to generate the next steps. This leads to the assistant actually having a dialogue with itself, imitating the learning process.

For example, it formulates the question “need to find a common denominator”, and then it answers it itself, for example, “I don’t know how to find the NSC”, and then provides an explanation. This happens without any intervention from the user.

This seems like excessive autonomy of the model or some peculiarity of the role or prompt settings (perhaps the instruction “continue the dialogue until you solve the problem” is interpreted too literally?).

Does anyone have experience with this behavior? What settings or instructions should I review to make the assistant wait for a real request from the user?

It would help to know how you are doing it (agent sdk, responses API, etc.), preferable with a bit of some (anonymized) code snippet.

It seems more like an error in the implementation, but with only a description we can’t help you much.

I use openai sdk in code, and test in assistant workflow

steps:
1 - I send a question to assistant
2 - Assisatnt generate many responses

In code - I always get only last message from assistant

I mean, what inputs and roles are you sending, what endpoints are you using.

You are only showing your results, it’s like showing the cake and asking what went wrong without showing how you cooked it.

That is the expected behaviour, the output is only the newly generated assistant role.

Sorry)

First message I sent with role - user
Then in conversation I have many messages with role assistant

I use assistant sdk, endpoints:
** I can not add links, so methods are: add msg openai_client.beta.threads.messages.create with role user
create run openai_client.beta.threads.runs.create(**kwargs)
retrieve until complete openai_client.beta.threads.runs.retrieve

I test the assistant in assistants workflow on openai platform

  1. Add msg from user
  2. Get many responses fro assistants (like on previose screenshot)

EXP:
{
“object”: “list”,
“data”: [
{
“role”: “assistant”,
“content”: [
{
“type”: “text”,
“text”: {
“value”: “{"main_answer":"Чудово! Спробуй додати дроби \\(\\frac{4}{48}\\) і \\(\\frac{3}{48}\\) — обчисли суму чисельників і залиш знаменник без змін. \n\nЩо ти отримаєш? :blush:","user_inputs":["\\frac{7}{48}","\\frac{8}{48}","Потрібна допомога"]}”,
“annotations”:
}
}
],
“attachments”: ,
“metadata”: {}
},
{
“role”: “assistant”,
“content”: [
{
“type”: “text”,
“text”: {
“value”: “{"main_answer":"НСК (найменше спільне кратне) двох чисел — це найменше число, яке ділиться без остачі на обидва ці числа. \n\nДля 12 і 16:\n- Розкладемо на прості множники:\n - 12 = 2^2 × 3\n - 16 = 2^4\n- НСК буде мати найбільшу ступінь кожного простого множника: 2^4 × 3 = 16 × 3 = 48\n\nОтже, НСК дорівнює 48.\n\nТепер перетворимо дроби на спільний знаменник 48:\n- \\(\\frac{1}{12} = \\frac{4}{48}\\) (бо 12 × 4 = 48)\n- \\(\\frac{1}{16} = \\frac{3}{48}\\) (бо 16 × 3 = 48)\n\nЧи хочеш спробувати додати ці дроби самостійно?","user_inputs":["Так, я спробую","Поясни ще раз"]}”,
“annotations”:
}
}
],
“attachments”: ,
“metadata”: {}
},
{
“role”: “assistant”,
“content”: [
{
“type”: “text”,
“text”: {
“value”: “{"main_answer":"Щоб додати дроби \\(\\frac{1}{12}\\) і \\(\\frac{1}{16}\\), спочатку знайдемо спільний знаменник. Він дорівнює найменшому спільному кратному (НСК) чисел 12 та 16. \n\nЧи знаєш ти, як знайти НСК для 12 і 16? Якщо ні, я можу допомогти! :slightly_smiling_face:","user_inputs":["Я знаю, як знайти НСК","Поясни, будь ласка","Що таке НСК?"]}”,
“annotations”:
}
}
],
“attachments”: ,
“metadata”: {}
},
{
“role”: “assistant”,
“content”: [
{
“type”: “text”,
“text”: {
“value”: “{"main_answer":"Дуже цікава задача!\\n\\nОсь про що йдеться у задачі: Марічка і Наталка їдять кавун разом, але різними темпами. Ми хочемо знати, скільки частини кавуна залишиться через 1 хвилину спільного поїдання.\\n\\nДля початку спробуємо зрозуміти, скільки частини кавуна за 1 хвилину з’їдає кожна з дівчаток окремо.\\n\\nЧастина кавуна, яку з’їдає Марічка за 1 хв: \\n$$ \\frac{1}{12} $$\\n\\nЧастина кавуна, яку з’їдає Наталка за 1 хв: \\n$$ \\frac{1}{16} $$\\n\\nНаступний крок — порахувати, яку частину кавуна вони з’їдають разом за 1 хвилину, додавши ці дроби. Хочеш спробувати сам(а) скласти цей дріб?","user_inputs":["Я знаю, як почати","Поясни, як додавати дроби","Не знаю, що робити"]}”,
“annotations”:
}
}
],
“attachments”: ,
“metadata”: {}
},
{
“role”: “user”,
“content”: [
{
“type”: “text”,
“text”: {
“value”: “Марічка може з’їсти кавун за 12 хв, а Наталка — за 16 хв. Яка частина кавуна залишиться через 1 хв, якщо дівчатка почнуть їсти його одночасно?”,
“annotations”:
}
}
],
“attachments”: ,
“metadata”: {}
}
],
}

Newer AI models, seemingly across the board, have a fault with not stopping correctly after they finish one structured output. This is randomly but often activated, and also comes about more on the Responses endpoint in the same input circumstance.

Instead of emitting the “done” special token, they continue predicting something else to write, which can be another assistant message…and another.

The Responses API is capable of sending you multiple output items, event-like, which will separate out both generated reasoning and generated tool calls, and also has the facility for delivering these unwanted multiple assistant role messages.

Alright, let’s take a look at what we can do here.

First thing is: you are using assistants API, which is being deprecated. For a new project, I recommend using either Responses API or Completions API.

That said, let’s clarify what are you trying to do, as it seems we are literally not communicating in the same language (ukrainian?).

What you are showing over and over are the outputs of your assistant.
How can we determine the problem without knowing what you are commanding it to do?

Regardless, if I understood a bit of what you want to do, you want the assistant to propose multiple answers for a single question, and repeat the process over and over, is that so?

What you need to explain to make your post intelligible, is to share what is your initial prompt (and the system prompt for the assistant which originated the thread). We can’t guess only by looking the answers of it.

Here is an example in Responses API, where you can clearly see the developer prompt, that will determine how the model should respond to the user role:

from openai import OpenAI
client = OpenAI()

response = client.responses.create(
    model="gpt-4.1-mini",
    input=[
        {
            "role": "developer",
            "content": "Show me 3 answers for every question the user make."
        },
        {
            "role": "user",
            "content": "Why is the sky blue?"
        }
    ]
)

print(response.output_text)

# follow up question(s)
response2 = client.responses.create(
    model="gpt-4.1-mini",
    previous_response_id=response.id,
    input="And why is the ocean salty?",
)

print(response2.output_text)

I recommend taking a look at the Responses API docs, where you can see some examples and try to build it from there.

From what I understand, your assistant is designed to give a single reply, followed by suggested follow-up questions for the user to choose from.
However, the model ends up answering its own suggestions, which are meant to guide the user—not to be continued by the assistant itself.

If that’s correct, your observation may already point to the solution:

Instead, consider having the assistant answer the initial question and then either generate follow-up questions with the clear intent to guide the user, or split the two steps—answering and suggesting follow-ups—into separate model calls before returning to the user with a composite message.
This way, you can present clear options for the user to choose from and let the conversation continue accordingly.