Repository navigation
[fold013 resolution for #2052, do not merge] #2052 + #2049 + #2051 - #2062
Conversation
…tead of failing (red)
With `parallel_tool_calls: false`, a model that makes a second call fails
the response: on the streamed `auto` path the first call has already left
when `NativeToolStreamRouter.admitCall` throws `toolChoiceViolation`
("parallel tool calls are disabled for this request"), so the client sees
a stream that errors mid-response; on the complete-call paths (and Nemotron
Super's owner) the response is a 422. Nothing in the prompt asks the model
for a single call. OpenAI returns at most one call and vLLM keeps the first
(`maybe_filter_parallel_tool_calls`).
These tests expect the first call to be returned and every later call to
be dropped (valid, off-schema under `strict`, or undeclared), with no
error. They fail on dev 6bc14de; the Super HTTP case replaces the old
422 expectation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(red)
GLM's tool parser withholds a response from its first `<tool_call>` to EOS
and parses that suffix as one call batch. On the legacy text path it also
reads the reasoning, so a `<tool_call>` the model only mentioned or drafted
in its thought, or a text answer that mentions the tag, fails the batch, and
`NativeToolStreamRouter.checkNativeToolFailure` turns that into
generationFailed("native GLM tool output is invalid"): a 500 for the whole
response. Production (OpenRouter, 72 h): 80 GLM tool requests ended this way,
55 cut mid-stream and 25 as HTTP 500 after 4-10 attempts.
These tests pin the reference behaviour (vLLM's and SGLang's GLM parsers
return unmatched markers as text): on an `auto` request the calls are the
frames from the earliest `<tool_call>` whose rest parses to the end of the
response, everything before them is text, and a suffix with no such rest is
all text; a required call still fails closed (422); no call is completed,
salvaged from a malformed final frame or split out of an output cut at the
token limit. The conformance replay's shapes (a call drafted in the thought,
a tag mentioned in the thought, a text answer that mentions it, clean calls)
run through the production event stream, at 1- and 4096-character chunks.
Red on dev 6bc14de: the stray/unparsed `auto` cases fail with the 500.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ack switch (red) 9B-MIDFAIL (11-12): with provider 0.10.12 the catalog Qwen3.5-9B lost the model card's presence_penalty 1.5 (#1961). In production, in the same 10-minute windows as 0.10.11 Macs, its JSON response_format answers ran to max_tokens and failed about twice as often (51 % against 23 % on the 4,096-token workload; Mantel-Haenszel odds ratio 3.1), and answers with a max_tokens of 8,192 or more hit it 6.1 % of the time against 1.5 %. A registry presence_penalty 1.5 (2026-11-12 19:17Z) brought both back. Those JSON rows never speculate (a token constraint), so neither MTP acceptance nor the template differs for them between the two releases: the penalty is the difference. Red on dev: - qwen35CatalogBuildsUseTheirModelCardDefaults and qwen35OmittedPresencePenaltyFollowsEachBuildsGate expect 1.5 on the 9B. - qwen35NineBPresencePenaltyRollbackSwitch: DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY=0/off/false restores 0.10.12's no-penalty default on the 9B alone; anything else keeps the card's. - qwen35NineBPenaltySwitchReachesTheDaemon: `darkbloom start` passes it to the launchd daemon. Only the API surface the tests name is added (the key constant and an environment parameter, unused); behaviour is unchanged.
…rollback switch The 0.10.12 regression in 9B-MIDFAIL: #1961 dropped the catalog Qwen3.5-9B's default presence_penalty (the model card's 1.5) on the strength of a 31-draw gate. In production the 9B's answers then ran to max_tokens about three times as often, and its JSON response_format answers ran out about twice as often as on 0.10.11 in the same hour. Those JSON rows never speculate (a token constraint), and the 9B's template and JSON constraint are unchanged since 0.10.4. So the difference is the penalty itself, not MTP acceptance or the template. A registry presence_penalty 1.5 restored both from 2026-11-12 19:17Z. - EngineV2SamplingDefaults: every catalog Qwen 3.5/3.6 build, the 9B included, takes qwen35CardDefaults (T 1, top_p 0.95, top_k 20, presence penalty 1.5) for omitted knobs. A request's own value, the coordinator's registry default included, still wins. - DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY: 0/off/false/no restores 0.10.12's no-penalty default on the 9B alone (qwen35NineBNoPenaltyDefaults). It is read at slot construction from the factory's environment, and LaunchAgent.inferencePassthroughEnvKeys carries it to the launchd daemon. - MTPAcceptancePolicy: unchanged. The 9B's built-in rule stays exact for the rows that still draft (presence_penalty 0 or the rollback). - A penalty row does not speculate. It still donates prefix checkpoints (Qwen35CardDefaultDonationTests now serves the 9B on its own default). - The red test's rollback list gains "no", as the repo's other switches accept it. - Docs: inference.md (the sampling table, the Qwen defaults table, the acceptance rule), prefix-cache.md invariant 9, configuration.md (the new switch). Changelog fragment.
…stead of failing mid-stream OpenAI returns at most one call with `parallel_tool_calls: false`, and vLLM keeps the first (`maybe_filter_parallel_tool_calls`). We failed the response instead: the streamed `auto` path threw `toolChoiceViolation` after the first call had already left (a mid-stream error), and the complete-call paths returned a 422, although nothing in the prompt asks for a single call. - `NativeToolStreamRouter` exposes the first call only; a later frame, exposed-name or not, valid or not, is consumed and dropped without being validated (`admitsCall` / `droppingCall`). - `ToolConstraintValidation.admitted` keeps the first call on the complete-call paths: the scheduler's terminal flush (native channel families, required/named, one-piece surfaces) and Nemotron Super's owner output. `validate` keeps its cardinality check as defense in depth. - The prompt is unchanged (no template reads the flag), so the coordinator sidecar's prompt mirror is unaffected; GLM pairs keep their single-call instruction. Tests: StreamedToolCallTests (later calls dropped, strict and not; an unexposed later call dropped unvalidated, now a Harmony frame: Qwen's parser returns an undeclared frame as text, so its red-commit version never reached that path; the complete-call helper), NemotronSuperMediaControlsHTTPTests (two calls -> the first, was 422). Docs: inference.md, direct-mode.md. Changelog fragment parallel-tool-calls-false-first-call.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GLM's SDK tool stream (`GLM5ToolStream`) withholds a response from its first `<tool_call>` to EOS and parses that suffix as one call batch; on GLM `auto` requests (the legacy text path) the suffix also holds the reasoning. A tag the model only mentioned or a call it drafted in its thought, or a text answer that mentions the tag, failed the batch, and `checkNativeToolFailure` turned it into generationFailed -> a 500 for the whole response (80 OpenRouter GLM tool requests in the 72 h to 11-13 05:10Z; 13-34/day, ~74/day at the 11-13 tool rate). As vLLM's and SGLang's GLM parsers return unmatched markers as text: - `GLM5ToolSuffix.split` (new): when the SDK's whole-suffix parse fails, the calls are the frames from the earliest `<tool_call>` whose rest parses as calls to the end of the response (the SDK's public `GLM5ToolCallParser`, unchanged strictness); everything before them is text. A suffix with no such rest (a malformed or cut-off final frame, text after the calls) is all text, so a later malformed frame still never commits an earlier call. At most 64 starts are tried. - `NativeToolStreamRouter.finishCompleteCalls(truncated:)` applies it at the complete-call terminal (the scheduler calls it instead of the handler's `finish()` + `takeResidualText()`); an output cut at the token limit is never split. - `checkNativeToolFailure`: an `auto` GLM parse failure is no longer thrown; its text leaves through the existing residual path, which the service's reasoning parser splits at `</think>`. Required/named calls still fail closed (422); MiMo, Flint and the streamed-call path are unchanged. - `DARKBLOOM_GLM_TOOL_TEXT_FALLBACK=0` restores the 500 (no split); it is on `LaunchAgent.inferencePassthroughEnvKeys`. Tests: the red suite passes, plus the rollback and the 64-start bound. Docs: inference.md (GLM5Next implementation boundary), configuration.md. Changelog: glm-stray-tool-call-text.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the dedicated refactor-pass subagent (behaviour-preserving): - the scheduler destructures `finishCompleteCalls` into `(toolCalls, residual)`; - the test suite's result type is `Outcome` (it shadowed `Swift.Result`), `expectUnparsed` no longer throws, and a custom tool body keeps the request's tool choice; - the 64-start bound is worded exactly: calls after 64 or more tags stay text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ct wording From the refactor pass's assessment (no further cleanup warranted): - the forced refusal test runs named as well as required choice; - a suffix that parses keeps its calls at `length` (unchanged), next to the stray suffix that is not split there; - docs, changelog and the router comment say exactly that: only a suffix that did not parse stays text in an output the token limit cut off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the independent review of 7fb1f8d (REQUEST CHANGES): 1. BLOCKER: retrying every literal `<tool_call>` could promote a frame that sits inside an unfinished argument (a JSON string, or a raw string value) into an executable call. `GLM5ToolSuffix` now reads the suffix's frame structure as the SDK's parser does (`Lexer`): a frame that has started its arguments owns everything up to its `</tool_call>`; a string-typed value runs raw to `</arg_value>`, any other value is JSON whose quoted delimiters are data. The calls are the trailing run of top-level frames, separated only by whitespace and ending the response, from just after the run's last frame that does not parse (each frame parses on its own), and the SDK's `parseEOS` must agree on them; anything else is all text. 2. A think marker inside a released frame would reach the service's reasoning parser as a channel boundary: such a suffix keeps failing, as before (`Split.ambiguous`; `finishCompleteCalls` now throws it). 3. Work is linear in the suffix: one structural pass, each run frame parsed once on its own (from the end) and the run once by `parseEOS`; the 64-start bound is gone. 4. Docs, changelog and comments describe a stricter provider rule inspired by the reference parsers' no-failure fallback, and its deliberate divergences (a call followed by text or a malformed frame commits nothing; a call drafted in a closed thought stays reasoning). Tests: both review witnesses (JSON and raw nesting, with `stop` and `length`, at three chunk widths) and a frame after an argument stay text with no call; think markers inside a released draft keep the 500; 20,000 mentions before a call parse it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r frames before routing them Same behavior as the previous commit, fewer lines shared with the other 0.10.13 tool-output PRs (#2053 changes the same `routeToolSegment` cases and adds `validateWithheld` where `admitted` was): - `ParallelToolCallPolicy` (new file) holds `admitted` (withheld calls: the first) and `LaterCallFilter` (streamed segments of every call after the first are consumed: `.callStarted` opens a dropped frame, its arguments and its completion or failure are swallowed, and an unexposed `.call` after an exposed one is dropped before validation). - `NativeToolStreamRouter`: one stored filter and one line at the top of `routeToolSegment`; the case bodies and `admitCall` are back to `dev` (its parallel throw is unreachable now, kept as defense in depth). - `ToolConstraintValidation` is back to `dev`; the scheduler's terminal flush and Nemotron Super's output call `ParallelToolCallPolicy.admitted`. - inference.md: the "holds either way" sentence is back to `dev` (still true: one call); the streamed-calls paragraph names the policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d later frames, the engine terminal The independent review of 0d73e28 (CHANGES REQUESTED): - B1: `NemotronSuperLocalOutputTests.testToolPolicyViolationsFailClosed` still expected two calls under `parallel_tool_calls: false` to throw; CI run 43374842176 failed exactly there. The case moves to its own test, which expects the first call (streamed and complete) and both calls without the flag. - Nothing covered the filter's `.callFailed` / `.callCompleted` branches: `failedLaterFramesAreDroppedToo` drops a later Gemma frame that closes against what it streamed, one cut by the end of generation (unterminated, diverged) and one ended by the stop token, strict or not, at the token limit or not. Without those branches the dropped frame's failure reaches `routeToolSegment` and fails the stream. - Nothing covered the scheduler's complete-call terminal: `completeCallTerminalReturnsTheFirstCall` serves a forced Gemma choice with two calls through the service and the engine's event stream. - `StructuredForcedToolAdmissionTests.serve` mirrors the engine terminal again (`ParallelToolCallPolicy.admitted`), and its forced `parallel_tool_calls: false` case expects the first call (Qwen 3.5, 3.6, MiMo) instead of the old violation. All of these fail on dev 6bc14de, where a second call throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ater frames - The prompt does ask for one call in two cases (a GLM pair's automatic choice, and forced choices with `parallel_tool_calls: false`), so the changelog and `ParallelToolCallPolicy` now say "under automatic choice" and "only a GLM pair's prompt does". - A later frame keeps its family's malformed-output rule: GLM, MiMo, Flint and Nemotron Super still fail a response on any frame that does not parse, and a frame a parser returns as text (an undeclared name on Qwen or Gemma) stays text (changelog, inference.md, the policy's doc). The "holds either way" sentence in inference.md is left as is: #2053 rewrites that sentence, and its fold resolution already carries this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0.10.13 fold resolution for #2052 (do not merge): #2052 faf818c + #2049 15f7d67, the earlier PR it conflicts with in the fold order (release-0.10.13/CONFLICTS.md). #2052's own branch stays independent. One textual conflict, MultiModelBatchSchedulerEngine.swift at the complete-call terminal: #2052 takes the calls and the residual from router.finishCompleteCalls(truncated:) (an auto GLM suffix that does not parse is split there); #2049 admits only the first call when parallel_tool_calls is false. Both kept: the calls finishCompleteCalls returns, including calls split out of a GLM suffix, go through ParallelToolCallPolicy.admitted, so a GLM response with two final calls and parallel_tool_calls: false keeps the first, as #2049 does for every family. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2051 is earlier than #2052 in the 0.10.13 fold order, and its head 37f0e62 conflicts with #2052 in LaunchAgent.swift (after the matrix's 05:56Z refresh, which had #2051 at fc06c86): both add a rollback key at the end of inferencePassthroughEnvKeys and its doc comment. Both kept, in fold order (#2051's DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY, then #2052's DARKBLOOM_GLM_TOOL_TEXT_FALLBACK); the tests only check membership. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…51, refactor pass) Behaviour unchanged: the same defaults, switch values, passthrough and assertions. From the independent review of 37f0e62 (APPROVE; should-fix 1-3, nit 5), applied by the AGENTS.md refactor pass: - The registry shadows the kill switch. While the coordinator's registry sets presence_penalty for the 9B, routed requests carry it, so DARKBLOOM_QWEN35_9B_PRESENCE_PENALTY=0 affects only local requests. A routed rollback also needs the registry value removed or set to 0. Said in configuration.md, the changelog and the key's doc comment. - The root cause is worded as the evidence allows: "constrained JSON rows" (a schema outside the subset is served prompt-only), and "the difference we can establish" (32.7 % vs 13.6 % with nothing else running), not "the penalty alone". - One number pair everywhere. "About three times" is 5.5 % vs 1.7 % of answers with max_tokens >= 8,192 over the same period (9B-MIDFAIL §4.5). "The same 10-minute windows" goes with the JSON workload's 51 % vs 23 % only (§4.1). inference.md had attached 6.1 % vs 1.5 % to the 10-minute windows. - Tests: - qwen35OmittedPresencePenaltyFollowsEachBuildsGate is renamed qwen35OmittedPresencePenaltyIsTheCardsOnEveryBuild, and its vestigial per-build penalty column is dropped (same assertions). - The launchd test now uses the file's unnamed @test style.
The independent review of faf818c (REQUEST CHANGES, glm-stray-evidence/review/REVIEW-2.md) as tests, before the fix: 1. Malformed JSON let the lexer resume reading frames, so a frame quoted in a JSON string the malformed value opened became a call (store(doc: {})): `]` or `<bad>` where a value belongs. Also a name followed by `<arg_value>`, `</arg_value>` or `</arg_key>` (not `<arg_key>`) was read as a mention, so a complete frame after it became a call. Expected: no call, all text, at `stop` and `length`, three chunk widths. 2. A think marker in an argument key was not checked: the released text handed it to the reasoning parser. Expected: the response keeps failing. Same after a frame whose JSON breaks the grammar (it owns the rest). 3. At `length` the router released the whole suffix after checking only the prefix of a split it then discarded: a marker inside the selected call was released. Expected: keeps failing. 4. An oversized suffix the SDK refuses while streaming was released through the visible-text path, before any EOS check: `auto` now fails again, as on dev, in pieces or in one delivery (the auto expectation of oversizedFrameFailsBeforeFallback goes back to dev's). 5. Many adjacent frames after a mention (40,000; the run was built by front insertion): a functional check, not a timing one, so not red. Plus a regression guard: a think marker inside the final call's own argument stays its data. Red on faf818c: 1 (stop), 2, 3, 4 and the oversized auto case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the independent review of faf818c (REQUEST CHANGES, REVIEW-2.md), finishing the author's last, uncompiled draft (05:56Z) and extending it: 1. BLOCKER: `GLM5ToolSuffix.Lexer` reads a frame's JSON values as the SDK does, structurally (strings, objects, arrays, literals, number bytes) instead of counting brackets, and never resumes reading frames inside arguments that break the grammar: such a frame, or one still open at the end, owns the rest of the response, so no frame after it is a call (all text). A name followed by `</arg_key>`, `<arg_value>` or `</arg_value>` is a malformed frame too, not a mention. A value whose declared type is a union of `string` with `object` or `array` (the template could have written it raw or as JSON, ending in different places) owns the rest as well; a declared type is taken from the key that matches byte for byte, as the SDK takes it. 2. The think-marker check covers whole frames (name, keys, values) and everything after a frame that owns the rest. 3. `split(_:tools:truncated:)` decides the release first: at the token limit the whole suffix is text and the check runs on all of it. 4. `checkNativeToolFailure` lets a GLM parse failure through only after `finishCompleteCalls` released the EOS suffix: a suffix the SDK refuses as oversized while streaming fails before it is released, as on dev. 5. The run that ends the response is collected by appending and reversing once (it was built by front insertion: quadratic in adjacent frames). 6. Docs and changelog: the cases that still fail (think marker inside a frame, oversized suffix), the grammar rule. The red tests of 531ddff pass with this; the rest of the suite is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
From #2049's owner (its delta review, N1): this resolution keeps #2049's sentence in |
The independent review of 3779320 (REQUEST CHANGES, glm-stray-evidence/review/REVIEW-3.md) as tests, before the fix: 1. A raw (string-typed) value holding the SDK's frame tags, which the SDK refuses, let the lexer borrow a nested frame's closing tags as its own: the second of two frames drafted inside it became a call. 2. A name followed by an unexpected tag (`<bad>`) was read as a mention even when argument tags followed it, so a frame inside its JSON argument became a call, and a think marker inside its value was released (stop and `length`). 3. A key that only canonically equals a declared one (the SDK refuses it) fell through to `additionalProperties`, read raw, and let the frame end inside an unclosed JSON string: the next frame became a call. Expected for 1-3: no call; all text, or the failure for a released think marker. Plus guards: a byte-exact declared key and an additional property still type the final call, and 5,000 additional keys against a 5,000-key schema (review finding 4: a full map scan per key) parse, functionally. Red on 3779320: 1-3 at `stop`, 2's think marker at `length` too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the independent review of 3779320 (REQUEST CHANGES, REVIEW-3.md): 1. A raw value is checked for the frame tags the SDK refuses there (`<tool_call>`, `</tool_call>`, `<arg_key>`, `</arg_key>`, `<arg_value>`): a value holding one makes its frame own the rest, instead of ending at a nested frame's `</arg_value>` and resuming after it. 2. A `<tool_call>` whose name is followed by anything but `</tool_call>` or `<arg_key>` is a mention only when no frame tag follows it before the next `<tool_call>`; otherwise it is a malformed frame that owns the rest (this replaces the three-tag special case of 3779320). Its think markers are then inside a frame, and released text holding them still fails. 3. A declared key's type is taken as the SDK takes it: a dictionary lookup, then the declared key's bytes; a key that only canonically equals a declared one owns the rest (the SDK refuses it) instead of falling through to `additionalProperties`. 4. That lookup is one hash lookup, not a scan of the declared properties per argument. Also: only a declaration the SDK accepts (one per name, an object schema without indirect types) and a key schema without indirect types type an argument; otherwise the value is read as JSON if it opens like JSON (never ending before its raw reading would), raw otherwise. Docs: the ownership triggers and the mention rule. The red tests of 46a47ef pass with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dedicated refactor-pass subagent (AGENTS.md) on c62caaf (glm-stray-evidence/refactor/ASSESSMENT-3.md): no code change warranted; one comment correction: `finishCompleteCalls` says that only a suffix that did not parse is all text at the token limit, and one that parses keeps its calls (as `truncatedOutputIsNotSplit` asserts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two fresh-context reviews of c62caaf (REVIEW-4.md and REVIEW-4b.md, both REQUEST CHANGES) as tests, before the fix: 1. A frame the SDK refuses kept a boundary a different reading would move: a raw guess for a schema the SDK refuses (an object property with `anyOf`, or an undeclared tool) ended the frame at an `</arg_value>` that a JSON string it opened may run past, and a JSON reading of an array-typed value that opens with a string ran past a raw string's end, swallowing the next frame's opening. The frames after it (data, in another reading) became calls, and a think marker after it was released. 2. A frame's tags in top-level text escaped the malformed-header check when a closed frame came between the header and its arguments: a frame inside that header's JSON argument became a call, and its think marker was released. Expected: no call, all text, or the failure for a released think marker, at `stop` and `length`. Plus a functional case for the review's long-name cost (the name was hashed once per argument): a 200,000-byte name with 5,000 arguments. The run helper takes a JSON array of tools too. Red on c62caaf: 1 and 2 at `stop`; the think-marker cases at `length` too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From two fresh-context reviews of c62caaf (REVIEW-4.md, REVIEW-4b.md): 1. BLOCKER (both): a frame the SDK refuses kept an end that another reading would move. `GLM5ToolSuffix.Lexer` now asks the SDK's parser about each closed frame as it records it: an accepted frame is the SDK's own reading and keeps its boundary; a refused frame keeps it only without a `"`, which could open a JSON string a raw reading ends inside (a raw guess for a schema the SDK refuses) or end a raw string a JSON reading runs past (swallowing the next frame's opening). Otherwise it owns the rest. The run reuses these verdicts instead of parsing its frames again. 2. A frame's tag (`</tool_call>`, `<arg_key>`, `</arg_key>`, `<arg_value>`, `</arg_value>`) in top-level text, outside every frame, owns the rest: the malformed-header check no longer stops at an interposed closed frame. 3. A frame's declaration is looked up once per frame, and only for a name the SDK accepts (1-64 ASCII letters, digits, `-`, `_`), not once per argument. Docs: the refused-frame and top-level-tag rules, that a thought spelling out the tags in order owns the rest (and fails as before when its `</think>` follows), and that the rule follows the `glm5` parser format. The red tests of e33365d pass with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fresh-context review of e0922a9 (REVIEW-5.md, REQUEST CHANGES, two SHOULD-FIX) as tests, before the fix: 1. A frame's tag in top-level text made the rest owned only from that tag: a malformed header read as a mention before an interposed closed frame kept its think marker outside, and released it (either direction, `</think>` or `<think>` after a real thought close). Expected: the response keeps failing, at `stop` and `length`. 2. Every closed frame was parsed by the SDK while lexing, even a quote-free one discarded before the end, and the SDK scans every declared tool per frame: 20,000 discarded frames against 500 tools, functionally (not a timing test, so not red). Red on e0922a9: 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A second fresh-context review of e0922a9 (REVIEW-5b.md, APPROVE WITH FIXES) as tests, before the fix: 1. A trailing run with a member the SDK refuses (an undeclared name, a missing required argument) ran the members after it: part of a batch the model emitted as one unit, against the SDK's own rule that a malformed member invalidates the batch. Expected: no call, all text. 2. The fallback was gated on `!requiresToolCall`, not on `auto`: with a prepared `none` (the Flint response format forces it while a client-selected GLM parser keeps its handler) the suffix was split and its failure answered, though no residual is published for `none`. Expected: the suffix still fails. (Its NITs 2 and 4 are REVIEW-5's two findings, in 43be515.) Red on e0922a9: 1 and 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From two fresh-context reviews of e0922a9 (REVIEW-5.md: two SHOULD-FIX; REVIEW-5b.md: APPROVE WITH FIXES): 1. A frame's tag in top-level text owns the rest from the first `<tool_call>` read as a mention before it (the malformed header it may belong to), not from the tag, so a think marker in that header's region is inside the owned text (REVIEW-5 #1, 5b NIT 2). 2. The SDK's parser is asked about a frame while lexing only when the frame holds a `"` (the boundary check needs it), and about the final run when it is chosen, instead of about every closed frame: quote-free frames discarded before the end cost no tool-table scan (REVIEW-5 #2, 5b NIT 4). A name the SDK would refuse before reading arguments (invalid, or not an accepted declaration) is refused without asking it. 3. The trailing run is taken whole or not at all, as the SDK takes a batch: a member it refuses (an undeclared name, a missing required argument) no longer lets the members after it run (5b #1). 4. The fallback is gated on `auto` (the prepared choice the scheduler passes the router), not on `!requiresToolCall`: under `none` no residual is published, so the suffix keeps failing (5b NIT 3). Docs and changelog: the whole-batch rule, the mention anchor. The red tests of 43be515 and bd0bdd2 pass with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Behaviour-preserving: - The dedicated refactor-pass subagent (AGENTS.md) on 9415d34 (glm-stray-evidence/refactor/ASSESSMENT-4.md): the trailing run is a range of frame indices (it is always a suffix of the frames) instead of a reversed array and a second lookup of its start. - REVIEW-6 NIT 1 / REVIEW-6b NIT 1: when the lexer asks the SDK's parser about a frame with a `"`, it passes that name's one accepted declaration instead of the whole tool list, which the SDK scans per frame; the SDK resolves the name the same way from either (the lexer keeps only names with exactly one accepted declaration, and refuses every name when an entry's `function` is not an object, as the SDK does). The final `parseEOS` still uses the whole list. Functional case: 12,000 such frames discarded before the end, against 500 tools. - REVIEW-6 NIT 2: the changelog says that output the parser cannot read safely (a thought spelling out the tags, a refused call with quotes before the final calls) recovers no call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second fresh-context review of 9415d34 (REVIEW-6b.md, APPROVE WITH FIXES, one SHOULD-FIX) as a test, before the fix: a frame's tag in top-level text after a closed frame (no mention before it) owned the rest only from the tag, but the closed frame's raw value may run on through it (the template writes strings raw and unescaped), so a think marker between the frame and the orphan tag was released (either direction). Expected: the response keeps failing, at `stop` and `length`. Red on afa6697. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the second fresh-context review of 9415d34 (REVIEW-6b.md, APPROVE WITH FIXES): a frame's tag in top-level text owns the rest from the first frame or mention before it, not only from a mention: a closed frame's raw value may run on, unescaped, through the orphan tags, so a think marker between them is inside the owned text and still fails. When such a tag is there no call is recovered anyway; only think markers move back to the 500 they were on dev. Not taken: REVIEW-6b NIT 2 (check a refused frame for `"` only after its name). A Hermes-style draft whose JSON "name" region opens a string could then end the frame early and let a frame inside that string run. The red test of f64d2fe passes with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2052 is frozen at 91ae652 for the 0.10.13 fold: its fixes for the independent reviews 2 to 6b, each test-first, and a final fresh-context review of that head (glm-stray-evidence/review/REVIEW-7.md, APPROVE WITH FIXES: the PR description only). Clean merge onto 0c37db5 (#2052 faf818c + #2049 15f7d67 + #2051 37f0e62): the resolutions of #2049 (MultiModelBatchSchedulerEngine.swift, the split calls go through ParallelToolCallPolicy.admitted) and #2051 (LaunchAgent.swift) stand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2051 moved from 37f0e62 to 98a9cde (wording and names after its review; EngineV2SamplingDefaults.swift, tests, docs). Clean merge; it does not touch LaunchAgent.swift, and the key both lists keep (qwen35NineBPenaltyEnvironmentKey) is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion Fold order: #204915f7d67 and #20531aacedf (#2059 = #2053 + #2049 + #2062). #2062 is already merged here, so this brings #2053 and #2049's current head. Clean merge: #2053's two launchd keys sit mid-list (TokenLimitCutPolicy, StrictToolCallPolicy), the GPT-OSS key stays last. Combined behaviour on the forced GPT-OSS path: the Harmony handler holds the call frame, so a cut at the limit flushes no text through the router's analysis gate; with #2053 a forced call cut at the limit ends as `length` (validateWithheld with cutAtLimit) instead of a 422, as for the other families. #2049's later-call filter is a no-op (<|call|> stops after one). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolution branch only. #2052 froze at 91ae652 (09:04Z); its resolution #2062 @ 0d2ec9e carries it with #2049 15f7d67 and #2051 98a9cde. Merging it keeps this branch its descendant, so the fold takes #2062 and then this branch. #2052 rewrote its lexer (GLM5ToolSuffix.Lexer: frames as ranges, `unclosed` for a frame that owns the rest, the SDK's grammar, split(truncated:)) and its router (glmSuffixSplit, autoToolChoice). This branch's cut handling moves onto it: - GLM5ToolSuffix: #2052's file, plus droppingCutFrames on the new lexer: from `unclosed` (a frame open at the end, or one that owns the rest), or from a header the end cut (new `cutHeader`: a `<tool_call>` the response ends in, in its name or a cut-off first tag, after the start of a declared name), or from the end, back over the closed frames separated only by whitespace. split() is #2052's, unchanged. - NativeToolStreamRouter.finishCompleteCalls(truncated:cutAtLimit:): #2052's split(truncated:) and glmSuffixSplit, then at a cut that ends as `length` the frames that end the output are dropped (glmFramesDroppedAtCut), and an ambiguous suffix is dropped instead of failing. hasNativeToolFailure follows #2052's glmSuffixSplit (a suffix the SDK refused while streaming still fails at a natural stop). - GLM5ToolFailureTests: #2052's file. Its cases keep #2052's contract, which is this branch's with DARKBLOOM_LENGTH_FINISH_AT_LIMIT=0: `run` turns the cut policy off unless asked. The cut's own cases turn it on: cutCases (mentions stay; a whole call, an open value, a cut name or tag, a nested or borrowed frame, all dropped), a cut suffix is not split, and #2052's own shapes that own the rest or hold a think marker in a frame are dropped at a cut, never released (ownedRestCases). - inference.md, configuration.md: #2052's text, with the cut's exceptions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…any declared name as a cut header, cut tests and docs (fold resolution) Resolution branch only. The independent review of the #2062 merge d075567 (APPROVE WITH NITS, review-2059-merge.md) found: - 2 and 7: at a cut, an ambiguous suffix was dropped whole even when the think marker sat only in the frames the cut drops anyway, and the lexer ran twice (split, then droppingCutFrames). GLM5ToolSuffix.textAtCut now does both in one pass and decides on exactly the text it releases: everything from the frames that end the output is dropped, and the rest is released unless it still holds a think marker from inside a frame (then the whole suffix is dropped, as before). finishCompleteCalls takes that arm at a cut; with the switch off it is #2052's code unchanged. - 3: a header the end cut matched only declarations the SDK accepts; it now matches any declared function name (Lexer.declaredNames), since the question is whether it is a header, not whether the SDK would take the call. Undeclared names stay mentions. - 4: cut cases that reach the stray-tag and refused-frame branches (and the walk-back's `<= start` guard): an orphan tag, one after a mention, the review's prose example, #2052's four refused-frame shapes; a think marker only in the dropped frames; an undeclared cut header; and aCutHeaderMatchesAnyDeclaredName. ownedRestCases[3] now releases the mention before a frame that holds the marker. - 1, 5, 6 (docs): inference.md says a frame's tag in top-level text takes the mentions before it, and that a suffix the SDK refuses as oversized still fails first; configuration.md's GLM row gives the cut's exceptions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion The 09:45Z fold list folds #2052 at its frozen resolution #2062 0d2ec9e and #2059's new head (pending; 42d9add now), which re-merges it. On that fold, this resolution's previous head conflicted in NativeToolStreamRouter.swift. 42d9add carries #2062 0d2ec9e. Two hunks, both kept, the earlier PR first: - stored properties: #2052's autoToolChoice and glmSuffixSplit, then #2045's harmonyAnalysis; - init: #2052's autoToolChoice assignment, then the Harmony gate. route(_:) is unchanged around the gate. #2052's new GLM suffix split applies to auto GLM output only; the gate to forced Harmony output only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Do not merge. CI check for the 0.10.13 fold: #2052's resolution branch (
fix/glm-stray-tool-call-text-fold013), perrelease-0.10.13/CONFLICTS.md. #2052's own branch stays independent.Head
0d2ec9ebfc(09:03Z) = #2052's frozen head91ae6525ecmerged with the earlier PRs in the fold order that it conflicts with:parallel_tool_calls: falsereturns the first call instead of failing mid-stream (0.10.13) #204915f7d676e9(parallel_tool_calls: falsekeeps the first call):MultiModelBatchSchedulerEngine.swiftat the complete-call terminal. The callsrouter.finishCompleteCallsreturns (including calls split out of an unparsed GLM suffix) go throughParallelToolCallPolicy.admitted, so a GLM response with two final calls andparallel_tool_calls: falsekeeps the first, as fix(provider):parallel_tool_calls: falsereturns the first call instead of failing mid-stream (0.10.13) #2049 does for every family.98a9cded8c(Qwen3.5-9B presence penalty):LaunchAgent.swift, both rollback keys kept in fold order.History (normal signed merges, no force):
113bbbe31f(#2049),0c37db51bc(#205137f0e6277a),1bc5c34220(#205291ae6525ec),0d2ec9ebfc(#205198a9cded8c).Simulated fold on
dev: #2047 → #2051 → #2050 → #2048 → #2049 → this head merges cleanly. #2059 (#2053's resolution) is built on this branch and re-merges this head; #2045 comes later in the order.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.