Repository navigation
Unsloth Studio: a JSONL reply that quotes <tool_call> no longer stalls the tool parser and fails the turn with RecursionError - #14097
Conversation
…instead of recursing When a reply opened with a bare JSON value quoting tool markup and held no call, parse_tool_calls_from_text called itself on the rest, once per value, and re-masked the whole remainder each time. A JSONL reply quoting <tool_call> on every line (a Hermes-format dataset) stalled for about a minute and then failed the turn with RecursionError. The skipped values now advance a loop over the text masked once.
…pability picks (#14138) ## Summary `Repo tests (CPU, studio)` fails on every PR whose base includes #14083, with the same single test: ``` tests/studio/test_model_picker_contracts.py::test_diffusion_capability_labeled_image_video_gen assert '{ value: "diffusion", label: "Image/video gen" }' in _read("features/hub/lib/model-type-filter.ts") ``` Seen on #14097, #14106, #14112, #14115, #14122 and #14125 (bases `72d0d2db`, `b4a4855e`, `4c5fb400`), and it reproduces on main at `1e2cedde`. ## Cause #14083 (Studio Hub: On Device filters and sort) moved the On Device list onto Discover's capability picks, on purpose. `model-type-filter.ts` no longer keeps its own `MODEL_TYPE_FILTER_OPTIONS` (which held `{ value: "diffusion", label: "Image/video gen" }`). Its `matchesInventoryCapabilities` now takes `HubCapabilityFilter` picks and matches them with Discover's own `matchesHubCapability`, so the On Device panel shows Discover's "Image gen" and "Video gen" tiles. The PR describes this as change 2. The product is right and the test is stale. What the test protects (#11681) is that the diffusion capability is never presented as "Image to text". That still holds: the only names now shown for it are Discover's "Image gen" / "Video gen" options and the capability badge's "Image gen" / "Video gen". ## Change Test only, `test_diffusion_capability_labeled_image_video_gen`: - **Kept as before:** - "Image to text" must not appear in the three hub files. - Discover's options must be `{ value: "image-gen", label: "Image gen" }` and `{ value: "video-gen", label: "Video gen" }`. - **New:** the capability badge in `model-capabilities.ts` must name the same two kinds. - **Replaced** the literal from the deleted On Device list. Now, if `model-type-filter.ts` has a `diffusion` option, it must still be labeled "Image/video gen". Otherwise the file must match through `matchesHubCapability`, so On Device cannot quietly grow a second, unchecked set of names. ## Testing - **This change:** `tests/studio/test_model_picker_contracts.py` gives 201 passed. - **Before (main `1e2cedde`):** the same file gives 1 failed, 200 passed, the failure CI shows. - **Each of these makes the test fail:** - Relabeling Discover's `image-gen` option "Image to text". - Renaming `matchesHubCapability` out of `model-type-filter.ts`, so On Device no longer shares Discover's matcher. - Adding back an On Device `{ value: "diffusion", label: "Image to text" }` option.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ning after a quoted opener is not executed [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85ce154e1d
ℹ️ 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".
| content = content[end + 1 :] | ||
| skipped = True | ||
| continue |
There was a problem hiding this comment.
Keep a cursor instead of copying each JSONL suffix
When every leading JSON value quotes a tool marker (the Hermes JSONL input this change handles), this assignment copies the whole remaining response and continue reruns _xml_signal_inside_leading_bare_json, whose _first_foreign_tool_signal performs several whole-suffix searches. The iterative version therefore remains quadratic: on the target tree, 3,200/6,400/12,800 33-byte rows took about 1.2/3.8/13.2 seconds, so a roughly 422 KB answer still blocks the end-of-turn parser for seconds despite avoiding RecursionError. Keep an offset into one buffer and avoid rescanning later signals so each row is consumed once.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not a correctness bug: base raised RecursionError here; head returns the right answer, about 0.02 s at 400 rows and 1 s at 3,200. A 400 KB JSONL reply taking seconds at end of turn is acceptable, and a cursor would thread offsets through every leading-value helper.
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
Line numbers are at main
e795149.What's broken
When a reply opens with a JSON value that quotes tool markup but isn't a call,
parse_tool_calls_from_text(studio/backend/core/inference/tool_call_parser.py:2367) calls itself on the rest of the text (:2403, and the Gemma path at:2426). It does that once per leading value, and every level re-masks the whole remainder. N lines means N levels of recursion and O(N²) masking.A Hermes-format JSONL dataset pasted into chat is exactly this shape. With tools on, the reply is re-parsed after every streamed answer, so the answer finishes, then the turn stalls and fails with
RecursionError.Fix
Strip and mask once, then loop. A skipped leading value advances
contentandcontinues instead of recursing. The mask is equal-length, so slicing it gives the same view the tail call built.Evidence: CPU on Windows 11, base
08fb7bcvs66f4b53, withtests/test_tool_parser_leading_json_lines.py.RecursionError: maximum recursion depth exceededEvery suite that imports the parser: 3821 pass, plus the same 10 Windows-only failures as base. Not run: a live model reply.
Full logs: LeoBorcherding#322