mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4663] Tool call for a tool not declared in the current tools list is returned as raw text (finish_reason=stop), breaking agent sessions #2120
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#2120
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 @gaotong1992 on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4663
Environment
0.1.48(/props→"build_info": "Strata 0.1.48")qwen3.8-flash-next-unsloth-ud-iq4_xs(GGUF, Q4_XS)/v1/chat/completions, streaming,tools+tool_choice: "auto"Summary
When the model emits a well-formed native Qwen tool call (
<tool_call><function=Name><parameter=...>) for a function name that is not present in the current request'stoolsarray, but that name appeared earlier in the conversation history, Strata returns the raw XML asmessage.contentwithfinish_reason: "stop"and notool_calls.Agent clients see a plain-text assistant message, cannot execute the tool, and the session stalls. This happens in long agent sessions because the active tool set changes over time (deferred tools loaded/unloaded, MCP tools, context compaction), so the model may call a tool it used earlier that is not declared in the current turn.
The 0.2.8 release note says the improved tolerance "only applies to tools the request declared", so this specific case is still uncovered.
Minimal reproduction
Actual output (3 runs each):
Raw leaked content in the failing case:
Expected behavior
Either of:
tool_callsregardless of whether the name is in the currenttoolsarray (let the client decide how to handle an unknown tool), orunknown tool) instead of silently moving the call intocontent.Returning raw XML as a normal
finish_reason: "stop"message is the problematic case: it is indistinguishable from the model replying in prose, so OpenAI-compatible agent clients stop.Additional evidence
toolsarray.TodoWritecalls, 4/4 calls with 20 long arguments (~2000 tokens), 3/3 calls truncated at</parameter>via a stop sequence — all returned propertool_calls.--tool-call-parser) and the official Qwen API does not lose these calls.Impact
Long-running coding-agent sessions (ZCode / Claude-Code-style harnesses with dynamic tool sets) stop with an apparent "model printed a todo list and froze" symptom. A proxy that re-injects previously-used tool names into
toolsworks around it, but the server-side behavior is the real issue.Suggested fix location
The native tool-call parser appears to validate the function name against the request's declared
toolsand falls back to content on mismatch. Relaxing that check (parse any matching<tool_call>block) or emitting an explicit error would fix the long-session failure mode.@github-actions[bot] commented on GitHub (Oct 30, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@rugabunda commented on GitHub (Oct 30, 2026):
Same issue here on totally fresh strata install, using opencode over strata api; forced to use another fork, and copy the self compiled engine from strata copy. Similar if not same issue: https://github.com/Niko1221/Strata/issues/4663
@Tsury commented on GitHub (Oct 30, 2026):
Reproduces on 0.2.8 (engine 0.1.54), on the Anthropic
/v1/messagesroute, with Claude Code's tool search.tool_call_recoveryat its default (on).-pwith tool search on. MCP tools are deferred, so the request'stoolsholdsToolSearchand the built-in tools, but not the MCP tools.ToolSearch, then the MCP tool, and answered correctly.stop_reason: end_turnand notool_use: Claude Code gets no tool call, so it cannot tell the model to load the tool first, and the session ends.With deferred tools, a call to a tool that exists but is not in
toolsis expected client behavior. Claude Code can recover from it if it receives the call as atool_use.@xrip commented on GitHub (Oct 30, 2026):
#4700 fixes the Claude Code case from Tsury's comment.
What happened: Claude Code stopped in the middle of a job, and its last message was raw
<tool_call>text. The model made a good tool call, but Strata sent it back as answer text, because the tool was not in the request'stoolslist. With tool search on (the default behindANTHROPIC_BASE_URL), Claude Code keeps MCP tools out of that list until the model loads them withToolSearch. When the model calls one straight away, Claude Code gets only text and stops.What I saw when I ran Claude Code 2.1.314 against a small fake API:
toolshas the built-in tools,ToolSearchand an emptyDeferredToolPlaceholdermarkeddefer_loading: true. MCP tools are only named in the chat.ToolSearch, the answer is atool_reference, and the tool is intoolsfrom then on.So #4700 follows Anthropic's rules on
/v1/messages. When the request has adefer_loadingtool, a call for a tool that is not in the list comes back as a tool call, so Claude Code runs it and goes on. The model also now sees whatToolSearchfound. Requests without tool search work as before.Not fixed: the first report here, Chat Completions with tools that change between turns. That route gives no sign that the client holds tools back, so those calls stay text.
@wangchll commented on GitHub (Oct 30, 2026):
Same failure here on a different client (DeepSeek Harness, over
/v1/chat/completions), and the host logs enough to split it into two defects. I think only the first one is the bug in this issue's title.Setup: App 0.2.8 (I first saw it on 0.2.7), engine 0.1.54, Windows 10 22H2 (19045), 2× Tesla V100-SXM2-16GB (sm_70, driver 582.78, one model layer-split across both cards), client
deepseek-harness/0.2.1-rc.3.The server knows it dropped the call, and it logs the name. 19 lines in
app-1.server.log:/metricsagrees:totals.tool_calls_unread: 7over 629 requests in the live 0.1.54 session.The names the model actually wrote (all 19 occurrences):
read_filereadexecpwshpswspspwshps+pwshmwmw93mnemon_runtime_memorymw93glued to the frontreportTwo groups:
read_file,exec,report— plausible names the model reaches for instead of the declaredread/pwsh/ (reporthas no obvious target). This is the path in this issue's title: DSH gets the XML back asmessage.contentwithfinish_reason: "stop"and notool_calls, the harness has nothing to dispatch, and the turn ends there. With DSH that is usually the end of the session.psws,pspwsh,mw,mw93mnemon_runtime_memory— corrupted names. They are not names from history or from training, and no request in any form could dispatch them. The rest of the turn arrives intact (the surroundingdone: 232 tokens (stop)line is normal), so this does not look like a parser problem: the name tokens themselves come out wrong. Whatever tolerance 0.2.8 added for undeclared names cannot help these — there is nothing to match them against.Group 2 is what made me look at the engine instead of the harness: from the client's side both groups look identical ("the model called a tool that does not exist"), and that reading is wrong for the second group.
0.2.8 does not fix it. All 7 occurrences in the live session are on App 0.2.8 / engine 0.1.54 (5×
read_file, 2×pspwsh), which matches @Tsury's Anthropic-endpoint report from the other side.Workaround I'm about to run (covers group 1 only): re-inject every tool name already used earlier in the conversation into the request's
toolsarray, so the model's habitualread_fileis at least declared and comes back as a realtool_callsentry. That does nothing for group 2 — a proxy could fuzzy-matchpspwsh→pwsh, but I would rather not put a spell-corrector in front of a model and hide the defect.Two other things from the same box, in case they share a root:
the reply reached max tokens while still thinking, so it has no answer— the turn returnsdone: 1 tokens (length)with an empty answer. A harness usually has no path for that either, so the session ends the same way it does above. Nearly all of mine come from a long session with a large thinking budget.Unrecoverable native verification failure: verify: timed out at layer 1; its GPU waits were released but the GPU did not finish within 5 s, right after decode fell 51.7 → 9.2 → 5.0 tok/s; and one silentengine stopped unexpectedly (exit code None)in the middle of reading a 40,927-token prompt. Possibly #4662, but I see it on 0.1.52 as well as 0.1.54.Housekeeping, since the thread is still moving: the bot asked for the
[Engine]prefix in the title and the hardware line in the body, and closes the issue after 5 days without them. Worth adding while people are still reading it.@Niko1221 commented on GitHub (Oct 31, 2026):
0.2.9 fixes part of this, on the OpenAI chat route (
/v1/chat/completions): a tool the conversation already called is accepted even when this request'stoolslist no longer names it, so the client gets a real tool call.Not covered yet: the Anthropic and Responses routes, and a tool the conversation never called, such as the Claude Code tool search case above. PR #4700 is about that case and we haven't taken it yet. Keeping this open for those. If you still see it on the OpenAI route on 0.2.9, please say which client and post the
strata_rejected_tool_callsfrom the response.@github-actions[bot] commented on GitHub (Nov 4, 2026):
Closing this issue because it still did not follow the format after 5 days. That is housekeeping, not a rejection.
To bring it back: fix the title (area prefix) and the missing parts, then comment
/reopen. A check runs and reopens it, or tells you what is still missing. See CONTRIBUTING.md.