[PR #21940] [CLOSED] fix: add synthetic tool responses for orphaned tool calls #41982

Closed
opened 2026-04-25 14:02:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21940
Author: @maxkuminov
Created: 2/27/2026
Status: Closed

Base: mainHead: fix/orphaned-tool-calls


📝 Commits (1)

  • 959ff2b fix: add synthetic tool responses for orphaned tool calls

📊 Changes

2 files changed (+123 additions, -0 deletions)

View changed files

backend/open_webui/test/test_convert_output.py (+106 -0)
📝 backend/open_webui/utils/misc.py (+17 -0)

📄 Description

Summary

  • When a native function call (e.g., web search) times out or fails without producing a function_call_output, convert_output_to_messages() emits an assistant message with tool_calls and no following tool role message. All providers (OpenAI, Azure, Google) reject this as invalid, returning "Provider returned error" for every subsequent message in that chat — permanently breaking the conversation.
  • After the final flush_pending() call, this PR checks if the last message is an assistant with tool_calls and appends synthetic tool role messages so the conversation remains valid.

Test plan

  • New test: normal flow (function_call + function_call_output) — no change in behavior
  • New test: orphaned function_call at end — synthetic tool response added
  • New test: multiple orphaned tool calls — all get synthetic responses
  • New test: empty output list — returns empty
  • New test: output with only messages (no tool calls) — no change

All tests in backend/open_webui/test/test_convert_output.py.

Fixes #14577, #12135, #18121, #9435

🤖 Generated with Claude Code


🔄 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/21940 **Author:** [@maxkuminov](https://github.com/maxkuminov) **Created:** 2/27/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/orphaned-tool-calls` --- ### 📝 Commits (1) - [`959ff2b`](https://github.com/open-webui/open-webui/commit/959ff2b479edb92c3ecb5f63dcf9aeb255b5f105) fix: add synthetic tool responses for orphaned tool calls ### 📊 Changes **2 files changed** (+123 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/open_webui/test/test_convert_output.py` (+106 -0) 📝 `backend/open_webui/utils/misc.py` (+17 -0) </details> ### 📄 Description ## Summary - When a native function call (e.g., web search) times out or fails without producing a `function_call_output`, `convert_output_to_messages()` emits an assistant message with `tool_calls` and no following `tool` role message. All providers (OpenAI, Azure, Google) reject this as invalid, returning "Provider returned error" for **every subsequent message** in that chat — permanently breaking the conversation. - After the final `flush_pending()` call, this PR checks if the last message is an assistant with `tool_calls` and appends synthetic `tool` role messages so the conversation remains valid. ## Test plan - [x] New test: normal flow (function_call + function_call_output) — no change in behavior - [x] New test: orphaned function_call at end — synthetic tool response added - [x] New test: multiple orphaned tool calls — all get synthetic responses - [x] New test: empty output list — returns empty - [x] New test: output with only messages (no tool calls) — no change All tests in `backend/open_webui/test/test_convert_output.py`. Fixes #14577, #12135, #18121, #9435 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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-25 14:02:54 -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#41982