Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
Target branch: Please verify that the pull request targets the dev branch.
Description: Provide a concise description of the changes made in this pull request.
Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
Testing: Have you written and run sufficient tests for validating the changes?
Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
Prefix: To clearly categorize this pull request, prefix the pull request title, using one of the following:
Changelog Entry
Description
Fix bug where task would crash if it generated a summary without strict JSON format.
However, this only mitigates the root issue: see Additional Information.
Added
Changed
Refactored regex for stripping thoughts before title generation (to be more readable)
Deprecated
Removed
Fixed
Fix bug where task would crash if it generated a summary without strict JSON format
Security
Fix bug where task would crash if it generated a summary without strict JSON format
Breaking Changes
Additional Information
The cause of the new issue is due to the new change to enforce a strict JSON response when generating titles.
This fix only prevents the generation task from crashing. It simply ignores the bad response and falls back to the chat history.
Screenshots or Videos
Example of query failure
This is an easy way to get title generation to fail:
Which produces the fallback title:
(Note: The issue is with the title generation response, not directly the initial response above.)
Also, I've seen it fail even with more unrelated prompts like topics about medicine, science, or history. With many models, sometimes the model disobeys and uses Markdown instead of JSON. An example was **Title:** 💊 Health and Medicine
🔄 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/9095
**Author:** [@joshuawu](https://github.com/joshuawu)
**Created:** 1/30/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `dev`
---
### 📝 Commits (1)
- [`bcaf405`](https://github.com/open-webui/open-webui/commit/bcaf4053443f32bf3d7b5da79e9706e712453068) Fix title generation JSON enforcement changes
### 📊 Changes
**2 files changed** (+3 additions, -5 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/routers/tasks.py` (+2 -4)
📝 `backend/open_webui/utils/middleware.py` (+1 -1)
</details>
### 📄 Description
# Pull Request Checklist
### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request.
**Before submitting, make sure you've checked the following:**
- [x] **Target branch:** Please verify that the pull request targets the `dev` branch.
- [x] **Description:** Provide a concise description of the changes made in this pull request.
- [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description.
- [ ] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources?
- [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation?
- [ ] **Testing:** Have you written and run sufficient tests for validating the changes?
- [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
- [x] **Prefix:** To clearly categorize this pull request, prefix the pull request title, using one of the following:
# Changelog Entry
### Description
Fix bug where task would crash if it generated a summary without strict JSON format.
However, this only mitigates the root issue: see **Additional Information**.
### Added
### Changed
- Refactored regex for stripping thoughts before title generation (to be more readable)
### Deprecated
### Removed
### Fixed
- Fix bug where task would crash if it generated a summary without strict JSON format
### Security
- Fix bug where task would crash if it generated a summary without strict JSON format
### Breaking Changes
---
### Additional Information
The cause of the new issue is due to the new change to enforce a strict JSON response when generating titles.
This fix only prevents the generation task from crashing. It simply ignores the bad response and falls back to the chat history.
### Screenshots or Videos
## Example of query failure
This is an easy way to get title generation to fail:

Which produces the fallback title:

(Note: The issue is with the title generation response, not directly the initial response above.)
Also, I've seen it fail even with more unrelated prompts like topics about medicine, science, or history. With many models, sometimes the model disobeys and uses Markdown instead of JSON. An example was `**Title:** 💊 Health and Medicine`
For further context, earlier I suggested having an explicit setting for chain of thought models (see the closed PR https://github.com/open-webui/open-webui/pull/9088), but it was not preferred.
---
<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/9095
Author: @joshuawu
Created: 1/30/2025
Status: ❌ Closed
Base:
dev← Head:dev📝 Commits (1)
bcaf405Fix title generation JSON enforcement changes📊 Changes
2 files changed (+3 additions, -5 deletions)
View changed files
📝
backend/open_webui/routers/tasks.py(+2 -4)📝
backend/open_webui/utils/middleware.py(+1 -1)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
Fix bug where task would crash if it generated a summary without strict JSON format.
However, this only mitigates the root issue: see Additional Information.
Added
Changed
Deprecated
Removed
Fixed
Security
Breaking Changes
Additional Information
The cause of the new issue is due to the new change to enforce a strict JSON response when generating titles.
This fix only prevents the generation task from crashing. It simply ignores the bad response and falls back to the chat history.
Screenshots or Videos
Example of query failure
This is an easy way to get title generation to fail:


Which produces the fallback title:
(Note: The issue is with the title generation response, not directly the initial response above.)
Also, I've seen it fail even with more unrelated prompts like topics about medicine, science, or history. With many models, sometimes the model disobeys and uses Markdown instead of JSON. An example was
**Title:** 💊 Health and MedicineFor further context, earlier I suggested having an explicit setting for chain of thought models (see the closed PR https://github.com/open-webui/open-webui/pull/9088), but it was not preferred.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.