Repository navigation
Studio: report the real error instead of "Unknown tool" - #9640
Conversation
Review + GitHub Actions A/B evidencePinned review: Reproduced on Full A/B run — every leg asserted strictly, all 12 steps green.
The card column is the user-visible payload: it is produced by running the real What I checked beyond the diff
Conclusion: the swallow and its fix are both verified with real values on Actions, and I found no blocker. No screenshots: this is a backend change with no frontend delta, so the visible effect is the tool-card string reported above rather than a layout difference. |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
Review reportTested refs: base Before: On the base, After: The original PR head passed all 11 backend cases and propagated the real tool exception through direct dispatch and the streamed tool loop. That exposed a second defect: Verdict: Real. The same harness failed on the exact base for the claimed reason and passed on the original head. The UI defect also reproduced on the original head and passed on the repaired head with identical loopback-provider input. Regression risk:
Compatibility: Local A/B and UI tests ran on macOS 27.0 arm64 with CPython 3.12.13, Node 24.16.0, and Playwright 1.57.0. The repaired UI scene passed in Playwright Chromium and WebKit. This change does not alter hardware selection, model execution, persisted data, or dependency formats. UI evidence: In both composites, the original head receives the exception but leaves Chat blank. The repaired head renders the Python error card and Fixes: The PR's backend fix is Gaps: The exact malformed-tool UI scene was not run natively on Linux or Windows. Branded Firefox was blocked by its nested macOS sandbox; branded Chrome and Edge were unavailable; native Safari was not run, and WebKit is not Safari proof. The UI test used a deterministic loopback provider rather than an external model provider. No performance, stress, or soak run was needed for this exception-path change. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs 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". |
|
Confirmed this on main, where studio/backend/core/inference/tools.py:7353 still returns from inside the finally in _session_in_flight and drops the real exception, so a failing python or terminal call comes back as "Unknown tool". The backend half is the valuable part here; the tool-ui-python.tsx guard overlaps #9641, so we should reconcile the two before either lands. |
_session_in_flight returned from inside its finally, which discards a propagating exception. Because it is a @contextmanager, contextlib reads the resulting StopIteration as "handled", so execute_tool fell past the remaining arms and answered "Unknown tool: python" for every failing python, terminal or edit_file call. The comment at tools.py:9386 already described this from the field. Python 3.14 flags the line directly (PEP 765). Using `if pending:` keeps the cleanup exactly as it was and just removes the return. The refcount decrement, the _removing_sessions release and the notify_all all already ran on the exception path, so no lifecycle state changes; only the exception survives now. Also drops a dead local. Once exceptions propagate the three tool loops disagreed. studio_tool_loop and safetensors_agentic already turn a raising tool into "Error: tool raised an exception: ...", hand it to the model and let it recover. llama_cpp had no handler around stream_tool_execution, so the enclosing per-iteration handler re-raised and a bad argument killed the whole GGUF answer. It gets the same arm as the other two, re-raising _LlamaStreamCancelled first because that subclasses Exception and is not a tool error. Tests cover the guard's state machine on the exception path (queued deletes, nesting, case-folded ids, a failing cleanup, waiter wakeup, 100 randomised concurrent schedules) and each loop's exception contract, including that research_runs still names only unguarded tools.
d6b8f4e to
3aae7e7
Compare
Verification, and two changes pushed to the branchReproduced this end to end and pushed the result: the branch is rebased on The bug is real and was still live on
Worth adding to the description: the swallow was intermittent, not universal. Python 3.14 confirms the diagnosis at the exact line. An independent AST sweep of the whole backend agrees with your completeness claim: one occurrence, this one. What I changed1. This is the one thing that would have broken on merge. Once exceptions propagate the three loops disagree:
The innermost
So the middle column is the regression: the PR alone traded a wrong message for a dead chat on the flagship local path. It now gets the same arm the other two have, re-raising 2. Dropped the frontend half. #9641 merged and already covers Nothing else is lost by dropping it, so the backend fix stands alone now. 3. Kept your two tests and added two focused files covering what the originals did not: the guard's state machine on the exception path, and each loop's contract. Does it break anythingFull backend suite, integration tree against pristine Nothing anywhere matches the State machine, each case asserting the key is absent from
Every one of those on Python 3.10, 3.11, 3.12, 3.13 and 3.14, all five identical: base fails exactly the three propagation cases, head and head-plus-fix pass all 110. One behaviour change worth naming. Old installs. Seeded a Browsers, since #9641 ships alongside this. Real engines running the repository's own
Identical on all five except 100k-deep nesting, where Chromium serialises and Firefox and WebKit hit their recursion limit and return Two things I found and deliberately did not change
GapsEverything above ran on Linux x86_64. Native Windows and macOS come from this PR's own CI rather than from me, so read those jobs, not this comment, for them. Playwright WebKit on Linux is not branded Safari and I did not run Safari. No GPU axis applies: the change is control flow in a contextmanager and touches no hardware selection or model execution. |
|
Codex Review: Didn't find any major issues. Keep them coming! 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: Didn't find any major issues. 🎉 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". |
* Studio: stop the session guard from swallowing tool exceptions _session_in_flight returned from inside its finally, which discards a propagating exception. Because it is a @contextmanager, contextlib reads the resulting StopIteration as "handled", so execute_tool fell past the remaining arms and answered "Unknown tool: python" for every failing python, terminal or edit_file call. The comment at tools.py:9386 already described this from the field. Python 3.14 flags the line directly (PEP 765). Using `if pending:` keeps the cleanup exactly as it was and just removes the return. The refcount decrement, the _removing_sessions release and the notify_all all already ran on the exception path, so no lifecycle state changes; only the exception survives now. Also drops a dead local. Once exceptions propagate the three tool loops disagreed. studio_tool_loop and safetensors_agentic already turn a raising tool into "Error: tool raised an exception: ...", hand it to the model and let it recover. llama_cpp had no handler around stream_tool_execution, so the enclosing per-iteration handler re-raised and a bad argument killed the whole GGUF answer. It gets the same arm as the other two, re-raising _LlamaStreamCancelled first because that subclasses Exception and is not a tool error. Tests cover the guard's state machine on the exception path (queued deletes, nesting, case-folded ids, a failing cleanup, waiter wakeup, 100 randomised concurrent schedules) and each loop's exception contract, including that research_runs still names only unguarded tools. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Tighten the comments added by this change * Drop comments that restate the assertion beside them --------- Co-authored-by: danielhanchen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
|
Independently confirmed this is a genuine bug. Before the fix, exceptions from Python, terminal, and A/B tests passed on Ubuntu, Windows, and macOS. Live Studio UI repros also passed on Chromium, Firefox, and WebKit. Successful tools, genuinely unknown tools, cancellation, cleanup, and concurrency behavior remained unchanged. OS A/B run · Studio UI A/B run Genuine fix; no regression found. |


Give the python tool a bad argument and the model gets told "Unknown tool: python". The tool exists. The error was thrown and then thrown away.
_session_in_flight has a return inside a finally, which drops whatever exception was on its way out. The normal path always hits it, so this happens on every python, terminal, and edit_file call.
Calling the python tool with {"code": 42}:
before: Unknown tool: python
after: AttributeError: 'int' object has no attribute 'strip'
studio_tool_loop already catches this and passes it back to the model, and it re-raises CancelledError first, so cancelling still works the same. Changing the check to if pending: keeps the cleanup as it was and just removes the return.