[GH-ISSUE #1058] 0.1.40: a tool call quoted in the thinking is delivered as a real call (fires on a max_tokens cut and inside code fences) #452

Closed
opened 2026-11-04 01:43:10 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @47Hunter47 on GitHub (Oct 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1058

Summary. 0.1.40 (9fb1b9f) fixes #804 and on real traffic it recovers more than the opt-in PR did — on a second harness here it turned 11 of 12 recorded strandings into real calls, where 0.1.39 delivered none. But the rescue's only condition is "the called name is one the request declares", so it also acts on a call the model wrote inside its thinking as an example. On a reply that then runs into max_tokens, that means the client is handed a real tool call for something the model was only documenting — and on a client that auto-approves, it runs.

The example everyone writes quotes a destructive command, so this is worth a look before it spreads:

finish_reason: "length"      tools: [{"name": "fake_tool", ...}]
reasoning_content: "... include this example verbatim (it is only documentation, do not run it):
<tool_call>
<function=fake_tool>
<parameter=cmd>
rm -rf build
</parameter>
</function>
</tool_call>
... Then think about multiples ... 700=7*100, 693=7*99, ..."

tool_calls: [{"function": {"name": "fake_tool", "arguments": "{\"cmd\": \"rm -rf build\"}"}}]

That is a real response from a live 0.1.40 server, not a parser unit test.

Environment. 0.1.40, tag 1735d64, engine compiled locally on this machine (BUILD.json: source: local). Linux, 1× RTX 3090 24 GB, 61 GB RAM, driver 580.178.04. Qwen3.8-Flash-Next GSQ-RCO IQ3_XXS, --max-context 230000, --kv int8, images on (CPU encoder), thinking on, sampling temperature 1.0 / top_p 0.95 / top_k 20, reasoning_budget_tokens 16384. Requests over /v1/chat/completions, non-streaming and streaming (they agree). Nothing was executed: the client read the response fields only, and the tool named in the request exists nowhere.

Which conditions it fires under. Same dictated example, one variable changed per row, two attempts each:

variant declared tools name matches end of turn fired
V1 yes yes length (cut mid-thought) 2/2
V2 none – length / stop 0/2
V3 yes, but a different name no length 0/2
V4 yes yes long reply, natural end 1/2 (finish=tool_calls, and two calls in one reply)
V5 yes yes block inside a ```text fence 1/2 (finish=tool_calls)

So, in order: tools must be declared (V2 confirms the guard the maintainer described), the name must be one of them (V3 confirms the gate), and once those hold the rescue ignores where the call sits — not the start of a line, and not kept out by a code fence (V5) — and it does not care how the turn ended: a max_tokens cut (V1, the dangerous one) and a natural stop (V4) both fire.

Rate, to be fair about it: with the model asked to copy the exact block, ~50-100% of attempts fire; with a free-form prompt ("give an example of the call format, then keep thinking") it was 1 of 11 attempts — the model often writes the format loosely enough not to parse. It is stochastic, temperature 1.0.

The same result offline and deterministically. The corpus on PR #525 (serve/fixtures/format_fix_specimens.json at 4111c85, 25 entries with stated expectations) run against a 0.1.40 tree: the 5 "act" entries are correct, and 10 of the 20 negative controls now deliver a call — a fenced example, a mid-sentence quote, prose between two blocks (two calls), a call with no parameters, and cut-max-tokens, which is exactly the shape above. No model needed, just OutputParser:

import sys; sys.path.insert(0, "<0.1.40 tree>")
from serve.frontend import OutputParser
TOOLS = [{"name": "execute_code", "parameters": {"properties": {"code": {"type": "string"}}}}]
INPUT = open("cut-max-tokens.txt").read()   # "I could run\n<tool_call>\n<function=execute_code>…"
p = OutputParser(thinking=True, tools=TOOLS, stream_tools=True)
print([(e.kind, getattr(e.call, "name", None)) for e in p.feed(INPUT) + p.finish("length")])
# 0.1.40 -> [('tool_call', 'execute_code')]       0.1.39 -> only reasoning

Mechanism. In feed(), the reasoning branch enters a new rcall state on any <tool_call> once self.schemas is non-empty (tool = self.buf.find(CALL_START) if self.schemas else -1 — no line or fence context), holds the block whole, and then:

name = body[:end].strip()[len("<function="):].split(">", 1)[0]
if name in self.schemas:
    call = parse_tool_call(body[:end], self.schemas.get(name))
# a declared name -> tool_call; anything else -> reasoning

The declared-name condition is doing the work the content channel already does — that part is right, and it is why #970's two bogus <function=tool_call> deliveries in #804 do not happen here. What is missing is that the content channel distinguishes a call the model is making from text about the format by position and by where the turn ended, and this path does not.

Suggested gates, both cheap and both already in #525 (I am not arguing for the flag, only for the two conditions):

  1. The opener must start a line (or, at the minimum, be refused inside a fence). All 12 live strandings in the corpus from this machine begin with \n\n<tool_call>\n<function=NAME> — opener on its own line — and so do all four in #804, so this costs nothing in recall on the recorded data. It removes the fenced documentation case, the mid-sentence quote, and prose-between-blocks.
  2. Refuse when the turn ended by length. A budget cut is when a thinking span is most often open, and a complete call in that reasoning was written as an example far more often than as an act. This is the case with a destructive command in it.

One request: make it observable. rcall logs nothing and adds nothing to GET /metrics (totals still holds only the request/token/draft keys). So an operator cannot tell whether this class is firing on 1 reply in 100 or 1 in 100 000, and cannot tell when it acts on the wrong thing — the parse-level shape that #525 calls a hit is invisible here. A single counter (totals.tool_calls_from_reasoning or similar) would make the rate measurable per model and per quant, which is the question every harness will ask before turning this on.

Corpora, both public. PR #525's serve/fixtures/format_fix_specimens.json (25 entries, expectations included) is the deterministic half. Mine — 12 live strandings from this machine, genericised, in that same schema, 11/12 recovered by 0.1.40: https://gist.github.com/47Hunter47/4abcd3a80701f5634f85b96e4c067cc3 . Happy to re-run either against any head or to add the variants above as corpus entries.

Originally created by @47Hunter47 on GitHub (Oct 6, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1058 **Summary.** 0.1.40 (`9fb1b9f`) fixes #804 and on real traffic it recovers more than the opt-in PR did — on a second harness here it turned 11 of 12 recorded strandings into real calls, where 0.1.39 delivered none. But the rescue's only condition is "the called name is one the request declares", so it also acts on a call the model wrote inside its thinking **as an example**. On a reply that then runs into `max_tokens`, that means the client is handed a real tool call for something the model was only documenting — and on a client that auto-approves, it runs. The example everyone writes quotes a destructive command, so this is worth a look before it spreads: ```text finish_reason: "length" tools: [{"name": "fake_tool", ...}] reasoning_content: "... include this example verbatim (it is only documentation, do not run it): <tool_call> <function=fake_tool> <parameter=cmd> rm -rf build </parameter> </function> </tool_call> ... Then think about multiples ... 700=7*100, 693=7*99, ..." tool_calls: [{"function": {"name": "fake_tool", "arguments": "{\"cmd\": \"rm -rf build\"}"}}] ``` That is a real response from a live 0.1.40 server, not a parser unit test. **Environment.** 0.1.40, tag `1735d64`, engine compiled locally on this machine (`BUILD.json`: `source: local`). Linux, 1× RTX 3090 24 GB, 61 GB RAM, driver 580.178.04. Qwen3.8-Flash-Next GSQ-RCO **IQ3_XXS**, `--max-context 230000`, `--kv int8`, images on (CPU encoder), thinking on, sampling temperature 1.0 / top_p 0.95 / top_k 20, `reasoning_budget_tokens` 16384. Requests over `/v1/chat/completions`, non-streaming and streaming (they agree). Nothing was executed: the client read the response fields only, and the tool named in the request exists nowhere. **Which conditions it fires under.** Same dictated example, one variable changed per row, two attempts each: | variant | declared tools | name matches | end of turn | fired | |---|---|---|---|---| | V1 | yes | yes | `length` (cut mid-thought) | **2/2** | | V2 | **none** | – | `length` / `stop` | 0/2 | | V3 | yes, but a **different** name | no | `length` | 0/2 | | V4 | yes | yes | long reply, natural end | **1/2** (`finish=tool_calls`, and two calls in one reply) | | V5 | yes | yes | block inside a ```` ```text ```` fence | **1/2** (`finish=tool_calls`) | So, in order: tools must be declared (V2 confirms the guard the maintainer described), the name must be one of them (V3 confirms the gate), and once those hold the rescue ignores **where** the call sits — not the start of a line, and not kept out by a code fence (V5) — and it does not care **how the turn ended**: a `max_tokens` cut (V1, the dangerous one) and a natural stop (V4) both fire. Rate, to be fair about it: with the model asked to copy the exact block, ~50-100% of attempts fire; with a free-form prompt ("give an example of the call format, then keep thinking") it was **1 of 11 attempts** — the model often writes the format loosely enough not to parse. It is stochastic, temperature 1.0. **The same result offline and deterministically.** The corpus on PR #525 (`serve/fixtures/format_fix_specimens.json` at `4111c85`, 25 entries with stated expectations) run against a 0.1.40 tree: the 5 "act" entries are correct, and **10 of the 20 negative controls now deliver a call** — a fenced example, a mid-sentence quote, prose between two blocks (two calls), a call with no parameters, and `cut-max-tokens`, which is exactly the shape above. No model needed, just `OutputParser`: ```python import sys; sys.path.insert(0, "<0.1.40 tree>") from serve.frontend import OutputParser TOOLS = [{"name": "execute_code", "parameters": {"properties": {"code": {"type": "string"}}}}] INPUT = open("cut-max-tokens.txt").read() # "I could run\n<tool_call>\n<function=execute_code>…" p = OutputParser(thinking=True, tools=TOOLS, stream_tools=True) print([(e.kind, getattr(e.call, "name", None)) for e in p.feed(INPUT) + p.finish("length")]) # 0.1.40 -> [('tool_call', 'execute_code')] 0.1.39 -> only reasoning ``` **Mechanism.** In `feed()`, the reasoning branch enters a new `rcall` state on any `<tool_call>` once `self.schemas` is non-empty (`tool = self.buf.find(CALL_START) if self.schemas else -1` — no line or fence context), holds the block whole, and then: ```python name = body[:end].strip()[len("<function="):].split(">", 1)[0] if name in self.schemas: call = parse_tool_call(body[:end], self.schemas.get(name)) # a declared name -> tool_call; anything else -> reasoning ``` The declared-name condition is doing the work the content channel already does — that part is right, and it is why #970's two bogus `<function=tool_call>` deliveries in #804 do not happen here. What is missing is that the content channel distinguishes a call *the model is making* from text *about the format* by position and by where the turn ended, and this path does not. **Suggested gates, both cheap and both already in #525** (I am not arguing for the flag, only for the two conditions): 1. **The opener must start a line** (or, at the minimum, be refused inside a fence). All 12 live strandings in the corpus from this machine begin with `\n\n<tool_call>\n<function=NAME>` — opener on its own line — and so do all four in #804, so this costs nothing in recall on the recorded data. It removes the fenced documentation case, the mid-sentence quote, and prose-between-blocks. 2. **Refuse when the turn ended by `length`.** A budget cut is when a thinking span is most often open, and a complete call in that reasoning was written as an example far more often than as an act. This is the case with a destructive command in it. **One request: make it observable.** `rcall` logs nothing and adds nothing to `GET /metrics` (`totals` still holds only the request/token/draft keys). So an operator cannot tell whether this class is firing on 1 reply in 100 or 1 in 100 000, and cannot tell when it acts on the wrong thing — the parse-level shape that #525 calls a hit is invisible here. A single counter (`totals.tool_calls_from_reasoning` or similar) would make the rate measurable per model and per quant, which is the question every harness will ask before turning this on. **Corpora, both public.** PR #525's `serve/fixtures/format_fix_specimens.json` (25 entries, expectations included) is the deterministic half. Mine — 12 live strandings from this machine, genericised, in that same schema, 11/12 recovered by 0.1.40: https://gist.github.com/47Hunter47/4abcd3a80701f5634f85b96e4c067cc3 . Happy to re-run either against any head or to add the variants above as corpus entries.
Author
Owner

@47Hunter47 commented on GitHub (Oct 6, 2026):

We hit this class on a second harness and ended up carrying a local fix, so here is what we run, what it measures, and what it costs — posted as information for this decision, not as a request for anything.

The two conditions we added (nothing else changes; the rescue still fires only for a name the request declares):

  1. the opener must begin a line and sit outside a ```/~~~ fence of the reasoning;
  2. the block is held until the turn ends and delivered only on a natural stop — a length / cancel / disconnect end returns it as reasoning text.

Plus one rule borrowed from #525's contract: a </think> inside the reasoning clears the held block (a call inside a closed span was a mention, however well it parses).

Measured offline, both corpora, same machine:

stock 0.1.40 with the two conditions
#525's negative controls (format_fix_specimens.json, 20 of them) 10 fire 3 fire
#525's "act" entries (5) 5/5 correct 5/5 correct
our 12 live strandings 11/12 delivered 10/12
live cut-case probe (model asked to include the example, turn cut by max_tokens) 2/2 fired 0/2
feeding modes agree (whole / 1-char / random / stream_tools off) yes yes

Already-streamed text is byte-identical before and after; only the reasoning-block case moves, and it moves to end-of-turn.

What it costs, honestly. One live stranding — a client cancel whose reasoning ended on a genuine call — is no longer delivered; that is the gate doing its job. And it turns 6 tests red in serve/test_reasoning_tools.py, every one of them asserting the previous policy: test_a_declared_call_in_the_reasoning_is_a_call (a call opened mid-sentence, "before " + CALL, counted as a call), test_finish_reasons_and_block_order, and the RCALL_MAX test whose assertion assumes the reasoning is held rather than streamed.

That is exactly why we did not open a PR for it. Those tests are design statements — whether a <tool_call> woven into a sentence inside the thinking is an act is your call, not ours, and a patch that flips them red is not a patch we should land on someone else's behalf.

What it does not solve. A line-start block followed by more prose still fires (3 of #525's 20 controls). We kept that shape on purpose: it is the same shape as every real stranding we have — \n\n<tool_call>\n<function=NAME> closing the span — so position alone cannot tell a quote from an act there.

The change is a 155-line diff over serve/frontend.py and serve/server.py (the serve now passes its finish reason into finish()). Happy to paste it here, attach it, or turn it into a PR if you would rather have one.

Either way our earlier request stands: one counter in GET /metrics would let an operator see whether this class fires at all, and how often it acts on the wrong thing, before deciding anything about the gates.

<!-- gh-comment-id:6013233237 --> @47Hunter47 commented on GitHub (Oct 6, 2026): We hit this class on a second harness and ended up carrying a local fix, so here is what we run, what it measures, and what it costs — posted as information for this decision, not as a request for anything. **The two conditions we added** (nothing else changes; the rescue still fires only for a name the request declares): 1. the opener must begin a line and sit outside a ```/~~~ fence of the reasoning; 2. the block is held until the turn ends and delivered **only on a natural stop** — a `length` / `cancel` / `disconnect` end returns it as reasoning text. Plus one rule borrowed from #525's contract: a `</think>` inside the reasoning clears the held block (a call inside a *closed* span was a mention, however well it parses). **Measured offline, both corpora, same machine:** | | stock 0.1.40 | with the two conditions | |---|---|---| | #525's negative controls (`format_fix_specimens.json`, 20 of them) | 10 fire | **3 fire** | | #525's "act" entries (5) | 5/5 correct | 5/5 correct | | our 12 live strandings | 11/12 delivered | **10/12** | | live cut-case probe (model asked to include the example, turn cut by `max_tokens`) | 2/2 fired | **0/2** | | feeding modes agree (whole / 1-char / random / `stream_tools` off) | yes | yes | Already-streamed text is byte-identical before and after; only the reasoning-block case moves, and it moves to end-of-turn. **What it costs, honestly.** One live stranding — a client cancel whose reasoning ended on a genuine call — is no longer delivered; that is the gate doing its job. And it turns **6 tests red in `serve/test_reasoning_tools.py`**, every one of them asserting the previous policy: `test_a_declared_call_in_the_reasoning_is_a_call` (a call opened *mid-sentence*, `"before " + CALL`, counted as a call), `test_finish_reasons_and_block_order`, and the `RCALL_MAX` test whose assertion assumes the reasoning is *held* rather than streamed. That is exactly why we did not open a PR for it. Those tests are design statements — whether a `<tool_call>` woven into a sentence inside the thinking is an act is your call, not ours, and a patch that flips them red is not a patch we should land on someone else's behalf. **What it does not solve.** A line-start block followed by more prose still fires (3 of #525's 20 controls). We kept that shape on purpose: it is the same shape as every real stranding we have — `\n\n<tool_call>\n<function=NAME>` closing the span — so position alone cannot tell a quote from an act there. The change is a 155-line diff over `serve/frontend.py` and `serve/server.py` (the serve now passes its finish reason into `finish()`). Happy to paste it here, attach it, or turn it into a PR if you would rather have one. Either way our earlier request stands: one counter in `GET /metrics` would let an operator see whether this class fires at all, and how often it acts on the wrong thing, before deciding anything about the gates.
Author
Owner

@sergqwer commented on GitHub (Oct 6, 2026):

Thanks for the numbers. #1068 (opened 14 minutes before your comment) does the same two things you describe, plus a third condition that targets your remaining 3:

  1. the opener begins a line;
  2. after the block come only whitespace and further such blocks, until the turn ends;
  3. it is delivered only on a natural end (finish stop). length, cancel, disconnect and error return it as reasoning text.

Condition 2 separates the shape you kept on purpose (a line-start block followed by prose) from a stranding. A stranding closes the span, so nothing follows it. A quote is followed by something: prose, a closing fence, or </think> and an answer. Your </think> rule falls out of it, because </think> is not whitespace.

The same corpora, run through OutputParser whole, one character at a time and in random 1-9 character chunks (every mode agrees):

stock 0.1.40 #1068
#525's negative controls (20) 10 fire 0 fire
#525's acts (5) 5/5 5/5
your 12 live strandings, against their expectations 2 wrong (live-02, live-06) 12/12
live strandings delivered 11 9

The two it no longer delivers:

  • live-02: the cancelled one, refused as you say.
  • live-06: a declared todo_list block followed by an undeclared <function=tool_call> envelope block. The second block breaks condition 2, so both stay text, as your corpus expects. Stock delivered the first half.

What #1068 does not cover, and your fence rule does: an opener inside a ``` fence that the turn never closes, where the turn ends right after the block. A closing fence after the block already releases it. None of the live strandings sits in a fence, so adding your fence check would cost no recall on this data. I can add it to #1068 if the maintainer wants it.

Tests. #1068 rewrites serve/test_reasoning_tools.py to the new contract. test_a_declared_call_in_the_reasoning_is_a_call becomes a call that ends the turn (one, two adjacent, at the start of the reasoning). The mid-sentence call is the first of the quoted shapes that must stay text. The others:

  • more thought after the call;
  • prose after it;
  • a fenced block;
  • </think> after it;
  • a max_tokens cut;
  • prose between two calls;
  • a second call mid-line.

An HTTP test checks that max_tokens cutting the turn right after the call gives finish length and no call. It fails if finish() ignores how the turn ended. The RCALL_MAX test passes unchanged: the reasoning before an opener still streams, and only the block itself and the whitespace after it are held. The serve suite passes (423).

The counter: GET /metrics totals get reasoning_calls_delivered and reasoning_calls_kept_as_text (complete calls to a declared tool that stayed text).

<!-- gh-comment-id:6013361979 --> @sergqwer commented on GitHub (Oct 6, 2026): Thanks for the numbers. #1068 (opened 14 minutes before your comment) does the same two things you describe, plus a third condition that targets your remaining 3: 1. the opener begins a line; 2. after the block come only whitespace and further such blocks, until the turn ends; 3. it is delivered only on a natural end (finish `stop`). `length`, cancel, disconnect and error return it as reasoning text. **Condition 2** separates the shape you kept on purpose (a line-start block followed by prose) from a stranding. A stranding closes the span, so nothing follows it. A quote is followed by something: prose, a closing fence, or `</think>` and an answer. Your `</think>` rule falls out of it, because `</think>` is not whitespace. The same corpora, run through `OutputParser` whole, one character at a time and in random 1-9 character chunks (every mode agrees): | | stock 0.1.40 | #1068 | |---|---|---| | #525's negative controls (20) | 10 fire | **0 fire** | | #525's acts (5) | 5/5 | 5/5 | | your 12 live strandings, against their expectations | 2 wrong (`live-02`, `live-06`) | **12/12** | | live strandings delivered | 11 | 9 | The two it no longer delivers: - `live-02`: the cancelled one, refused as you say. - `live-06`: a declared `todo_list` block followed by an undeclared `<function=tool_call>` envelope block. The second block breaks condition 2, so both stay text, as your corpus expects. Stock delivered the first half. **What #1068 does not cover, and your fence rule does:** an opener inside a ``` fence that the turn never closes, where the turn ends right after the block. A closing fence after the block already releases it. None of the live strandings sits in a fence, so adding your fence check would cost no recall on this data. I can add it to #1068 if the maintainer wants it. **Tests.** #1068 rewrites `serve/test_reasoning_tools.py` to the new contract. `test_a_declared_call_in_the_reasoning_is_a_call` becomes a call that ends the turn (one, two adjacent, at the start of the reasoning). The mid-sentence call is the first of the quoted shapes that must stay text. The others: - more thought after the call; - prose after it; - a fenced block; - `</think>` after it; - a `max_tokens` cut; - prose between two calls; - a second call mid-line. An HTTP test checks that `max_tokens` cutting the turn right after the call gives finish `length` and no call. It fails if `finish()` ignores how the turn ended. The `RCALL_MAX` test passes unchanged: the reasoning before an opener still streams, and only the block itself and the whitespace after it are held. The serve suite passes (423). **The counter:** `GET /metrics` totals get `reasoning_calls_delivered` and `reasoning_calls_kept_as_text` (complete calls to a declared tool that stayed text).
Author
Owner

@47Hunter47 commented on GitHub (Oct 6, 2026):

Closing our side of this: #1068 is what we now run.

We applied it on this machine (cherry-pick of 72ff2d65 onto v0.1.40, so the tree is byte-identical to the PR head) and re-ran both corpora against it, then the live server:

  • #525's 25-entry corpus: the 5 "act" entries correct, 0 of 20 negative controls fire, and every feeding mode agrees (whole / 1-char / random 1-9 / stream_tools off).
  • our 12 live strandings: 12/12 match the corpus's expectations — stock 0.1.40 got 2 wrong — with 9 delivered. The three it does not deliver are the cancel, the mixed tail and the undeclared envelope, all by contract.
  • serve/ on the PR head: 415 passed, 8 skipped.
  • live smoke test: normal tool calls and streaming intact, and the quoted-call probe returns nothing in all three variants (name declared, no tools declared, a different name).
  • the new counters work: after a single probe, reasoning_calls_kept_as_text: 1 in GET /metrics — which is the part that lets anyone see whether this class fires at all before deciding anything.

Our own two-condition stopgap is dropped in its favour: it left 3 of #525's controls firing (a line-start block followed by prose), and #1068's second condition closes exactly those.

The only shape the three conditions do not cover, confirmed with a minimal pair on the PR: an opener inside a fence that never closes, with the turn ending right after the block. Nothing in our live data sits in a fence (all 12 are \n\n<tool_call>\n<function=NAME> with the span ending on the block), so that is a defensive gap rather than an observed one — noted on #1068, not a request here.

<!-- gh-comment-id:6013685979 --> @47Hunter47 commented on GitHub (Oct 6, 2026): Closing our side of this: **#1068 is what we now run.** We applied it on this machine (cherry-pick of `72ff2d65` onto v0.1.40, so the tree is byte-identical to the PR head) and re-ran both corpora against it, then the live server: - #525's 25-entry corpus: the 5 "act" entries correct, **0 of 20 negative controls fire**, and every feeding mode agrees (whole / 1-char / random 1-9 / `stream_tools` off). - our 12 live strandings: **12/12 match the corpus's expectations** — stock 0.1.40 got 2 wrong — with 9 delivered. The three it does not deliver are the cancel, the mixed tail and the undeclared envelope, all by contract. - `serve/` on the PR head: 415 passed, 8 skipped. - live smoke test: normal tool calls and streaming intact, and the quoted-call probe returns nothing in all three variants (name declared, no tools declared, a different name). - the new counters work: after a single probe, `reasoning_calls_kept_as_text: 1` in `GET /metrics` — which is the part that lets anyone see whether this class fires at all before deciding anything. Our own two-condition stopgap is dropped in its favour: it left 3 of #525's controls firing (a line-start block followed by prose), and #1068's second condition closes exactly those. The only shape the three conditions do not cover, confirmed with a minimal pair on the PR: an opener inside a fence that never closes, with the turn ending right after the block. Nothing in our live data sits in a fence (all 12 are `\n\n<tool_call>\n<function=NAME>` with the span ending on the block), so that is a defensive gap rather than an observed one — noted on #1068, not a request here.
Author
Owner

@Niko1221 commented on GitHub (Oct 6, 2026):

Fixed in 0.1.40.1, thank you for the corpus and the live runs. The rescue now needs a line-start opener outside code fences and inline code, a closed call with nothing but whitespace or more calls after it, and a normal end of the turn; a reply cut by max tokens keeps the call as reasoning text. Both gates you suggested are in, plus the counter (totals.tool_calls_from_reasoning) and a log line. A call quoted in a code fence or inline code in the visible answer (after ) is now text too, so an example in an answer never runs.

<!-- gh-comment-id:6013766315 --> @Niko1221 commented on GitHub (Oct 6, 2026): Fixed in 0.1.40.1, thank you for the corpus and the live runs. The rescue now needs a line-start opener outside code fences and inline code, a closed call with nothing but whitespace or more calls after it, and a normal end of the turn; a reply cut by max tokens keeps the call as reasoning text. Both gates you suggested are in, plus the counter (totals.tool_calls_from_reasoning) and a log line. A call quoted in a code fence or inline code in the visible answer (after </think>) is now text too, so an example in an answer never runs.
Author
Owner

@47Hunter47 commented on GitHub (Oct 6, 2026):

Verified on 0.1.40.1 (82f46a8c) before switching to it — offline first, then live:

  • your corpus: serve/fixtures/rcall_specimens.json, 37/37 entries match their expectations, the 16 that expect a call get it, and every feeding mode agrees (whole / 1-char / random 1-9).
  • our 12 live strandings — now folded into that file, thank you for that: 11/12 against the expectations our gist carried, and the single difference is one we would have written the other way ourselves. It is live-06, the mixed tail: this delivers the declared todo_list block where our older expectation (inherited from #525's all-or-nothing tail contract) said nothing. Your entry for the same shape expects the declared call, so per-block is the consistent reading — our expectation was the stale one, not your behaviour.
  • serve/ on this head: 444 passed, 8 skipped.
  • live on this machine: the quoted-call probes return nothing in all three variants (declared name, no tools declared, a different name); a turn cut by max_tokens with ~18k characters of thinking still returns no call; ordinary tool calls and streaming are untouched.
  • the counter is there (totals.tool_calls_from_reasoning, created on the first rescue — it reads 0 until one actually fires) and the cut case logs the max-tokens line.

One small operational note: finish() taking reason: str | None is friendlier than the boolean a half-way PR used, because a harness that drives the parser itself can still tell a cancel from a length cut.

We switched to 0.1.40.1 and dropped the two-condition patch we had been carrying. The fence/inline-code side is the part we could not have written as confidently — our own gate only handled fences, and none of our 12 live cases sat in one, so it had no evidence behind it. Good to have it in for real.

<!-- gh-comment-id:6014009524 --> @47Hunter47 commented on GitHub (Oct 6, 2026): Verified on 0.1.40.1 (`82f46a8c`) before switching to it — offline first, then live: - **your corpus**: `serve/fixtures/rcall_specimens.json`, **37/37 entries match their expectations**, the 16 that expect a call get it, and every feeding mode agrees (whole / 1-char / random 1-9). - our 12 live strandings — now folded into that file, thank you for that: **11/12** against the expectations our gist carried, and the single difference is one we would have written the other way ourselves. It is `live-06`, the mixed tail: this delivers the declared `todo_list` block where our older expectation (inherited from #525's all-or-nothing tail contract) said nothing. Your entry for the same shape expects the declared call, so per-block is the consistent reading — our expectation was the stale one, not your behaviour. - `serve/` on this head: **444 passed, 8 skipped**. - live on this machine: the quoted-call probes return nothing in all three variants (declared name, no tools declared, a different name); a turn cut by `max_tokens` with ~18k characters of thinking still returns no call; ordinary tool calls and streaming are untouched. - the counter is there (`totals.tool_calls_from_reasoning`, created on the first rescue — it reads 0 until one actually fires) and the cut case logs the max-tokens line. One small operational note: `finish()` taking `reason: str | None` is friendlier than the boolean a half-way PR used, because a harness that drives the parser itself can still tell a cancel from a length cut. We switched to 0.1.40.1 and dropped the two-condition patch we had been carrying. The fence/inline-code side is the part we could not have written as confidently — our own gate only handled fences, and none of our 12 live cases sat in one, so it had no evidence behind it. Good to have it in for real.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#452
No description provided.