Repository navigation
Studio chat: tool-call nudging on by default (API stays opt-in) - #6883
Conversation
Healing is already default-on everywhere and the nudge retry from the client-tool passthrough is opt-in on the API. Studio chat had neither signal: the frontend never sent nudge_tool_calls, and the safetensors and MLX server-side loop lacked the GGUF loop's plan-without-action re-prompt entirely. Backend: the re-prompt helpers move from llama_cpp.py into tool_call_parser.py (shared, cycle-free; the GGUF loop imports them under its old names with zero behavior change) and run_safetensors_tool_loop now re-prompts once at the streaming no-tool-call exit, gated on Auto-Heal, active tools, nothing executed yet, and short forward-looking text. Re-prompts do not consume tool iterations. Frontend: the chat adapter sends nudge_tool_calls from a new nudgeToolCalls runtime setting (default true) with the same persistence, hydration, and settings toggle plumbing as Auto-Heal. Request-model defaults are untouched, so raw API callers stay opt-in.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8e5ecdbde
ℹ️ 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".
| setScalarSettingVersion( | ||
| "nudgeToolCalls", | ||
| nudgeToolCalls, | ||
| state.nudgeToolCalls, | ||
| ); |
There was a problem hiding this comment.
Accept nudgeToolCalls in saved chat settings
Toggling this new setting queues a persisted settings patch containing nudgeToolCalls, but the backend /api/chat/settings validator still uses ChatSettingsPayload with extra="forbid" and has no nudgeToolCalls field (checked studio/backend/routes/chat_history.py:165-181). As a result, this PUT returns 400; because the failed patch is re-queued, subsequent chat setting saves can keep failing after the user changes the Nudge Tool Calls switch until reload.
Useful? React with 👍 / 👎.
| : {}), | ||
| auto_heal_tool_calls: | ||
| useChatRuntimeStore.getState().autoHealToolCalls, | ||
| nudge_tool_calls: useChatRuntimeStore.getState().nudgeToolCalls, |
There was a problem hiding this comment.
Route the nudge flag to a path that consumes it
This adds nudge_tool_calls only to Studio's enable_tools streaming payload, but the backend client-tool retry that reads it is selected only for GGUF passthrough requests with not _effective_enable_tools(payload) and standard tools, while the local GGUF/safetensors tool-loop calls do not pass this field through. In Studio chat, switching Nudge Tool Calls on or off therefore does not control the intended retry/nudge behavior for local tool use.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
All three confirmed and fixed: nudgeToolCalls is typed on ChatSettingsPayload so settings persist again, nudge_tool_calls now plumbs into both server-side tool loops (None keeps the default-on behavior, explicit false disables) so the Studio flag controls the path it actually runs, and the safetensors loop treats RAG autoinject as an executed tool so it no longer re-prompts after retrieval.
| auto_heal_tool_calls | ||
| and active_tools | ||
| and reprompt_count < MAX_ACT_REPROMPTS | ||
| and not any(record.executed for record in tool_controller.history) |
There was a problem hiding this comment.
Treat RAG auto-inject as an executed tool
When rag_scope.autoinject is enabled, build_rag_autoinject has already emitted a search_knowledge_base tool_start/tool_end and appended a tool result before this controller is used, but tool_controller.history is still empty. This makes a short post-retrieval intent like “I'll search the docs” satisfy the new no-execution guard and get re-prompted, often causing a redundant KB search even though retrieval already ran for the turn.
Useful? React with 👍 / 👎.
…ops, skip the re-prompt after RAG autoinject ChatSettingsPayload uses extra forbid, so a settings patch containing nudgeToolCalls failed to persist any settings; the field is now typed and round-trips. nudge_tool_calls now plumbs into both server-side tool loops and gates the plan-without-action re-prompt with None meaning on, so API callers keep today's behavior, explicit false disables it, and Studio's default-on flag actually controls the path Studio chat runs. The safetensors loop no longer re-prompts after RAG autoinject: the injected retrieval bypasses the tool controller, so the nothing-executed gate saw an empty history and re-asked after a successful retrieval.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45f9968627
ℹ️ 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".
| stripped_answer = content_accum.strip() | ||
| if ( | ||
| auto_heal_tool_calls | ||
| and (nudge_tool_calls is None or nudge_tool_calls) |
There was a problem hiding this comment.
Keep omitted nudge flag from enabling safetensors retries
When a non-Studio /v1/chat/completions caller uses the safetensors server-side tool loop and omits nudge_tool_calls, the route passes payload.nudge_tool_calls through as None, and this condition treats None the same as true. That makes the new plan-without-action retry run by default for API requests, so a short reply like “I'll search…” can trigger an extra generation and tool execution even though the caller did not opt in; Studio can still get default-on behavior by sending true, but omitted API flags should stay disabled.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed: the safetensors loop now requires an explicit nudge flag since its retry is new, so omitted stays off for API callers while Studio sends true. The GGUF loop keeps None as on because its re-prompt predates the flag.
…nudge flag The retry is new on this loop, so an omitted nudge_tool_calls must not change existing API behavior; Studio opts in explicitly. The GGUF loop keeps None as on because its re-prompt predates the flag.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4ad413ef9
ℹ️ 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".
| and active_tools | ||
| and reprompt_count < MAX_ACT_REPROMPTS | ||
| and not rag_autoinjected | ||
| and not any(record.executed for record in tool_controller.history) |
There was a problem hiding this comment.
Respect denied tool confirmations before re-prompting
When Confirm Tool Calls is enabled and the user denies a proposed tool, the loop appends TOOL_REJECTED_MESSAGE but never records that denial in tool_controller.history. Because this new nudge gate only excludes executed records, the next short intent response such as “I'll search again” satisfies the condition and the loop injects a user message telling the model to call the tool, causing another confirmation prompt for an action the user just rejected. Denied/attempted calls should block this re-prompt or the gate should be disabled after a confirmation denial.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed: a denied confirmation now suppresses the plan-without-action re-prompt for the rest of the request, mirroring the autoinject handling. Regression test plus the no-denial control added.
…mation A denial appends TOOL_REJECTED_MESSAGE but records nothing in the tool controller history, so the nothing-executed gate re-prompted the model to call the tool the user had just rejected, producing another confirmation prompt. A denial now suppresses the re-prompt for the rest of the request, mirroring the RAG autoinject handling.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29f3c32f7c
ℹ️ 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".
| ) | ||
| # Empty status clears the badge AND resets the route's | ||
| # per-turn text cursor before the re-prompted turn streams. | ||
| yield {"type": "status", "text": ""} |
There was a problem hiding this comment.
Suppress streamed intent before re-prompting
When this branch fires in a streaming safetensors response, the short intent in content_accum has already been emitted as normal content earlier in the streaming state, and the route only resets its diff cursor on the empty status event; it cannot retract chunks already sent to the client. With Studio's new default nudge_tool_calls=true, a reply like “I'll search the web for that.” is shown and persisted before the re-prompted tool call/final answer, so successful nudged turns are prefixed with the abandoned planning text.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This mirrors the GGUF loop's long-standing re-prompt behavior: the intent streams, then the tool activity follows on the next turn. Retracting already-sent chunks is not possible in SSE and hiding the intent would diverge the two loops.
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Resolve the plan-without-action re-prompt conflict toward the decided policy: the nudge is always on for the Studio inference paths and opt-in for the API. - Centralize the intent regex, cap, and re-prompt message in tool_call_parser so the GGUF and safetensors/MLX loops share one source of truth. - Safetensors/MLX loop keeps the opt-in gate (and nudge_tool_calls) on the new retry while adopting main's executed-turn budget accounting; GGUF keeps its pre-existing default-on behaviour (None keeps nudging). - Studio callers send nudge_tool_calls=true; the /v1 and Anthropic routes forward the request value, which defaults to None (off) on both request models. - Reconcile tests to the decided behaviour: keep the omitted-flag no-reprompt test, drive the Studio-path re-prompt tests with nudge_tool_calls=True, point the parity tests at the shared constants, and add a nudge wiring guard.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
The shared MAX_ACT_REPROMPTS was set to 1, but GGUF's established default (llama_cpp.py) has re-prompted a stalling model up to 3 times since #5620. Restore the GGUF-matched cap so safetensors and MLX inherit the same behavior, and update the safetensors cap test to assert the cap dynamically.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
Tool-call healing is default-on everywhere (request model, GGUF loop, safetensors/MLX loop, and the client-tool passthrough from #6801). The passthrough nudge retry is opt-in via nudge_tool_calls, and stays that way for API callers. This PR makes nudging active by default for Studio chat only:
Testing