open-webui/backend
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
..
data refac: mv backend files to /open_webui dir 2024-09-04 16:54:48 +02:00
open_webui fix(mcp): execute MCP tool calls server-side in native function calling mode 2026-04-26 18:49:01 +02:00
.dockerignore fix: litellm config issue 2024-02-24 22:35:11 -08:00
.gitignore refac 2024-09-06 04:59:20 +02:00
dev.sh refac 2026-03-24 19:43:30 -05:00
requirements-min.txt refac 2026-04-24 18:20:10 +09:00
requirements.txt refactor(firecrawl): use v2 API directly (#23934) 2026-04-24 18:32:08 +09:00
start.sh refac 2026-03-24 19:43:30 -05:00
start_windows.bat refac 2026-04-24 15:40:02 +09:00