mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2037] serve: tool_call_recovery misses fenced JSON inside an explicit tool-call wrapper #811
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#811
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bettercallcaleb on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2037
Summary
With
tool_call_recoveryenabled, Strata recovers JSON for a declared tool inside an explicit<tool_call>wrapper, but fails to recognize the same JSON if the model wraps it in a Markdown ```json fence. The response is emitted as regular content, with notool_call.This is a code-fence handling issue, not a JSON-string escaping issue: literal backticks inside a JSON string work in the unfenced case.
Reproduction (parser-only; no model required)
Actual
The fenced case instead emits the wrapper and fenced JSON as
content, without an error. Reproduced against the currentserve/frontend.pyonmainwith whole-input, 1-character, and 7-character chunks, bothstream_tools=FalseandTrue.Expected
When recovery is explicitly enabled, an otherwise valid JSON call for a declared tool inside an explicit
<tool_call>wrapper should either be recovered despite an optional Markdown JSON fence, or produce a clear diagnostic. It should not silently become a normal assistant reply.Fenced JSON in ordinary prose/reasoning must remain text, not execute as a tool call. Any recovery should be narrowly scoped to the explicit wrapper and a declared tool.
Where
serve/frontend.py:OutputParser._follower()recognizes JSON only when the text following<tool_call>begins with{.@Niko1221 commented on GitHub (Oct 12, 2026):
Confirmed, and your reproduction was exact. With recovery on,
<tool_call>followed by a Markdown fence (json or a bare) was read as prose, so the call came out as content. Fixed: inside an explicit<tool_call>wrapper, a fence that opens with an optionaljsonand holds a declared tool's{"name": ..., "arguments": ...}is now the call, whole input or streamed in 1- or 7-character chunks, withstream_toolson or off. Narrow on purpose: it needs the wrapper,tool_call_recoveryon and a declared tool; a fence in prose or reasoning, another language's fence (```python), and an undeclared tool name all stay text, and the #1058 quote and fence safeguards are untouched. Tests cover each of those. Closing when the fix ships in 0.1.43.1 (out now).