When tool call results contain HTML entities like ", &, ',
they are not decoded before being sent to the LLM in subsequent conversation turns.
Root Cause
Tool results are stored with HTML-escaped content in the database
Messages retrieved from DB still contain HTML entities
processDetails() in src/lib/utils/index.ts inserts the escaped content directly without decoding
Example: A tool result containing "{"results": ...} is sent to the LLM as-is instead of being decoded to "{"results": ...}
Changes
Modified src/lib/utils/index.ts
In processDetails() function (line 875-876), applied unescapeHtml() to tool call results before inserting them into messages
The unescapeHtml() function already existed in the file and uses DOMParser to decode HTML entities
Test
The fix ensures HTML entities are properly decoded:
" → "
& → &
' → '
' → '
Tool call results in multi-turn conversations now contain clean JSON instead of HTML-escaped content.
Checklist
Minimal fix focused on the issue
No new dependencies added (using existing unescapeHtml function)
Backward compatible
Fix matches the solution suggested in the issue
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/20745
**Author:** [@YuriNachos](https://github.com/YuriNachos)
**Created:** 1/17/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `fix-tool-call-html-entities-decoding`
---
### 📝 Commits (5)
- [`f84aad5`](https://github.com/open-webui/open-webui/commit/f84aad5f141ab769d4b75628f576c89c9ff88db9) fix: handle None value for model capabilities in builtin_tools check
- [`0d4898f`](https://github.com/open-webui/open-webui/commit/0d4898fa40798e396c4deb2f9cc71b0b7d54baf4) fix: handle None value for model capabilities in file_context check
- [`9772be0`](https://github.com/open-webui/open-webui/commit/9772be02cc1d4b4153a76fd15a12d07d47f8eb66) fix: handle None value for capabilities in get_model_capability helper
- [`3d404ff`](https://github.com/open-webui/open-webui/commit/3d404ff87cac3d257c56ed1ef198ed5b8c142ecf) fix: URL-encode OAuth client secrets to handle special characters
- [`3079444`](https://github.com/open-webui/open-webui/commit/3079444ab2f03123a9a7a4e0dc0e7fe135ea7452) fix: Decode HTML entities in tool call results before sending to LLM
### 📊 Changes
**4 files changed** (+13 additions, -14 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/config.py` (+6 -6)
📝 `backend/open_webui/utils/middleware.py` (+4 -6)
📝 `backend/open_webui/utils/tools.py` (+1 -1)
📝 `src/lib/utils/index.ts` (+2 -1)
</details>
### 📄 Description
## Summary
Fixes #20600
When tool call results contain HTML entities like `"`, `&`, `'`,
they are not decoded before being sent to the LLM in subsequent conversation turns.
## Root Cause
1. Tool results are stored with HTML-escaped content in the database
2. Messages retrieved from DB still contain HTML entities
3. `processDetails()` in src/lib/utils/index.ts inserts the escaped content directly without decoding
Example: A tool result containing `"{"results": ...}` is sent to the LLM as-is instead of being decoded to `"{"results": ...}`
## Changes
- Modified `src/lib/utils/index.ts`
- In `processDetails()` function (line 875-876), applied `unescapeHtml()` to tool call results before inserting them into messages
- The `unescapeHtml()` function already existed in the file and uses DOMParser to decode HTML entities
## Test
The fix ensures HTML entities are properly decoded:
- `"` → `"`
- `&` → `&`
- `'` → `'`
- `'` → `'`
Tool call results in multi-turn conversations now contain clean JSON instead of HTML-escaped content.
## Checklist
- [x] Minimal fix focused on the issue
- [x] No new dependencies added (using existing unescapeHtml function)
- [x] Backward compatible
- [x] Fix matches the solution suggested in the issue
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20745
Author: @YuriNachos
Created: 1/17/2026
Status: ❌ Closed
Base:
main← Head:fix-tool-call-html-entities-decoding📝 Commits (5)
f84aad5fix: handle None value for model capabilities in builtin_tools check0d4898ffix: handle None value for model capabilities in file_context check9772be0fix: handle None value for capabilities in get_model_capability helper3d404fffix: URL-encode OAuth client secrets to handle special characters3079444fix: Decode HTML entities in tool call results before sending to LLM📊 Changes
4 files changed (+13 additions, -14 deletions)
View changed files
📝
backend/open_webui/config.py(+6 -6)📝
backend/open_webui/utils/middleware.py(+4 -6)📝
backend/open_webui/utils/tools.py(+1 -1)📝
src/lib/utils/index.ts(+2 -1)📄 Description
Summary
Fixes #20600
When tool call results contain HTML entities like
",&,',they are not decoded before being sent to the LLM in subsequent conversation turns.
Root Cause
processDetails()in src/lib/utils/index.ts inserts the escaped content directly without decodingExample: A tool result containing
"{"results": ...}is sent to the LLM as-is instead of being decoded to"{"results": ...}Changes
src/lib/utils/index.tsprocessDetails()function (line 875-876), appliedunescapeHtml()to tool call results before inserting them into messagesunescapeHtml()function already existed in the file and uses DOMParser to decode HTML entitiesTest
The fix ensures HTML entities are properly decoded:
"→"&→&'→''→'Tool call results in multi-turn conversations now contain clean JSON instead of HTML-escaped content.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.