Skip to content

fix(studio): enable local tool calling for OAI-compat remote models - #7330

Closed
Souravrajvi0 wants to merge 39 commits into
unslothai:mainfrom
Souravrajvi0:fix/7282-remote-models-tool-calling
Closed

Souravrajvi0 wants to merge 39 commits into
unslothai:mainfrom
Souravrajvi0:fix/7282-remote-models-tool-calling

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7282 — Search, Code, and MCP were greyed out for remote Ollama / llama.cpp / vLLM / Custom Connections because Studio forced supportsTools: false for every external model.

Those tools still execute on the Studio host. This PR:

  • Marks OAI-compat Connection types as supporting Unsloth's local tool runtime (providerSupportsLocalToolRuntime)
  • Lights Search / Code / MCP in the composer for those remotes (Docs/RAG stay local-only)
  • Runs a streaming local tool loop against the remote model's OpenAI function-calling responses (stream_external_local_tool_loop)
  • Forwards enable_tools / enabled_tools / mcp_enabled / permission fields from the chat adapter
  • Leaves hosted providers (OpenAI / Anthropic / OpenRouter / …) on the existing pure-proxy + supportsBuiltin* path

Motivation

Remote models already speak /v1/chat/completions with tools. Unsloth's Search / Code / MCP run locally, so any Connection with a correct OpenAI-compatible interface should be able to use them. The UI and backend were incorrectly treating “external” as “no local tools”.

Test plan

  • studio/backend/tests/test_external_local_tool_loop.py (loop + Ollama proxy attaches local tools; OpenAI stays passthrough)
  • test_confirm_tool_calls_allowed_for_oai_compat_local_tool_runtime / existing hosted reject test
  • tests/studio/test_chat_response_details_ui_contract.py
  • Manual: connect Ollama or llama.cpp remote → Search/Code/MCP clickable → tool call streams tool_start/tool_end → final answer
    • Composer gating: ollama / llama_cpp / vllm / custom light Search/Code/MCP via supportsTools; Docs/RAG stay hidden for remotes
    • Live Ollama at 127.0.0.1:11434 reachable (/api/tags, /v1/models); installed models are tiny/non-tool-tuned, so the tool loop was exercised end-to-end through _proxy_to_external_provider with an OAI-compat mock remote (provider_type=ollama) that emitted web_search tool_calls → local execute_tool → tool_start/tool_end SSE → final answer
  • Manual: OpenAI/Anthropic still use builtin pills only (no local python/web_search injection)
    • Proxy path: tools=None and enabled_tools forwarded as hosted builtins only
    • Hosted chat-adapter arm emits web_search / web_fetch / code_execution / image_generation only; python / terminal only under the local-runtime arm

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Remote Models not able to do Tool Calling

3 participants