[PR #21555] [CLOSED] fix: /api/v1/completion: overriding user requested tools and populates built-in one #26137

Closed
opened 2026-04-20 06:21:16 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21555
Author: @exxocism
Created: 2/18/2026
Status: Closed

Base: devHead: fix/honor_tool_call_by_client


📝 Commits (1)

  • 557b098 fix: stop overriding built in tool calls for openai apis

📊 Changes

1 file changed (+8 additions, -3 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+8 -3)

📄 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:

  • Target branch: Verify that the pull request targets the dev branch. PRs targeting main will be immediately closed.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Add docs in Open WebUI Docs Repository. Document user-facing behavior, environment variables, public APIs/interfaces, or deployment steps.
  • Dependencies: No new or upgraded dependencies in this PR.
  • Testing: Manual end-to-end verification steps are documented below; full manual run with screenshots is still pending.
  • Agentic AI Code: This change was AI-assisted and requires additional human review and manual testing before merge.
  • Code review: Self-review completed on changed file and diff.
  • Design & Architecture: Change keeps existing defaults and only adjusts tool resolution precedence when caller explicitly provides tools.
  • Git Hygiene: Please confirm branch is rebased on dev and commits are clean/atomic before merge.
  • Title Prefix: Use fix:. Proposed title: fix: respect caller-provided tools in /api/v1/chat/completions.

Changelog Entry

Description

  • Fixes OpenAI-compatible chat completion behavior so explicit caller-provided tools are preserved and not overridden by server-side tool injection.
  • It now works properly when connected with other agents (cluade code, cursor, etc...)

Fixed

  • 557b098b2f - Fixed mismatch where /api/v1/chat/completions could advertise/forward tools not available to the caller and ignore the actual request tools payload in native function-calling flows.

Security

  • No security changes.

Breaking Changes

  • BREAKING CHANGE: None expected. Behavioral change is scoped to requests that explicitly pass tools (caller intent is now preserved).

Additional Information

  • Caveat: this code is vibe coded (AI-assisted) and should receive human review.
  • Syntax validation was run on the modified file: python3 -m py_compile backend/open_webui/utils/middleware.py.
  • Related issue: user-reported bug for tool advertisement/payload mismatch on POST /v1/chat/completions compatibility path.

Screenshots or Videos

  • As-is (overrides request and advertises built-in tools)
    001 asis
  • To-be (properly fills user-requested tools - cursor)
    002 tobe

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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/21555 **Author:** [@exxocism](https://github.com/exxocism) **Created:** 2/18/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/honor_tool_call_by_client` --- ### 📝 Commits (1) - [`557b098`](https://github.com/open-webui/open-webui/commit/557b098b2f6d2e7aba6ad321150f89d22dd68d2c) fix: stop overriding built in tool calls for openai apis ### 📊 Changes **1 file changed** (+8 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+8 -3) </details> ### 📄 Description <!-- ⚠️ CRITICAL CHECKS FOR CONTRIBUTORS (READ, DON'T DELETE) ⚠️ 1. Target the `dev` branch. PRs targeting `main` will be automatically closed. 2. Do NOT delete the CLA section at the bottom. It is required for the bot to accept your PR. --> # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/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:** - [x] **Target branch:** Verify that the pull request targets the `dev` branch. **PRs targeting `main` will be immediately closed.** - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [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. - [x] **Documentation:** Add docs in [Open WebUI Docs Repository](https://github.com/open-webui/docs). Document user-facing behavior, environment variables, public APIs/interfaces, or deployment steps. - [x] **Dependencies:** No new or upgraded dependencies in this PR. - [x] **Testing:** Manual end-to-end verification steps are documented below; full manual run with screenshots is still pending. - [x] **Agentic AI Code:** This change was AI-assisted and requires additional human review and manual testing before merge. - [x] **Code review:** Self-review completed on changed file and diff. - [x] **Design & Architecture:** Change keeps existing defaults and only adjusts tool resolution precedence when caller explicitly provides `tools`. - [x] **Git Hygiene:** Please confirm branch is rebased on `dev` and commits are clean/atomic before merge. - [x] **Title Prefix:** Use `fix:`. Proposed title: `fix: respect caller-provided tools in /api/v1/chat/completions`. # Changelog Entry ### Description - Fixes OpenAI-compatible chat completion behavior so explicit caller-provided `tools` are preserved and not overridden by server-side tool injection. - It now works properly when connected with other agents (cluade code, cursor, etc...) ### Fixed - 557b098b2f6d2e7aba6ad321150f89d22dd68d2c - Fixed mismatch where `/api/v1/chat/completions` could advertise/forward tools not available to the caller and ignore the actual request `tools` payload in native function-calling flows. ### Security - No security changes. ### Breaking Changes - **BREAKING CHANGE**: None expected. Behavioral change is scoped to requests that explicitly pass `tools` (caller intent is now preserved). --- ### Additional Information - Caveat: this code is vibe coded (AI-assisted) and should receive human review. - Syntax validation was run on the modified file: `python3 -m py_compile backend/open_webui/utils/middleware.py`. - Related issue: user-reported bug for tool advertisement/payload mismatch on POST `/v1/chat/completions` compatibility path. ### Screenshots or Videos - As-is (overrides request and advertises built-in tools) <img width="522" height="467" alt="001 asis" src="https://github.com/user-attachments/assets/64571004-c12e-405b-96cb-2acd27277716" /> - To-be (properly fills user-requested tools - cursor) <img width="522" height="467" alt="002 tobe" src="https://github.com/user-attachments/assets/c1c3a5c7-aafd-4d2b-81a2-4a70e860a318" /> ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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 06:21:16 -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#26137