open-webui/backend/open_webui
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
internal chore: format 2026-04-24 18:48:21 +09:00
migrations refac 2026-04-24 18:20:10 +09:00
models chore: format 2026-04-24 18:48:21 +09:00
retrieval chore: format 2026-04-24 18:48:21 +09:00
routers chore: format 2026-04-24 18:48:21 +09:00
socket refac 2026-04-17 13:29:51 +09:00
static chore: format 2026-04-19 22:45:54 +09:00
storage refac 2026-04-12 19:08:30 -05:00
test refac 2026-03-17 17:58:01 -05:00
tools refac 2026-04-24 18:06:19 +09:00
utils fix(mcp): execute MCP tool calls server-side in native function calling mode 2026-04-26 18:49:01 +02:00
__init__.py refac (#22987) 2026-03-24 15:41:26 -05:00
alembic.ini fix: Alembic CLI commands from failing 2025-08-15 04:17:47 -04:00
config.py feat: add PaddleOCR-vl loader support and implement retrieval router infrastructure (#23945) 2026-04-24 15:19:37 +09:00
constants.py chore: format 2026-04-14 17:27:31 -05:00
env.py refac 2026-04-24 16:23:28 +09:00
functions.py refac 2026-04-21 14:31:04 +09:00
main.py chore: format 2026-04-24 18:48:21 +09:00
tasks.py refac 2026-03-17 17:58:01 -05:00