Skip to content

Studio: don't drop parallel tool calls after an internal no-op#7157

Open
oobabooga wants to merge 3 commits into
unslothai:mainfrom
oobabooga:fix/tool-loop-noop-parallel
Open

Studio: don't drop parallel tool calls after an internal no-op#7157
oobabooga wants to merge 3 commits into
unslothai:mainfrom
oobabooga:fix/tool-loop-noop-parallel

Conversation

@oobabooga

Copy link
Copy Markdown
Member

In the agentic tool loop, when the model emits several tool calls in one turn and one of them is an internal no-op (a duplicate, a disabled tool, or a repeated render_html), the loop stopped at that no-op and silently dropped every call after it. For a batch [A, A (duplicate), B]:

  • Before: A runs, the loop hits the duplicate and breaks, so B never runs.
  • After: A runs, the duplicate is skipped, and B still runs.

The break was load-bearing: it kept the no-op's role:user nudge from splitting an assistant's tool_calls from their role:tool results.

Fix

Defer the nudges instead. The loop continues so the trailing calls still run, and a shared append_deferred_nudges() helper appends them as one role:user message after all the tool results. Applied to both the GGUF (llama_cpp.py) and safetensors (safetensors_agentic.py) loops.

One behavior change: a call that duplicates an already-satisfied one now counts toward the duplicate limit within a single turn, so the loop finalizes one turn sooner when the model parallel-duplicates.

Verification

Three regression tests (GGUF, safetensors, helper), each confirmed to fail on the old break: the [A, A (duplicate), B] batch now runs both A and B. Tool-loop, controller, safetensors, and secure-tools suites pass (397).

The no-op break was one of the issues raised in #7119. This PR lands that single fix on its own, minimal and tested.

@oobabooga oobabooga requested a review from danielhanchen as a code owner July 15, 2026 21:16

@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 ensures that duplicate or no-op tool calls do not abort a batch of parallel tool calls or split the assistant's tool calls from their corresponding tool results. It introduces an append_deferred_nudges helper to collect, deduplicate, and append no-op nudges as a single user message after the batch's tool results have been recorded. Corresponding unit tests have been added to verify this behavior across both the Llama.cpp and Safetensors agentic inference paths. I have no feedback to provide as there are no review comments.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a466fe59d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread studio/backend/core/inference/tool_loop_controller.py
@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 230e1ce20d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

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.

1 participant