mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 17:02:01 -05:00
[PR #21565] [CLOSED] fix: respect content edits and deleted blocks in output #113452
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21565
Author: @Algorithm5838
Created: 2/18/2026
Status: ❌ Closed
Base:
dev← Head:fix/drop-output-for-removed-tool-calls📝 Commits (1)
e4447f5fix: respect content edits and deleted blocks in output📊 Changes
2 files changed (+108 additions, -5 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+42 -5)📝
backend/open_webui/utils/misc.py(+66 -0)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.
This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:
devbranch. PRs targetingmainwill be immediately closed.devto ensure no unrelated commits (e.g. frommain) are included. Push updates to the existing PR branch instead of closing and reopening.Changelog Entry
Description
Deleting a
<details>block from a message doesn't actually remove it from model context. Theoutputfield keeps the items regardless of what happens to content. This applies to tool calls, reasoning, and code interpreter blocks.Shows up with things like a fetch tool that pulls large pages (50k+ tokens) where you'd delete the block to free up context, but the tokens stay. Or a custom thinking tool where a filter removes the tool block after the model finishes responding. This used to work before the output refactor.
Editing assistant message text also has no effect. The model still sees the old text because
process_messages_with_outputwas pulling everything from output items, ignoring content entirely.The fix:
process_messages_with_outputnow uses content (stripped of<details>blocks) for text and only uses output for structured items. If an output item's ID is gone from content, it gets skipped.serialize_outputnow emitsid=on reasoning and code_interpreter<details>tags (tool_calls already had it). Output stays in DB untouched, it just doesn't get sent to the model.Added
filter_output_by_content()inmisc.pyChanged
serialize_outputemitsid=onreasoningandcode_interpreter<details>tagsprocess_messages_with_outputfilters output items by matching against content, and usescontent(minus<details>blocks) as assistant textDeprecated
Removed
Fixed
<details>block (tool call, reasoning, code interpreter) now removes it from model contextSecurity
Breaking Changes
Additional Information
Screenshots or Videos
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.