Skip to content

Studio: heal DiffusionGemma tool calls into structured tool_calls - #6851

Merged
danielhanchen merged 8 commits into
unslothai:mainfrom
oobabooga:studio-diffusion-api-compat
Jul 8, 2026
Merged

danielhanchen merged 8 commits into
unslothai:mainfrom
oobabooga:studio-diffusion-api-compat

Conversation

@oobabooga

@oobabooga oobabooga commented Jul 3, 2026 •

Copy link
Copy Markdown
Member

DiffusionGemma tool calls come back as raw text instead of a structured tool_calls array. A client that declares a tool gets <|tool_call>call:get_weather{...}<tool_call|> in the message content with finish_reason: stop, so OpenAI-v1 clients like pi can't see the call.

Closes #6732

(Thinking already works; only tool calls were affected.)

Problem

supports_tools is off for diffusion, which keeps the agentic tool loop from running (it would drop the canvas frames that drive the visualization). But that same flag also switched off the client-tool passthrough, the path that turns the model's text tool call into a structured tool_calls.

So the tool call reached the client as raw text. The parser already understands DiffusionGemma's <|tool_call> format (from #6801); it just wasn't being reached.

Fix

Split the flag in two: supports_tools still gates the agentic loop (stays off for diffusion), and a new supports_tool_passthrough gates only the client-tool passthrough (on for diffusion).

Non-diffusion models are unaffected, since both flags return the same value there.

Verification

Live on unsloth/diffusiongemma-26B-A4B-it-GGUF with a declared tool: OpenAI (streaming and non-streaming) and Anthropic /v1/messages now return proper tool_calls / tool_use, and the diffusion visualization still streams. The existing passthrough and route suites pass unchanged.

Note

This is the Studio half. The model only emits schema-correct arguments once the shim (unslothai/unsloth-zoo#864) and the visual server (llama.cpp #24423) forward the tool definitions too, so it's a no-op until a client sends tools.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new property supports_tool_passthrough to the llama_cpp backend, which returns the underlying _supports_tools value. This property is then used in inference.py to determine tool passthrough and client tool support, falling back to supports_tools if the property is not present. This change ensures that client tool loops can bypass restrictions placed on supports_tools for specific models like DiffusionGemma. There are no review comments to address, and the changes look correct.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member

Pushed a small follow-up so the OpenAI /v1/chat/completions passthrough matches /v1/messages.

The passthrough branch was gated on not _effective_enable_tools(payload). If a client sent tools to DiffusionGemma while enable_tools was forced on (CLI --enable-tools, or via mcp_enabled), the passthrough was skipped, and since supports_tools is off for diffusion the server-side tool loop did not run either, so the request fell through to plain generation and returned the raw <|tool_call> text again.

It now gates on whether the server-side loop can actually claim the request (_effective_enable_tools(payload) and supports_tools), so DiffusionGemma routes through the client passthrough in that case too. Non-diffusion behavior is unchanged, and the existing OpenAI, Anthropic, and Responses passthrough suites still pass (353).

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 23f47cb81b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 1d4af28b8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit a113f89 into unslothai:main Jul 8, 2026
45 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] diffusiongemma not OpenAI-v1 compatible

3 participants