[GH-ISSUE #24585] issue: __event_emitter__ type replace modified message lost after refresh in Action Function #107345

Open
opened 2026-05-18 06:08:30 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @knives on GitHub (May 11, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/24585

Check Existing Issues

  • I have searched for any existing and/or related issues.
  • I have searched for any existing and/or related discussions.
  • I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!).
  • I am using the latest version of Open WebUI.

Installation Method

Docker

Open WebUI Version

0.9.3, 0.9.4, 0.9.5

Ollama Version (if applicable)

No response

Operating System

Windows 11

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

Expect the event_emitter message to persist after refresh in action function.

function-emit_action-export-1778525917500.json

FUNCTION CODE :
`
from pydantic import BaseModel, Field
from typing import Optional

class Action:
async def action(
self, body: dict, user=None, event_emitter=None, request=None
):
# 1. Mise à jour UI (frontend state)
await event_emitter(
{"type": "replace", "data": {"content": "event emitter replace type"}}
)

    return None

`

Actual Behavior

The replaced message with event_emitter is back to the original LLM output
1 -> Action function replace the message
2 -> Refresh
3 -> The message displayed is the original LLM output or the custom modified messaged (edit button)

Steps to Reproduce

1 -> Begin a new chat
2 -> Enter a command
3 -> Wait for the output
4 -> Click on the Action button
5 -> Refresh or change chat (leave the chat)
3 -> Go back to the chat/message where you clicked on the Action button

Logs & Screenshots

https://github.com/user-attachments/assets/d51bf4a1-277e-4be5-b9c9-914333e20567

Docker logs :
2026-05-11 19:08:18.049 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 127.0.0.1:35662 - "POST /api/v1/chats/8007d0e5-77f9-4c53-a343-6df08f3b73b4/messages HTTP/1.1" 405

2026-05-11 19:08:18.049 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 192.168.65.1:27235 - "POST /api/chat/actions/emit_action HTTP/1.1" 200

2026-05-11 19:08:18.078 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 192.168.65.1:27235 - "POST /api/v1/chats/8007d0e5-77f9-4c53-a343-6df08f3b73b4 HTTP/1.1" 200

2026-05-11 19:08:18.093 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 192.168.65.1:27235 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200

Additional Information

Works fine in 0.9.2
Not working on 0.9.3, 0.9.4 and 0.9.5

Originally created by @knives on GitHub (May 11, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/24585 ### Check Existing Issues - [x] I have searched for any existing and/or related issues. - [x] I have searched for any existing and/or related discussions. - [x] I have also searched in the CLOSED issues AND CLOSED discussions and found no related items (your issue might already be addressed on the development branch!). - [x] I am using the latest version of Open WebUI. ### Installation Method Docker ### Open WebUI Version 0.9.3, 0.9.4, 0.9.5 ### Ollama Version (if applicable) _No response_ ### Operating System Windows 11 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior Expect the __event_emitter__ message to persist after refresh in action function. [function-emit_action-export-1778525917500.json](https://github.com/user-attachments/files/27608335/function-emit_action-export-1778525917500.json) FUNCTION CODE : ` from pydantic import BaseModel, Field from typing import Optional class Action: async def action( self, body: dict, __user__=None, __event_emitter__=None, __request__=None ): # 1. Mise à jour UI (frontend state) await __event_emitter__( {"type": "replace", "data": {"content": "event emitter replace type"}} ) return None ` ### Actual Behavior The replaced message with __event_emitter__ is back to the original LLM output 1 -> Action function replace the message 2 -> Refresh 3 -> The message displayed is the original LLM output or the custom modified messaged (edit button) ### Steps to Reproduce 1 -> Begin a new chat 2 -> Enter a command 3 -> Wait for the output 4 -> Click on the Action button 5 -> Refresh or change chat (leave the chat) 3 -> Go back to the chat/message where you clicked on the Action button ### Logs & Screenshots https://github.com/user-attachments/assets/d51bf4a1-277e-4be5-b9c9-914333e20567 Docker logs : 2026-05-11 19:08:18.049 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 127.0.0.1:35662 - "POST /api/v1/chats/8007d0e5-77f9-4c53-a343-6df08f3b73b4/messages HTTP/1.1" 405 2026-05-11 19:08:18.049 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 192.168.65.1:27235 - "POST /api/chat/actions/emit_action HTTP/1.1" 200 2026-05-11 19:08:18.078 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 192.168.65.1:27235 - "POST /api/v1/chats/8007d0e5-77f9-4c53-a343-6df08f3b73b4 HTTP/1.1" 200 2026-05-11 19:08:18.093 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 192.168.65.1:27235 - "GET /api/v1/chats/?page=1 HTTP/1.1" 200 ### Additional Information Works fine in 0.9.2 Not working on 0.9.3, 0.9.4 and 0.9.5
GiteaMirror added the bug label 2026-05-18 06:08:30 -05:00
Author
Owner

@owui-terminator[bot] commented on GitHub (May 11, 2026):

🔍 Related Issues Found

I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions:

  1. 🟣 #23171 issue: message.done state is unreliable — switching chats or refreshing the page causes premature display of thinking process and action buttons
    This issue is closely related because it describes chat state becoming unreliable after refresh/navigation, causing UI state to be reconstructed incorrectly. Your report is also about a message state change not persisting after refresh, but for action-function replacements rather than done-state/action-button visibility.
    by ShirasawaSama · bug

  2. 🟣 #21564 issue: "Edit" and "Continue Response" don't work properly
    This is related because it involves the Edit/Continue Response message mutation path not behaving correctly, which is the same general area of message modification persistence. While the exact symptom differs, both issues concern edited assistant messages not being reflected correctly in the chat UI.
    by TheObserver-000 · bug

  3. 🟣 #20824 issue: Response from model does not appear until page refresh
    This issue is about generated assistant content only appearing after a page refresh, showing a refresh-related rendering/state-sync problem in the message timeline. It is less specific than your report, but still relevant because both bugs involve message content not surviving or appearing correctly across refreshes.
    by NTShop · bug


💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead.

This comment was generated automatically. React with 👍 if helpful, 👎 if not.

<!-- gh-comment-id:4423988341 --> @owui-terminator[bot] commented on GitHub (May 11, 2026): <!-- terminator-bot:related-issues-reply --> 🔍 **Related Issues Found** I found some existing issues that might be related. Please check if any of these are duplicates or contain helpful solutions: 1. 🟣 [#23171](https://github.com/open-webui/open-webui/issues/23171) **issue: message.done state is unreliable — switching chats or refreshing the page causes premature display of thinking process and action buttons** *This issue is closely related because it describes chat state becoming unreliable after refresh/navigation, causing UI state to be reconstructed incorrectly. Your report is also about a message state change not persisting after refresh, but for action-function replacements rather than done-state/action-button visibility.* *by ShirasawaSama · `bug`* 2. 🟣 [#21564](https://github.com/open-webui/open-webui/issues/21564) **issue: "Edit" and "Continue Response" don't work properly** *This is related because it involves the Edit/Continue Response message mutation path not behaving correctly, which is the same general area of message modification persistence. While the exact symptom differs, both issues concern edited assistant messages not being reflected correctly in the chat UI.* *by TheObserver-000 · `bug`* 3. 🟣 [#20824](https://github.com/open-webui/open-webui/issues/20824) **issue: Response from model does not appear until page refresh** *This issue is about generated assistant content only appearing after a page refresh, showing a refresh-related rendering/state-sync problem in the message timeline. It is less specific than your report, but still relevant because both bugs involve message content not surviving or appearing correctly across refreshes.* *by NTShop · `bug`* --- 💡 If your issue is a duplicate, please close it and add any additional details to the existing issue instead. *This comment was generated automatically.* React with 👍 if helpful, 👎 if not.
Author
Owner

@Classic298 commented on GitHub (May 11, 2026):

the replace is only for rich UI elements i believe. if you want to edit the message and persist it you have to do it another way. the replace is only for embeds i believe

<!-- gh-comment-id:4424163012 --> @Classic298 commented on GitHub (May 11, 2026): the replace is only for rich UI elements i believe. if you want to edit the message and persist it you have to do it another way. the replace is only for embeds i believe
Author
Owner

@knives commented on GitHub (May 12, 2026):

Hello,

I have checked the docs before submitting the tickets :

https://docs.openwebui.com/features/extensibility/plugin/development/events/#which-event-types-are-persisted-to-the-database

Image

I also tried the return str and dict method for Actions :

https://docs.openwebui.com/features/extensibility/plugin/development/events/#actions

Image

I have the same results (and in the case of str return, the content is not modified)

STR return function

"""
title: Example Filter
author: open-webui
author_url: https://github.com/open-webui
funding_url: https://github.com/open-webui
version: 0.1
"""

from pydantic import BaseModel, Field
from typing import Optional

from open_webui.models.chats import Chats


class Action:
    async def action(
        self, body: dict, __user__=None, __event_emitter__=None, __request__=None
    ) -> str:

        new_content = "Your new content"

        return new_content

dict return function


Result : 

- Content **not modified** on frontend and no persistence in the database.
- Refresh : Modification lost


"""
title: Example Filter
author: open-webui
author_url: https://github.com/open-webui
funding_url: https://github.com/open-webui
version: 0.1
"""

from pydantic import BaseModel, Field
from typing import Optional

from open_webui.models.chats import Chats
import aiohttp


class Action:
    async def action(
        self, body: dict, __user__=None, __event_emitter__=None, __request__=None
    ) -> dict:
        new_content = "your new content"

        body["messages"][-1]["content"] = new_content

        return body

Result :

  • Content modified on frontend and no persistence in the database.
  • Refresh : Modification lost

I also have checked the update_db parameter of the even_emitter in the action function : the update_db parameter is set to true for the parameter sent to the Action.

        for cell in __event_emitter__.__closure__:
            print(cell.cell_contents)

Docker logs :
{'chat_id': 'xxx', 'message_id': 'xxx', 'session_id': 'xxx', 'user_id': 'xxx'}
True

Did i misunderstood the documentation ?

It worked fine in 0.9.2 and in earlier version too.

<!-- gh-comment-id:4430089402 --> @knives commented on GitHub (May 12, 2026): Hello, I have checked the docs before submitting the tickets : https://docs.openwebui.com/features/extensibility/plugin/development/events/#which-event-types-are-persisted-to-the-database <img width="1090" height="943" alt="Image" src="https://github.com/user-attachments/assets/9eff2cb7-07e6-4c3e-9613-1c6b6cd6e190" /> I also tried the return str and dict method for Actions : https://docs.openwebui.com/features/extensibility/plugin/development/events/#actions <img width="1123" height="487" alt="Image" src="https://github.com/user-attachments/assets/6c230d25-1d0e-49a6-a442-a97dab900fb6" /> I have the same results (and in the case of str return, the content is not modified) STR return function ``` """ title: Example Filter author: open-webui author_url: https://github.com/open-webui funding_url: https://github.com/open-webui version: 0.1 """ from pydantic import BaseModel, Field from typing import Optional from open_webui.models.chats import Chats class Action: async def action( self, body: dict, __user__=None, __event_emitter__=None, __request__=None ) -> str: new_content = "Your new content" return new_content ``` dict return function ``` Result : - Content **not modified** on frontend and no persistence in the database. - Refresh : Modification lost """ title: Example Filter author: open-webui author_url: https://github.com/open-webui funding_url: https://github.com/open-webui version: 0.1 """ from pydantic import BaseModel, Field from typing import Optional from open_webui.models.chats import Chats import aiohttp class Action: async def action( self, body: dict, __user__=None, __event_emitter__=None, __request__=None ) -> dict: new_content = "your new content" body["messages"][-1]["content"] = new_content return body ``` Result : - Content **modified** on frontend and no persistence in the database. - Refresh : Modification lost I also have checked the update_db parameter of the __even_emitter__ in the action function : the update_db parameter is set to true for the parameter sent to the Action. ``` for cell in __event_emitter__.__closure__: print(cell.cell_contents) ``` Docker logs : {'chat_id': 'xxx', 'message_id': 'xxx', 'session_id': 'xxx', 'user_id': 'xxx'} True Did i misunderstood the documentation ? It worked fine in 0.9.2 and in earlier version too.
Author
Owner

@Classic298 commented on GitHub (May 12, 2026):

hm i forgot this replace method for messages existed. but for me it never worked to be persistent. it worked for you before 0.9.2? are you sure?

<!-- gh-comment-id:4430158030 --> @Classic298 commented on GitHub (May 12, 2026): hm i forgot this replace method for messages existed. but for me it never worked to be persistent. it worked for you before 0.9.2? are you sure?
Author
Owner

@knives commented on GitHub (May 12, 2026):

Hello,

Yes I'm sure it worked on 0.9.2 (at least for the original case with the event_emitter) and before.

I just made a new test on the 0.9.2 version with the 3 type of solutions :

  1. event_emitter --> No problem it works fine
  2. return dict --> No problem it works fine
  3. return str --> No modification of content and no miracle with refresh

here a video of the test

https://github.com/user-attachments/assets/8a6a5236-69e8-45e2-b1dc-cfdc243d86e2

<!-- gh-comment-id:4430833585 --> @knives commented on GitHub (May 12, 2026): Hello, Yes I'm sure it worked on 0.9.2 (at least for the original case with the __event_emitter__) and before. I just made a new test on the 0.9.2 version with the 3 type of solutions : 1. event_emitter --> No problem it works fine 2. return dict --> No problem it works fine 3. return str --> No modification of content and no miracle with refresh here a video of the test https://github.com/user-attachments/assets/8a6a5236-69e8-45e2-b1dc-cfdc243d86e2
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#107345