[PR #9095] [CLOSED] **fix** Fix title generation JSON enforcement changes #22316

Closed
opened 2026-04-20 04:04:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/9095
Author: @joshuawu
Created: 1/30/2025
Status: Closed

Base: devHead: dev


📝 Commits (1)

  • bcaf405 Fix 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:

  • 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:
Screenshot 2025-01-30 085816
Which produces the fallback title:
Screenshot 2025-01-30 085822
(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.


🔄 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: ![Screenshot 2025-01-30 085816](https://github.com/user-attachments/assets/263a822c-8e5b-402b-8371-2932210d2186) Which produces the fallback title: ![Screenshot 2025-01-30 085822](https://github.com/user-attachments/assets/fc6bcea8-662c-4a7a-9637-4912540739d6) (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>
GiteaMirror added the pull-request label 2026-04-20 04:04:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#22316