[GH-ISSUE #1438] Backend-Controlled API Flow: user message disappears from UI after step 2 trigger assistant completion and refresh. #171

Closed
opened 2026-10-18 14:09:35 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @vrzh on GitHub (Sep 23, 2026).
Original GitHub issue: https://github.com/open-webui/docs/issues/1438

Hi, thank you for the awesome project!

I am following the Backend-Controlled API Flow instructions. I hope this is the correct venue, there was a previous similar issue posted here https://github.com/open-webui/docs/issues/1175.

I understand that "Future versions may introduce changes in behavior or API structure." so I am hoping as part of the answer would be some info on how I can figure out what the correct calls are (if there are changes in the future).

When I complete step 2 (trigger assistant completion) and then refresh the web UI, the user message disappears from the UI. I am on the latest version 0.11.4.

UI view of chat after step 1 (as expected):
Image

UI view of chat after step 2 (as expected both user and assistant messages can be seen):

Image

UI view after refreshing the UI in the browser (problem - only the assistant message can be seen, user message is missing):
Image

For ease of testing I combined step 1 and step 2 into a script:

API_KEY="..."
HOST="..."

# Step 1: Create Chat with User and Assistant Messages
# https://docs.openwebui.com/reference/api-flow/#step-1-create-chat-with-user-and-assistant-messages

USER_MSG_ID=$(uuidgen || python3 -c "import uuid; print(uuid.uuid4())")
ASSISTANT_MSG_ID=$(uuidgen || python3 -c "import uuid; print(uuid.uuid4())")
TIMESTAMP=$(date +%s)

CHAT_ID=$(curl -X POST $HOST/api/v1/chats/new \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat": {
      "title": "New Chat",
      "models": ["gpt-5.6-sol"],
      "messages": [
        {
          "id": "'"$USER_MSG_ID"'",
          "role": "user",
          "content": "Hi, what is the capital of France?",
          "timestamp": '"$TIMESTAMP"',
          "models": ["gpt-5.6-sol"],
          "childrenIds": ["'"$ASSISTANT_MSG_ID"'"]
        },
        {
          "id": "'"$ASSISTANT_MSG_ID"'",
          "role": "assistant",
          "content": "",
          "parentId": "'"$USER_MSG_ID"'",
          "childrenIds": [],
          "model": "gpt-5.6-sol",
          "modelName": "gpt-5.6-sol",
          "modelIdx": 0,
          "done": false,
          "timestamp": '"$((TIMESTAMP + 1))"'
        }
      ],
      "history": {
        "currentId": "'"$ASSISTANT_MSG_ID"'",
        "messages": {
          "'"$USER_MSG_ID"'": {
            "id": "'"$USER_MSG_ID"'",
            "role": "user",
            "content": "Hi, what is the capital of France?",
            "timestamp": '"$TIMESTAMP"',
            "models": ["gpt-5.6-sol"],
            "childrenIds": ["'"$ASSISTANT_MSG_ID"'"]
          },
          "'"$ASSISTANT_MSG_ID"'": {
            "id": "'"$ASSISTANT_MSG_ID"'",
            "role": "assistant",
            "content": "",
            "parentId": "'"$USER_MSG_ID"'",
            "childrenIds": [],
            "model": "gpt-5.6-sol",
            "modelName": "gpt-5.6-sol",
            "modelIdx": 0,
            "done": false,
            "timestamp": '"$((TIMESTAMP + 1))"'
          }
        }
      }
    }
  }' | jq -r '.id')

echo "$CHAT_ID"


sleep 30

# Step 2: Trigger Assistant Completion
# https://docs.openwebui.com/reference/api-flow/#step-2-trigger-assistant-completion


SESSION_ID=$(uuidgen || python3 -c "import uuid; print(uuid.uuid4())")

curl -X POST $HOST/api/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "'"$CHAT_ID"'",
    "id": "'"$ASSISTANT_MSG_ID"'",
    "messages": [
      {
        "role": "user",
        "content": "Hi, what is the capital of France?"
      }
    ],
    "model": "gpt-5.6-sol",
    "stream": true,
    "background_tasks": {
      "title_generation": true,
      "tags_generation": false,
      "follow_up_generation": false
    },
    "features": {
      "code_interpreter": false,
      "web_search": false,
      "image_generation": false,
      "memory": false
    },
    "variables": {
      "{{USER_NAME}}": "",
      "{{USER_LANGUAGE}}": "en-US",
      "{{CURRENT_DATETIME}}": "2025-07-14T12:00:00Z",
      "{{CURRENT_TIMEZONE}}": "Europe"
    },
    "session_id": "'"$SESSION_ID"'"
  }'
Originally created by @vrzh on GitHub (Sep 23, 2026). Original GitHub issue: https://github.com/open-webui/docs/issues/1438 Hi, thank you for the awesome project! I am following the [Backend-Controlled API Flow](https://docs.openwebui.com/reference/api-flow/#step-2-trigger-assistant-completion) instructions. I hope this is the correct venue, there was a previous similar issue posted here https://github.com/open-webui/docs/issues/1175. I understand that "Future versions may introduce changes in behavior or API structure." so I am hoping as part of the answer would be some info on how I can figure out what the correct calls are (if there are changes in the future). When I complete step 2 (trigger assistant completion) and then refresh the web UI, the user message disappears from the UI. I am on the latest version `0.11.4`. UI view of chat after step 1 (as expected): <img width="806" height="240" alt="Image" src="https://github.com/user-attachments/assets/a2af892f-c2ad-493f-8317-a7f4226eb5f7" /> UI view of chat after step 2 (as expected both user and assistant messages can be seen): <img width="937" height="291" alt="Image" src="https://github.com/user-attachments/assets/ad85e4ad-063f-4d54-b3ef-4eb6e0331472" /> UI view after refreshing the UI in the browser (problem - only the assistant message can be seen, user message is missing): <img width="943" height="225" alt="Image" src="https://github.com/user-attachments/assets/c25c1af2-cc87-4f02-a353-fe005059cb57" /> For ease of testing I combined step 1 and step 2 into a script: ```sh API_KEY="..." HOST="..." # Step 1: Create Chat with User and Assistant Messages # https://docs.openwebui.com/reference/api-flow/#step-1-create-chat-with-user-and-assistant-messages USER_MSG_ID=$(uuidgen || python3 -c "import uuid; print(uuid.uuid4())") ASSISTANT_MSG_ID=$(uuidgen || python3 -c "import uuid; print(uuid.uuid4())") TIMESTAMP=$(date +%s) CHAT_ID=$(curl -X POST $HOST/api/v1/chats/new \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "chat": { "title": "New Chat", "models": ["gpt-5.6-sol"], "messages": [ { "id": "'"$USER_MSG_ID"'", "role": "user", "content": "Hi, what is the capital of France?", "timestamp": '"$TIMESTAMP"', "models": ["gpt-5.6-sol"], "childrenIds": ["'"$ASSISTANT_MSG_ID"'"] }, { "id": "'"$ASSISTANT_MSG_ID"'", "role": "assistant", "content": "", "parentId": "'"$USER_MSG_ID"'", "childrenIds": [], "model": "gpt-5.6-sol", "modelName": "gpt-5.6-sol", "modelIdx": 0, "done": false, "timestamp": '"$((TIMESTAMP + 1))"' } ], "history": { "currentId": "'"$ASSISTANT_MSG_ID"'", "messages": { "'"$USER_MSG_ID"'": { "id": "'"$USER_MSG_ID"'", "role": "user", "content": "Hi, what is the capital of France?", "timestamp": '"$TIMESTAMP"', "models": ["gpt-5.6-sol"], "childrenIds": ["'"$ASSISTANT_MSG_ID"'"] }, "'"$ASSISTANT_MSG_ID"'": { "id": "'"$ASSISTANT_MSG_ID"'", "role": "assistant", "content": "", "parentId": "'"$USER_MSG_ID"'", "childrenIds": [], "model": "gpt-5.6-sol", "modelName": "gpt-5.6-sol", "modelIdx": 0, "done": false, "timestamp": '"$((TIMESTAMP + 1))"' } } } } }' | jq -r '.id') echo "$CHAT_ID" sleep 30 # Step 2: Trigger Assistant Completion # https://docs.openwebui.com/reference/api-flow/#step-2-trigger-assistant-completion SESSION_ID=$(uuidgen || python3 -c "import uuid; print(uuid.uuid4())") curl -X POST $HOST/api/chat/completions \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "chat_id": "'"$CHAT_ID"'", "id": "'"$ASSISTANT_MSG_ID"'", "messages": [ { "role": "user", "content": "Hi, what is the capital of France?" } ], "model": "gpt-5.6-sol", "stream": true, "background_tasks": { "title_generation": true, "tags_generation": false, "follow_up_generation": false }, "features": { "code_interpreter": false, "web_search": false, "image_generation": false, "memory": false }, "variables": { "{{USER_NAME}}": "", "{{USER_LANGUAGE}}": "en-US", "{{CURRENT_DATETIME}}": "2025-07-14T12:00:00Z", "{{CURRENT_TIMEZONE}}": "Europe" }, "session_id": "'"$SESSION_ID"'" }' ```
Author
Owner

@Classic298 commented on GitHub (Sep 23, 2026):

Thanks for the clean repro. The docs example was missing a field: the completion request needs user_message, the user message object you created in step 1. Without it the backend saves the assistant reply with no parent, so after a reload the UI can't find your message anymore.

Add this to the step 2 request and it works:

"user_message": {
  "id": "<USER_MSG_ID>",
  "role": "user",
  "content": "Hi, what is the capital of France?",
  "parentId": null,
  "childrenIds": ["<ASSISTANT_MSG_ID>"],
  "models": ["gpt-5.6-sol"]
}

Docs are updated. For future changes: send a message in the web UI with the browser dev tools open and look at the /api/chat/completions request in the Network tab. That body is exactly what the UI sends, so it's always the current reference.

<!-- gh-comment-id:5795574432 --> @Classic298 commented on GitHub (Sep 23, 2026): Thanks for the clean repro. The docs example was missing a field: the completion request needs `user_message`, the user message object you created in step 1. Without it the backend saves the assistant reply with no parent, so after a reload the UI can't find your message anymore. Add this to the step 2 request and it works: ```json "user_message": { "id": "<USER_MSG_ID>", "role": "user", "content": "Hi, what is the capital of France?", "parentId": null, "childrenIds": ["<ASSISTANT_MSG_ID>"], "models": ["gpt-5.6-sol"] } ``` Docs are updated. For future changes: send a message in the web UI with the browser dev tools open and look at the `/api/chat/completions` request in the Network tab. That body is exactly what the UI sends, so it's always the current reference.
Author
Owner

@vrzh commented on GitHub (Sep 23, 2026):

Thank you, works like a charm!

I initially did look at the dev tools, but saw only a request to completions (i.e. no step 1 request):

Image

This got me confused, I thought it did not apply. But now I know!

<!-- gh-comment-id:5795804173 --> @vrzh commented on GitHub (Sep 23, 2026): Thank you, works like a charm! I initially did look at the dev tools, but saw only a request to `completions` (i.e. no step 1 request): <img width="257" height="170" alt="Image" src="https://github.com/user-attachments/assets/cff3764d-a699-43ff-a577-f6de56fd2045" /> This got me confused, I thought it did not apply. But now I know!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/docs#171
No description provided.