Skip to content

Studio: linear-time tool signal scanning in the safetensors and healer paths - #8494

Merged
danielhanchen merged 3 commits into
mainfrom
studio/tool-parse-worstcase
Aug 12, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
studio/tool-parse-worstcase

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Stacked on #8428 (base branch studio/streaming-strip-linear). Review that one first; this PR's diff on top is the three scans below.

Before

#8428 made the llama.cpp streaming display strip linear. Three sibling scans in the same tool paths were still quadratic, and they are on the per-chunk path for every streamed answer that contains, or looks like it contains, tool markup.

  1. safetensors_agentic.py _earliest_tool_signal() re-scanned the entire accumulated text on every chunk, so an answer of N chunks did N full scans.
  2. The same file's streaming display path called the whole-prefix strip per chunk rather than reusing the incremental stripper.
  3. tool_healing.py _build_markers() and the Gemma opener scan in tool_call_parser.py restarted from offset 0 after every candidate they could not use. Text with many openers (a model echoing markup, a code block full of <tool_call>{ examples) is quadratic in the number of openers, independently of streaming.

After

Each scan carries its position forward instead of restarting.

Case Before After
_earliest_tool_signal, 8k chunks 0.267s 0.008s 33x
safetensors streaming display strip, 8k chunks 15.045s 0.013s 1147x
2000 Gemma openers after an unusable closer 125.7ms 2.2ms 57x
800 unclosed JSON markers in _build_markers 370.2ms 0.2ms 1959x

The first two are now linear in response length rather than quadratic.

One thing deliberately not cached

_should_start_provisional_render_html() re-resolves the tool name on every chunk. Caching the first non-None answer looks safe and is not: the first call's name is not final until its marker is complete, and a later complete marker can resolve first. A truncated <function=rende sitting ahead of a finished <function=get_weather> reads as get_weather while the earlier marker is still open, then as render_html once it closes. Caching would pin the wrong answer and drop the panel. The reasoning is in a comment at the call site so it does not get "optimized" later.

Output equivalence

  • tests/tools/refactor_guard.py verify passes against the existing snapshot, without re-snapshotting: symbol inventory, golden outputs, idempotence and monkeypatch targets all match.
  • A differential run over 18,000 rows against the parent commit produces an identical digest (a7c1a1d2...), covering all three entry points (strip_tool_markup, strip_tool_call_markup, parse_tool_calls_from_text).
  • 930 tests pass across the tool, streaming and healing suites.

No public signature changes, no new dependencies, no behaviour change intended or observed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 5684a87434

ℹ️ 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 Author

Ran this on a staging copy rather than adding to the org queue. Green: Unsloth API CI, Windows API, GGUF (Linux/Mac/Windows), Windows UI, Startup profile, Local Agent Guides.

Three reds, all checked individually and none of them this branch:

Backend CI, test_refactor_guard.py (20). Every failure is an addition, not a removal or a changed byte:

ast...tool_call_parser.symbols._GEMMA_ANCHOR_CLOSERS: added
golden...tool_call_parser._gemma_call_is_anchored: added
runtime...tool_call_parser.dir: added "_GEMMA_ANCHOR_CLOSERS"
patch-targets...stt_download_worker.spawn_download[2]: file renamed

_GEMMA_ANCHOR_CLOSERS and _gemma_call_is_anchored landed on main after this stack forked, and the staging replica merges the branch onto main while the branch wins the baseline files. Against this PR real base the guard reports OK: inventory, golden outputs, idempotence and patch targets all match, with no re-snapshot. It resolves on rebase.

Backend CI, the rest. 84 in test_diffusion_prequant / test_diffusion_convrot from torch < 2.6 on that runner, which the pre-quant loader refuses by design; test_openai_auto_switch::test_an_expired_positive_hit_refreshes_before_switching, which fails identically on unmodified main; test_stt_sidecar; and two tests/studio/* frontend contract tests, which assert against frontend source the staging replica takes from main.

Chat UI and Mac. "Voice model picker did not wheel-scroll" and a Playwright TargetClosedError browser crash in the update-banner layout test. This branch touches no frontend.

@danielhanchen
danielhanchen force-pushed the studio/tool-parse-worstcase branch from 85ae833 to be8fe0b Compare August 11, 2026 23:00
@danielhanchen

Copy link
Copy Markdown
Member Author

Rebased onto the updated base branch. #8428 picked up a fix for _safe_cut cutting across an open <parameter> block, and this stack needed it under it rather than beside it. The diff this PR adds on top is unchanged: the three linear-time scans.

refactor_guard.py verify still reports inventory, golden outputs, idempotence and patch targets all matching without a re-snapshot, and 380 tests pass on the rebased head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: be8fe0b5c4

ℹ️ 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 force-pushed the studio/tool-parse-worstcase branch from be8fe0b to 69dca7f Compare August 11, 2026 23:29
@danielhanchen

Copy link
Copy Markdown
Member Author

Rebased again onto the updated base, which now carries the #8427 merge.

All the rebase conflicts were comment-only, two independent comment-reduction passes over the same blocks, so I took the base wording throughout rather than have this PR carry comment churn in files it does not otherwise touch. The one code conflict was _build_markers in tool_healing.py, where the base has the plain loop and this branch has the position-carrying version; kept this branch version, which is the change under review.

Re-measured after the merge, so the numbers are not stale:

Case Base This PR
2000 Gemma openers after an unusable closer 124.4ms 2.2ms 57x
800 unclosed JSON markers in _build_markers 356.0ms 0.2ms 1864x

refactor_guard.py verify clean without a re-snapshot, verify_import_hoist.py PASS, 393 tests pass.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 69dca7f9c7

ℹ️ 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 Author

Re-verified with the same deterministic harness as the rest of the series (scripts/ast_equivalence.py, build_corpus.py, eq_probe.py, pr_differential.py). One real defect found and fixed in 01b39b8.

The defect. _provisional_render_html_possible resolved the gates once before generation, on the reasoning that history and active_tools cannot change during a turn. active_tools is then handed to single_turn, which is injectable and free to append to the list while generating, so a render_html tool added mid-turn would never surface its panel. Before this PR the whole predicate was evaluated per chunk.

The hoist was not worth defending: it saved a dict lookup and a scan of a handful of tools. The expensive part is the name lookup over the growing buffer, and that is what _first_detected_tool_name already handles. All the gates are back inside the per-chunk predicate in the original short-circuit order. The name lookup stays uncached, for the reason recorded there.

Results.

tools      IDENTICAL  78,960 rows
segment    IDENTICAL  22,560 rows
streaming  IDENTICAL   5,641 rows

Streaming invariant within the head: 316,672 prefix comparisons, 0 mismatches. Idempotence measured on both sides, introduced by this PR: none.

AST over the 4 changed files: 255 identical, 22 changed, 4 added, 0 moved across files, 0 removed.

Tests: 382 in the tool and streaming suites, 391 in the safetensors suites. The two failures in test_safetensors_reasoning_stream.py reproduce unchanged on the merge base.

Worst cases re-measured on the current head, so the numbers are not stale:

Case Base This PR
2000 Gemma openers after an unusable closer 124.4ms 2.2ms 57x
800 unclosed JSON markers in _build_markers 356.0ms 0.2ms 1864x

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 3309c8ad0e

ℹ️ 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 Author

Another differential pass over the merge base, this time with a shadow copy of the head that has the fix removed, so the corpora are proven to reach the case rather than merely not flagging it.

The defect. The bounded closed-pair scan in strip_segment ends at the last required closer. For seven of the eight arms the closer is the last thing the regex consumes, so the bound is exact. The Mistral array arm is not one of them: \[TOOL_CALLS\]\s*\[.*?\](?:\s*</s>)? keeps going past the ] the bound is taken from, so the EOS survived into the displayed text.

in    See [1]. [TOOL_CALLS] [{"name": "get_weather", "ar}]</s> Done.
base  See [1].  Done.
head  See [1]. </s> Done.

Two things have to line up. Prose has to put a ] before the first [TOOL_CALLS], which is what turns the bound on, and the array has to be malformed enough to get past the string-aware pre-pass down to this arm. Display only: parse_tool_calls_from_text and _parse_function_xml never differed, so no call was lost or mis-parsed.

Fixed in 7c63e1e by extending the bound over that tail. The walk uses str.isspace() rather than a second regex; re's \s and str.isspace() agree on all 1,114,112 code points, so it is exactly the \s* the pattern would have consumed.

Coverage. 330,000 cases with 13 fields compared each, plus 20,000 streaming replays over 586,568 incremental strip calls. Zero differences against the merge base. The same corpora against the unfixed shadow produce 6,152 differing cases, all of them this one class.

corpus cases fixed unfixed control
mutations 150,000 0 1,233
targeted 40,000 0 1,420
markup soup 60,000 0 1
EOS-targeted 60,000 0 2,264
streaming + signal 20,000 0 1,234

refactor_guard.py verify still reports inventory, golden outputs, idempotence and patch targets all matching without a re-snapshot, which is also why the fix carries no new module-level symbol. 667 tests pass, and pr_differential.py stays IDENTICAL on all three suites with no new idempotence failure.

The remaining red checks are the base branch's, not this diff's. Chat UI Tests, Core, Repo tests and the three scan-packages jobs fail byte for byte the same way on #8428.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@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: 7c63e1e7af

ℹ️ 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".

Comment on lines +840 to +843
brace_end = (
_balanced_brace_end(content, brace_start, gemma_quotes = gemma)
if last_brace is None or brace_start < last_brace
else None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid rebalancing every opener before the final brace

A single trailing } makes brace_start < last_brace true for every preceding candidate, even though it can balance at most the innermost one. For truncated output shaped like '<tool_call>{' * N + '}', _balanced_brace_end therefore scans to EOF once per opener; doubling 400 to 800 candidates grows this path from about 0.16 to 0.65 seconds. This leaves _build_markers, and thus parsing and marker coverage, quadratic on a near-unclosed response; the candidates need a shared forward balance scan rather than using the existence of any later brace as permission to rescan.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The quadratic is real, but it is pre-existing and the suggested remedy is not sound.

Measured on '<tool_call>{' * N + '}', merge base against this branch:

N merge base this PR
400 0.0896s 0.0893s
800 0.3578s 0.3554s
1600 1.4289s 1.4230s
3200 5.7075s 5.7049s

Within noise of each other. The last_brace gate does not fire on this shape at all, because the single } is at EOF, so brace_start < last_brace holds for every candidate. This PR neither introduced the behaviour nor claims to remove it.

On the remedy: a shared forward balance scan is not equivalent to running _balanced_brace_end per candidate, because a candidate brace can sit inside a string literal of an earlier call, where a single global pass never treats it as a brace at all.

content = '<tool_call>{"x":"<tool_call>{"}'
  { at 11 -> _balanced_brace_end = 30    (succeeds)
  { at 28 -> _balanced_brace_end = None  (fails)

The later candidate fails while the earlier one succeeds, so you also cannot prune candidates from a neighbour's result in either direction.

There is a sound version, memoising per position rather than per scan (every candidate scan starts outside a string, so two scans that reach the same index agree from there on), and it takes N=3200 from 5.71s to 0.018s. It needs three new module-level tables, which changes the module surface that refactor_guard.py pins, and it is a change to the balanced scanner rather than to the scan bounding this PR is about. Separate PR.

"<parameter", last_param_start
):
param_closers = tuple(reversed(param_closers))
if any(content.find(tag, pos + 1) >= 0 for tag in param_closers):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stop searching the remaining parameter suffix per marker

When a parameter is unclosed and its value contains many literal <function=...> markers, this find searches from each marker to EOF for an absent parameter closer. The reverse opener lookup therefore does not make the overall filtering linear: _parse_function_xml and the healer call _inside_open_parameter for every candidate, producing quadratic work on exactly the truncated code/XML argument case this optimization is intended to handle. Carry or precompute the next closer position instead of rescanning the suffix for every marker.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Pre-existing, and this PR already improves it rather than regressing it. _parse_function_xml end to end, milliseconds:

N merge base this PR
250 3.72 2.36
500 27.4 11.1
1000 106.1 70.7
2000 433.5 305.1

Both grow about 30x for 4x N, so the path was quadratic before this PR and still is; the reverse opener lookup made it faster without making it linear, which is a weaker claim than the one being rejected here but is the claim the change actually makes.

Worth recording that line 736 is not the only unbounded scan on that path. The two supposedly bounded finds above it are bounded on the suffix, not the prefix, so their window grows with pos as well. Fixing only the closer search leaves the realistic shape at roughly 135x. A version that indexes all of them, via an optional keyword defaulting to today's behaviour, takes N=2000 from 305ms to 2.3ms and the whole-turn streaming display arm from 42.2s to 9.6s at 800 lines. That is a new shared index and two new module symbols, which refactor_guard.py pins, so it belongs in its own PR alongside the _balanced_brace_end memo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correcting my own table above: the N=500 base figure of 27.4 ms is not reproducible and the 2.47x it implies is wrong.

It fails an internal consistency check on the numbers I posted. The path is quadratic, so each doubling of N should cost about 4x. My base column gives 7.37x for 250 to 500, then 3.87x and 4.09x for the next two steps. That first step is the outlier, not the trend.

Re-measured just now, minimum over 5 rounds, _parse_function_xml on <function=a><parameter=x> followed by N literal <function=bN> markers, milliseconds:

N base head speedup
250 1.41 1.00 1.41x
500 5.04 3.41 1.48x
1000 18.78 12.11 1.55x
2000 110.80 43.64 2.54x

Absolute numbers on this path swing by roughly an order of magnitude with the exact input shape, so the shape above is stated explicitly rather than left implicit as I left it the first time.

What does not change is the conclusion: head is faster than base at every N, never slower, and both remain quadratic. The improvement in the middle of the range is about 1.5x, not 2.5x.

if not (auto_heal_tool_calls or tool_protocol_active):
return text
# Safetensors-only Magistral leading-reasoning removal first, then the shared strip.
return _streaming_stripper.strip(_strip_mistral_reasoning(text))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make leading Magistral reasoning removal incremental

For the standard Magistral stream that begins with [THINK], this call still runs _strip_mistral_reasoning over the entire cumulative snapshot before every incremental-strip invocation. While the block is unclosed, its find scans the growing reasoning prefix to EOF on every token; after it closes, each call searches that prefix again and allocates the complete visible suffix. Consequently long Magistral reasoning remains quadratic even though StreamingMarkupStripper itself resumes incrementally, so the leading-block cursor/removal also needs to carry state across snapshots.

Useful? React with 👍 / 👎.

@danielhanchen danielhanchen Aug 12, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

_strip_mistral_reasoning is byte-identical on both trees, and the merge base already called it on the whole cumulative snapshot at the same point. This PR only moved that unchanged call into _strip_streaming_display. Instrumented over one identical 4004-snapshot replay, the Magistral term is unchanged at 4005 calls and 32,088,054 summed input characters on both trees, while the scan this PR does target drops from 32.1M to 0.32M characters.

Per-token replay through run_safetensors_tool_loop:

tokens merge base this PR
8k 384ms 49ms
16k 2168ms 251ms
32k 9099ms 1000ms

Quadratic on both, and 9.2x faster in absolute terms here.

Reachability is also narrower than it looks. With skip_special_tokens=True on the safetensors streamer, Magistral 1.1 and 1.2 mark [THINK]/[/THINK] as special ids, so the markers never reach this loop; only Magistral 1.0 tokenizes them as ordinary text. On that model the total overhead at the 32k ceiling is about 1.0s against 200s or more of generation.

A streaming version of the leading-block cursor exists and takes 1000ms to 230ms, but it is a pre-existing cost this PR reduces rather than one it adds, so it goes in the same follow-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correcting one sentence in my reply above. I said Magistral 1.0 tokenizes [THINK] and [/THINK] as ordinary text. That is wrong.

mistralai/Magistral-Small-2506 contains zero occurrences of the string THINK anywhere in tekken.json, and its system prompt uses plain <think> and </think>. So 1.0 does not tokenize those markers as text, it never emits them at all.

mistralai/Magistral-Small-2507 does carry them:

{'rank': 34, 'token_str': '[THINK]',  'is_control': False}
{'rank': 35, 'token_str': '[/THINK]', 'is_control': False}

The correction makes the original point stronger rather than weaker, which is exactly why it was worth getting right instead of leaving a claim a reader would spot-check and find false.

Two limits on the surrounding argument that I should have stated at the time. The decode premise holds only when markers is None (core/inference/inference.py:1780-1793); ReasoningTextIteratorStreamer forces it False. That is true for Magistral today by omission rather than by design. And third-party conversions do not necessarily ship the added tokens, so "never reaches this loop" covers the official and unsloth/* conversions, not every conversion on the Hub.

@danielhanchen
danielhanchen force-pushed the studio/streaming-strip-linear branch from f3ea450 to 71aa0bf Compare August 12, 2026 10:46
Base automatically changed from studio/streaming-strip-linear to main August 12, 2026 10:47
@danielhanchen
danielhanchen force-pushed the studio/tool-parse-worstcase branch from 7c63e1e to f678f0c Compare August 12, 2026 10:59
@danielhanchen

Copy link
Copy Markdown
Member Author

Rebased onto main. The base PR landed as #8538, GitHub auto-closed the old base branch and retargeted this one, which left it conflicting; it now sits directly on main at 87cd048.

Conflicts were the expected two kinds. Comment-only in three places, two independent comment-reduction passes over the same blocks, resolved to the base wording throughout so this PR carries no comment churn. The one code conflict was _build_markers in tool_healing.py, base has the plain loop and this branch the position-carrying version; kept this branch's, which is the change under review.

One fix this round, on the 256-byte gap probe. Details in the thread; the short version is that the probe only moved the cliff rather than removing it, and the bound it was gating is unconditionally sound, so it is now always applied. 8000 openers behind 360 bytes of prose went from 3.629s to 0.007s, and growth is linear.

The other three items are all pre-existing quadratics measured on the merge base rather than regressions from this diff. _build_markers is within noise of the base on the shape raised (0.0893s vs 0.0896s at N=400, 1.423s vs 1.429s at N=1600), _inside_open_parameter is faster than the base at every N but still quadratic, and _strip_mistral_reasoning is byte-identical to the base and 9.2x faster in this path. Each has a working prototype; all three need new module-level symbols that refactor_guard.py pins, and all three are changes to the scanners rather than to the scan bounding this PR is about, so they go in a follow-up.

Re-verified after the rebase against the new merge base: refactor_guard.py verify clean without a re-snapshot, 668 tests pass, pr_differential.py IDENTICAL on tools (78,960 rows), segment (22,560) and streaming (5,641) with no idempotence failure introduced. The differential fuzzers were re-run at 330,000 cases with 0 diffs, with an unfixed shadow tree as a control to prove the corpora reach the cases.

The red checks are repo-wide. Mac Studio UI + API + Update CI is failing on main and on every open PR right now, and the rest fail identically on other branches.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen
danielhanchen force-pushed the studio/tool-parse-worstcase branch from f678f0c to b99e8e6 Compare August 12, 2026 11:02
@danielhanchen

Copy link
Copy Markdown
Member Author

Rebased onto main now that #8427 and #8538 have landed as squashes. Because both went in squashed, a straight git rebase tried to replay their commits and conflicted; I rebuilt the branch as main plus this PR's own 4-file delta instead and verified the result rather than eyeballing it.

Two conflicts, both resolved toward main:

Verification of the rebuild:

  • Symbol-level AST comparison against the pre-rebase head. The only differences are the functions where Studio: give the tool-call strip one owner and one scan order #8427's later commits and this PR both made changes (_inside_open_parameter, _strip_gemma_wrapperless_calls, strip_segment, _balanced_brace_end, _balanced_bracket_end), plus _gemma_call_is_anchored and _GEMMA_ANCHOR_CLOSERS which main has and the pre-rebase branch did not. The diff against main is exactly this PR's intended changes.
  • Tool suites, this branch against a same-session run on main at 87cd0480: 2762 passed vs 2760, and the failure sets are byte-identical (12 ids, all environmental here: no network, no sqlite_vec, no fastmcp).

Also added a test this branch needed. The loop now drives a StreamingMarkupStripper, so the exported strip_tool_markup_streaming has no call site left in safetensors_agentic.py, while ten assertions in test_safetensors_tool_loop.py still target it. Without a link between them the suite would look like it guards the loop while guarding a parallel implementation. The new class asserts the two agree at every prefix.

@danielhanchen

Copy link
Copy Markdown
Member Author

CI note. Every failing check on this PR fails at the same place, and none of them are this PR's doing.

Check Failing step
Tool calling Tests Install Unsloth (--local, --no-torch)
JSON, images Install Unsloth (--local, --no-torch)
OpenAI, Anthropic API tests Install Unsloth (--local, --no-torch)
GGUF inference smoke (API, tools, vision) Install Unsloth (--local, --no-torch)
Unsloth API & Auth Tests Install Unsloth (--local, --no-torch)
Unsloth install + inference without Visual Studio Install Unsloth, no build tools present
Chat UI Tests, Chat UI/API/Update Tests Install Unsloth (--local, --no-torch)
Wheel build + content sanity + import smoke Build frontend
startup ubuntu-latest / macos-15 / windows-latest Install Studio

main carries a duplicate HubModelPicker import in model-selector.tsx, which is TS2300 for tsc and aborts npm run build, so studio setup exits 2 before any test runs. #8534 deletes that line. The tool-related jobs here are the ones I would most want to see green on this PR, so I checked each rather than assuming: all three stop at the install step and never reach a test.

pip scan-packages :: hf-stack is separate and also not from this PR: openai 3.0.0 pulled in httpx2 and a new workload-identity module, which the supply-chain scanner flags as non-baselined. Being handled on #8534.

danielhanchen and others added 3 commits August 12, 2026 12:42
…r paths

Rebuilt on main after #8427 and #8538 landed as squashes.
The loop now drives a StreamingMarkupStripper, so the exported
strip_tool_markup_streaming had no call site left in the module while ten
assertions in this file still targeted it. Agreement is now asserted at every
prefix, so the suite guards the path the loop actually runs.
@danielhanchen
danielhanchen force-pushed the studio/tool-parse-worstcase branch from 6e56fcf to 194da73 Compare August 12, 2026 12:44
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

Rebased onto main at 993e3e45, which now carries #8534 and #8506. Clean rebase, no conflicts this time, so the earlier hand-resolved _build_markers conflict is settled history rather than something a reviewer has to re-check.

The previous CI run on this PR predates #8534, so every red on it was the duplicate HubModelPicker import aborting studio setup before any test ran. This run is the first one on this branch where the tool jobs actually execute.

Local check on the rebased head, 760 passed: test_safetensors_tool_loop, test_streaming_stripper, test_refactor_guard, test_tool_xml_strip, test_tool_call_parser_strict, test_gemma_tool_parse_edge_cases, test_rehearsal_in_code_block, test_tool_strip_guard.

One red that will remain and is not from here: Core (HF=latest + TRL=latest) runs unsloth-zoo at main against transformers 5.x. unsloth-zoo #1046 has landed and unslothai/unsloth-zoo#1051 tightens the same guard further.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 194da73330

ℹ️ 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 9a3a30e into main Aug 12, 2026
37 of 44 checks passed
@danielhanchen
danielhanchen deleted the studio/tool-parse-worstcase branch August 12, 2026 12:52
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