open-webui/backend/open_webui/utils
Prometheus d6eb4544fb fix(mcp): execute MCP tool calls server-side in native function calling mode
When Ollama/Gemma returns finish_reason=tool_calls in a non-streaming
response, OWU was passing the response through unchanged — the tool was
never called and oracle-mcp only ever saw ListToolsRequest.

Root cause: the tool-execution loop lives entirely in
streaming_chat_response_handler, which is skipped for non-streaming
JSON responses.  non_streaming_chat_response_handler only checked for
choices[0].message.content and silently dropped tool_calls.

Fix:
- Add _execute_tool_calls_non_streaming() helper that extracts tool
  calls from a non-streaming LLM response, resolves each tool from
  metadata['tools'], executes it (MCP call_tool or builtin callable),
  and feeds the results back for a second LLM turn.
- Call it from non_streaming_chat_response_handler whenever
  function_calling==native and tool_calls are present in the response.
- Also normalize Ollama-prefixed tool names (e.g. "oracle:oracle_vault_ask"
  → "oracle_vault_ask") at execution time in both the streaming and
  non-streaming paths so the tools_dict lookup succeeds.

Tested: oracle-mcp now shows CallToolRequest after Gemma emits a
tool_call, and Gemma's final answer is grounded in vault data.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-26 18:49:01 +02:00
..
access_control chore: format 2026-04-17 14:28:18 +09:00
images refac 2026-04-15 10:17:40 -07:00
mcp refac 2026-04-24 17:04:47 +09:00
telemetry refac 2026-04-24 15:00:47 +09:00
actions.py refac: async db 2026-04-12 14:22:11 -05:00
anthropic.py chore: format 2026-04-14 17:27:31 -05:00
asgi_middleware.py refac 2026-04-24 16:23:28 +09:00
audit.py refac 2026-04-12 16:25:01 -05:00
auth.py chore: format 2026-04-12 18:12:59 -05:00
automations.py refac 2026-04-21 13:51:39 +09:00
calendar.py feat: calendar 2026-04-19 19:15:05 +09:00
channels.py refac 2026-03-17 17:58:01 -05:00
chat.py refac 2026-04-20 08:53:06 +09:00
code_interpreter.py refac 2026-03-17 17:58:01 -05:00
embeddings.py refac: async db 2026-04-12 14:22:11 -05:00
files.py chore: format 2026-04-21 15:52:00 +09:00
filter.py refac 2026-04-24 18:20:10 +09:00
groups.py refac: async db 2026-04-12 14:22:11 -05:00
headers.py refac 2026-03-17 17:58:01 -05:00
logger.py refac 2026-04-10 10:15:55 -07:00
middleware.py fix(mcp): execute MCP tool calls server-side in native function calling mode 2026-04-26 18:49:01 +02:00
misc.py refac 2026-04-24 18:38:57 +09:00
models.py refac 2026-04-24 18:20:10 +09:00
oauth.py refac 2026-04-24 16:26:34 +09:00
payload.py refac 2026-04-14 16:47:43 -05:00
pdf_generator.py refac 2026-03-17 17:58:01 -05:00
plugin.py chore: format 2026-04-24 18:48:21 +09:00
rate_limit.py refac 2026-03-17 17:58:01 -05:00
redis.py refac 2026-04-24 15:21:52 +09:00
response.py refac 2026-04-24 16:31:02 +09:00
sanitize.py refac 2026-03-17 17:58:01 -05:00
security_headers.py refac 2026-04-20 09:10:48 +09:00
session_pool.py refac 2026-04-14 01:17:39 -05:00
task.py fix: Fix the error that occurs when the task model does not exist (#23169) 2026-04-01 07:01:25 -05:00
tools.py chore: format 2026-04-21 15:52:00 +09:00
validate.py chore: format 2026-04-12 18:12:59 -05:00
webhook.py refac 2026-04-20 08:34:15 +09:00