mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4622] [Engine] Let the harness decide undeclared tool-call names: add a switch and a non-terminal refusal #2097
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#2097
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 @ackalker on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4622
Area
[Engine]
What do you want to do?
Two narrow things, both about the path where a well-formed call names a tool the request did not declare:
undeclared_tool_calls: "text" | "call"(config key, default"text"= today's behaviour). Harnesses that have their own unknown-name policy want the call back astool_calls, which is what happened before 0.2.2.docs/DETAILS.md:495-509statesfinish_reasonstaysstop(orend_turn) and the block is returned as the text the model wrote. An OpenAI-shaped client reads that as a finished answer and ends the turn: nothing runs, no error, no retry, and the user has to notice and re-prompt. We would ask that a refusal carry a signal the client's own loop already understands:finish_reason: "tool_calls"alongsidestrata_rejected_tool_calls, or an explicit error.We are not asking you to change the default, to weaken the alias policy, or to guess names — "
bashis notshell" and the reordered-name rule are both right, and the declared-only check itself is reasonable. The ask is only: let the operator choose, and don't make a refusal indistinguishable from a completed answer.Why the marker is not enough on its own:
strata_rejected_tool_callsis a good addition and we will read it, but a vendor-specific field is invisible to every client that does not already know it — and those clients do not error, they just stop.The problem we see (Pi, a sixth client)
Pi (earendil-works/pi) against
qwen3.8-flash-next-iq3_sthrough llama-swap, 16 declared tools, thinking on. The model intermittently writes the name wrong:<function=tools__web_search>,<function=tools=web_search>,<function=tools>with the real name in the first parameter slot,<function=tools.web_search>.web_searchis declared, and those same sessions call declared tools correctly 27-236 times each (web_searchitself 2-6 times), so this is intermittent, not a broken schema. Thetoolstoken is seeded by Pi's own tool descriptions, which end with a line of the form "Codemode:tools.<name>(args)resolves to ..." — we fixed that upstream (earendil-works/pi#11573, branchcodemode-script-name-annotation, commitf14912eb1), so the trigger is rarer on our side already.What the policy does to our loop, measured in our own session store:
tools__web_search,tools=web_search,tools,tools.web_search, and one<function=AskUserQuestion>— a name from another harness). In 5 of the 6 it is the first assistant reply of the session. The whole call block is message text,stopReasonisstop, nothing runs, and the session continues only because the user re-prompts (one typed "Please retry.", the others re-sent the same request).Tool "..." not foundtool-result error — which is exactly the recovery your docs recommend ("answer the model with the tool names it does have and ask again") — never fires, because the call never reaches the client.createPartialCompletion(packages/ai/src/utils/error-body.ts:130) copiescontent,tool_callsandfinish_reasononly, so an unknown top-level field is dropped on the floor. A marker-only design needs a code change in every client; afinish_reasonchange needs none.Offline, no GPU,
OutputParser(thinking=False, tools=<the 16 real schemas>)at v0.2.7.1: all four spellings above givecalls = 0,unread = 1,unread_names = ['tools=web_search'](etc.), andcontentbyte-identical to what the client displayed.tool_call_recovery: truedoes not change any of them. The aliases atserve/frontend.py:1006-1017only rewrite the part after a dot, sotools/tools__web_search/tools=web_searchare not covered and never will be — the model, not the spelling table, is the variable.Why a switch, and what precedent
llama.cpp screens by construction too and silently: its autoparser builds the
<function=NAME>alternatives from the declared tools only (common/chat-peg-parser.cpp:505-517,tool_choices |= rule("tool-" + name, ...)insidefor (const auto & tool_def : tools), whole sectionoptional(...)unlessforce_tool_calls). So we are not asking Strata to be unlike llama.cpp. vLLM is the precedent for the knob we want:validate_tool_names: bool = False("Reject tool calls whose names are absent from the request tools",vllm/parser/engine/parser_engine_config.py:138-139, enforced in_is_valid_tool_name,vllm/parser/engine/parser_engine.py:467-475) — same capability, opt-in, pass-through by default.Two things in your own tree that argue a knob is cheap:
strata_rejected_tool_callsis read by nobody, including Strata.git grepfinds it only inserve/server.py,test_server.pyand the docs; nothing inapps/host/server/agent/mentions it, so a Strata-driven agent hits the same silent stop.What do you do today instead?
We re-prompt by hand, and we carry a local 20-line patch that recovers a junk prefix before
=(<function=tools=web_search>). That covers one family only — it does nothing for<function=tools>or<function=tools__web_search>— so it is not a real workaround. Our other option is to stop declaring tools for Pi, which we do not want.Relation to existing threads
Same class as #3796 (we are the fifth/sixth client) and the same path introduced by
70f42407for #3075. Per CONTRIBUTING rule 3 we are raising the config/behaviour scope question here rather than reopening #3796, and we have left a pointer there with the new evidence. Pi's side of the fix is in earendil-works/pi#11573, which also asks Pi to readstrata_rejected_tool_calls; the ask here is that no client has to.@ackalker commented on GitHub (Oct 29, 2026):
Following up with the framing that made me file this, because it is a protocol-spec argument rather than a client-complaint list.
We modelled the loop as a state machine over the outcomes a reply can express, and asked: which transitions can end the turn without a reason? That turns up six gaps in one pass, and this issue is gap G1.
The rule that falls out is one line: absence is not an outcome. Today O2 is encoded as "no
tool_callsandfinish_reason: stop", i.e. as an absence. So anything upstream that adds or removes calls silently fabricates or destroys a terminal transition.Six gaps, each with a real instance, including three of your own closed issues:
finish_reasonstayedstop: O1 destroyed, indistinguishable from O2content: "": O1 invented, the client'selsebranch wrote an empty artifactreasoning_close_retryexists (docs/DETAILS.md:470){TC}returned asreasoning_content, finishstop: same gap, different channelif self.schemasgatethe engine stopped unexpectedly (exit code -15),Stream ended without finish_reasonThree invariants would close G1-G4 and G6:
finish_reason(or an explicit error), not silence next tostrata_rejected_tool_calls.G2 and G4 are already handled in your code, which is the useful part of this comparison: both are refusals that became expressible (the
if self.schemasgate, andreasoning_close_retryas an opt-in transition). G1 is the remaining case where a refusal is expressed only to a client that reads a vendor field, whilefinish_reasonclaims the turn ended normally.Worth noting the limit of this framing so nobody tries to check it and gives up: the protocol layer (O1-O6, G1-G6) is fully interlockable. The semantic layer is not — a harness can never verify "task complete", only read the model's claim, so progress checking there is heuristics. We are asking only about the interlockable half.
And a correction to my own report: our
tools/tools__web_searchspellings are partly our fault — Pi's tool descriptions seed thetools.token. That is fixed upstream (earendil-works/pi#11573). It reduces the trigger for one client; it does not touch the class, which is models namingbashforshell,apply_patchforexec_command, andskills_readbehind atool_callwrapper.@TacoTakumi commented on GitHub (Nov 2, 2026):
I hit this from a different kind of client, and it adds one point to the case for the switch in point 1.
The client is a voice game. The model is a Qwen3.8 Flash Next finetune (Swift 1.5 IQ4_XS) on Strata 0.2.7.1 through llama-swap, with streaming on. The reply text goes to TTS while it streams. In two turns in a row, the model wrote a well formed call with a name that the request did not declare:
The next turn used match_class_for_player. The declared tool is set_player_class. Strata returned both blocks as content, and the TTS read the XML aloud to the player.
For a streaming client, the marker and finish_reason both come too late. The block streams as content first. strata_rejected_tool_calls and finish_reason come only in the last chunk, after the text is already spoken. To act on the marker, the client must hold back all text until the stream ends, and then there is no reason to stream. A finish_reason change alone has the same problem.
These names are also not near misses. No alias rule can map let PlayerClass (a hallucination) to set_player_class, and it should not try. The switch is the fix we need. Our loop already answers an unknown name with a tool error, so the model can try again.
Until there is a switch, I'll detect a tool call block at the start of the streamed text, keep it from TTS, and send the model an error.
@marksmeltzer commented on GitHub (Nov 3, 2026):
Field data from a rig where the miss fires on ordinary harness traffic, in case the frequency question is what is holding the switch back.
We run Strata as the model behind GitHub Copilot in VS Code and the GitHub Copilot CLI, all day, on:
qwen3.8-flash-next-unsloth-ud-q4_k_xlat 262144 contextWhat we counted
The six counted here were returned to us as calls, because we run
undeclared_tool_calls: "call". The count is mode-dependent:serve/frontend.py_call_eventincrementsundeclared_passedonly whenundeclared_callsis on, andserve/server.pyadds that tototals.tool_calls_undeclared. On the default setting those same six would have come back as text with nothing in the response to distinguish them from a finished answer. A second snapshot of the same process later the same evening read 2,390 requests and still 6, so it isn't one bad conversation.For scale, that 18 h 52 m window carried 281 M prompt tokens, 276 M of them reused: warm, long-context, tools-declared traffic.
Why that argues for the switch
0.26 % is rare enough that nobody finds it from symptoms and frequent enough that a harness used every day meets it within a day. What makes it need a switch rather than a workaround is that the text path gives the client no signal: the turn ends, nothing runs, and a user who hits this four times in a week gets four normal-looking finished answers and no way to connect them. Whatever the percentage, the operator has no way to know it is happening without a server-side counter, which is why the metrics half of this paired pull request matters even if the default stays
"text".What this does not measure
totals.tool_calls_undeclaredcounts calls, not names, and records no outcome. We are not claiming the six turns would otherwise have been lost; we don't know what each client did."text". We have not run the default path alongside this one, so the comparison between the two settings is read off the code, not measured.@marksmeltzer commented on GitHub (Nov 3, 2026):
Addendum to our earlier measurement: a call the model wrote correctly enough to mean, with a tag it never closed,
is invisible to both counters. Found in daily use 2026-11-03.
What we saw
One agent session, this server (2x RTX 5090, driver 617.42,
qwen3.8-flash-next-unsloth-ud-q4_k_xl, context262144), running our opt-in
"undeclared_tool_calls": "call". The model emitted a tool call whose tool namearrived complete but whose function tag was never closed: a stray closing parameter tag stood where the tag's
>belonged. The reply went back as ordinary text. The harness reported a malformed tool call and ended the turn. The
model was never told which part was wrong, and by then the tool's name existed only as prose in its own transcript,
so there was nothing to correct and no retry to make.
We are deliberately not pasting the markup. In a harness that reads a reply's text for calls, the damaged sequence
is itself a tool-call attempt - that is exactly how the session that found it lost its turn. Describe, don't quote.
Why our 0.26 % is a floor, and this is the reason
Both counters read zero on that request, for two unrelated reasons:
tool_calls_unreadis incremented in the branch that keeps the block as text. A server running"call"does nottake that branch, so it cannot count this.
tool_calls_undeclaredcounts calls the parser recognised as calls. Recognition needs the name and the tag'sclosing bracket. With the bracket missing, the block is never a call and never a rejected call: it is content.
A rate built from either counter therefore measures only the calls that were legible. Every number of this kind,
ours included, is a lower bound, and the true share of requests where the model writes a call the pipeline cannot
read is "that rate, plus whatever the invisible class contributes". We have given the class a counter now, but it
starts at zero, so we cannot say how large it is. One observed instance in continuous daily-driver use is all we have.
Why the two
v0.2.10additions we reviewed do not rescue this casetools.,functions.anddefault_api.as aliases of a declared name. In our instance the namehas a word inserted inside it, not a harness prefix in front of a real name, so no alias resolves it.
request shape; and in any case the block never becomes a call, because the blocker is the opener, not the name.
It is also a third failure mode beside #3441's drifted opener: there the word is spelled wrong and the tag closes,
and the rewrite in
v0.2.10handles it. Here the word is right and the tag never closes, so nothing rewrites it.What we did, on our side of the same failure
With
"undeclared_tool_calls": "call"set, the parser detects the shape and completes the opener - the same move#3441 makes for a drifted opener - and lets the existing call path recover the arguments. The client receives a
call carrying the name the model actually wrote and rejects it with its own "no such tool" error. That error is
the correction signal the model can act on, so the turn continues instead of ending. Three guards keep it narrow:
>begins call markup (a closing tag, a brace, or aparameter), so a sentence that merely names a function stays text;
only a reply that arrived all at once, while token-by-token delivery skipped it entirely - worth stating because
it is the bug a fix like this most easily hides.
With the switch off the reply is byte-identical to today's, which is our usual condition for touching the default
path at all.
Why the server does not simply answer the model itself
Auto-responding is what we would have preferred: recognise the damage, tell the model its call was malformed, skip
the client. It is not reliably possible for the traffic that matters. In a chat-completions or messages response
the server produces one HTTP reply, and a tool-result message is only meaningful as an answer to a
tool_callsarray whose ids the client minted and holds in its own conversation state. A server answering on the client's
behalf would have to invent the client's assistant turn and hope it got replayed. Strata does have a loop that
feeds tool results back to the model - it exists for the server's own MCP hub, gated on
mcp_serverson therequest or
--mcp-configon the command line. Requests from an agent harness set neither. So we route, and letthe harness produce the error. If upstream would rather normalise the opener into a call for an unknown name
unconditionally rather than behind a switch, the seam we wrote it at is small enough to move.
We gave the class a number
A failure mode with no counter cannot be reasoned about, only argued about. Added:
totals.tool_calls_malformed_openin
/metrics, and aMALFORMED TOOL CALL request ...line in the server log beside the undeclared one. It countsrepaired-and-returned calls, so - same caveat as the other two - it never moves on a server left on the default,
and a zero from a default server is not evidence that the shape does not occur.
How it was checked, and what was not
seven-character chunk widths, asserting the name and arguments survive, that nothing reaches the transcript as
text, and that the counters agree. Plus: switch off unchanged; a declared name behind the damage still executes;
a well-formed call unaffected; prose unaffected with the switch both on and off; a name still arriving held, not
named.
serve/test_undeclared_tool_calls.py, 19 tests.servesuite: 1404 tests, OK, 30 skipped, 533 s, 2026-11-03 on 2x RTX 5090 (driver 617.42),Ryzen 9 5950X, 128 GiB, Windows 11 build 26200.
0.1.56. This machine was serving the veryconversation in which the change was written, so the engine is still
0.1.54while we write this - we have notseen a repaired call in production, only in tests. The observation is one instance on one rig with one model, not
a rate, and we did not measure how often the shape occurs on any other model, quant, hardware, or server default
than ours.
@macmmm81 commented on GitHub (Nov 3, 2026):
I can confirm experiencing this issue with Qwen 3.8 Flash-Next (ISTA IQ3_S) running through Strata 0.2.10 (build 0.1.56; python 3.12.15 ) + DeepSeek Harness (DSH) in Programmatic Tool Calling (PTC) mode.
Environment:
run_code)Observed behavior:
In PTC mode, DSH exposes
run_codeas the callable tool, with other tools accessible through the generated TypeScript SDK.However, Qwen intermittently attempts to invoke those underlying tools directly, producing output such as:
Instead of invoking
run_codewith the appropriate SDK call:The incorrect invocation appears as raw XML in the conversation rather than being handled as a structured tool call that DSH can reject and provide feedback on.
Interestingly, manually correcting the model works temporarily. After explicitly explaining the PTC calling convention, Qwen resumes using
run_codecorrectly and can continue executing tools autonomously.However, after further execution, it eventually reverts to direct XML-style tool calls, causing the same failure again.
This suggests two separate problems:
I understand the reasoning behind restricting structured tool calls to explicitly declared tools, but an opt-in mechanism such as the proposed
undeclared_tool_calls: "call"option would be extremely useful for agent frameworks that already implement their own tool validation.It would allow DSH to reject invalid calls and return actionable feedback to the model, rather than leaving raw XML in the conversation and potentially terminating an otherwise productive autonomous session.
I support making this behavior configurable while retaining the current strict behavior as the default.
Happy to provide additional logs or test a proposed fix if useful.
@marksmeltzer commented on GitHub (Nov 3, 2026):
That’s exactly right.
However, have you tried adding some global instructions that are always resident and survive compaction about the DSH calling convention? Whenever it messes up, you can ask your agent to do an RCA and improve those global instructions.
Even with error handling, this will still improve your workflow to get the agent issuing the calls correctly more often.
Regards,
From: macmmm81 @.>
Sent: Tuesday, 03 November 2026 14:36:48
To: Niko1221/Strata @.>
Cc: Mark Smeltzer (Living Agile) @.>; Comment @.>
Subject: Re: [Niko1221/Strata] [Engine] Let the harness decide undeclared tool-call names: add a switch and a non-terminal refusal (Issue #4622)
[https://avatars.githubusercontent.com/u/39221755?s=20&v=4]macmmm81 left a comment (Niko1221/Strata#4622)https://github.com/Niko1221/Strata/issues/4622#issuecomment-6617241597
I can confirm experiencing this issue with Qwen 3.8 Flash-Next (ISTA IQ3_S) running through Strata 0.2.10 (build 0.1.56; python 3.12.15 ) + DeepSeek Harness (DSH) in Programmatic Tool Calling (PTC) mode.
Environment:
Observed behavior:
In PTC mode, DSH exposes run_code as the callable tool, with other tools accessible through the generated TypeScript SDK.
However, Qwen intermittently attempts to invoke those underlying tools directly, producing output such as:
<tool_call>
<function=read>
<parameter=file_path>decomp/ASSESSMENT.md
</tool_call>
Instead of invoking run_code with the appropriate SDK call:
const result = await tools.read({
file_path: "decomp/ASSESSMENT.md"
});
console.log(result);
The incorrect invocation appears as raw XML in the conversation rather than being handled as a structured tool call that DSH can reject and provide feedback on.
Interestingly, manually correcting the model works temporarily. After explicitly explaining the PTC calling convention, Qwen resumes using run_code correctly and can continue executing tools autonomously.
However, after further execution, it eventually reverts to direct XML-style tool calls, causing the same failure again.
This suggests two separate problems:
I understand the reasoning behind restricting structured tool calls to explicitly declared tools, but an opt-in mechanism such as the proposed undeclared_tool_calls: "call" option would be extremely useful for agent frameworks that already implement their own tool validation.
It would allow DSH to reject invalid calls and return actionable feedback to the model, rather than leaving raw XML in the conversation and potentially terminating an otherwise productive autonomous session.
I support making this behavior configurable while retaining the current strict behavior as the default.
Happy to provide additional logs or test a proposed fix if useful.
—
Reply to this email directly, view it on GitHubhttps://github.com/Niko1221/Strata/issues/4622?email_source=notifications&email_token=AESFMY2F5YUF5Y6VLI4OTGL5XJMYBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMNRRG4ZDIMJVHE32M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6617241597, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AESFMYYU3X3PCKBUZSXTFRT5XJMYBAVCNFSNUABGKJSXA33TNF2G64TZHMYTGOBVHE2DMMZQGE5US43TOVSTWNRRGAZTCOBZG4ZDFILWAI.
You are receiving this because you commented.Message ID: @.***>
@marksmeltzer commented on GitHub (Nov 3, 2026):
I have a convention where my agents keep track of their bad tool calls and then do periodic RCAs to improve the system instructions over time. Self healing is the goal.
Regards,
From: Mark Smeltzer (Living Agile) @.>
Sent: Tuesday, 03 November 2026 15:20:19
To: Niko1221/Strata @.>; Niko1221/Strata @.>
Cc: Comment @.>
Subject: Re: [Niko1221/Strata] [Engine] Let the harness decide undeclared tool-call names: add a switch and a non-terminal refusal (Issue #4622)
That’s exactly right.
However, have you tried adding some global instructions that are always resident and survive compaction about the DSH calling convention? Whenever it messes up, you can ask your agent to do an RCA and improve those global instructions.
Even with error handling, this will still improve your workflow to get the agent issuing the calls correctly more often.
Regards,
From: macmmm81 @.>
Sent: Tuesday, 03 November 2026 14:36:48
To: Niko1221/Strata @.>
Cc: Mark Smeltzer (Living Agile) @.>; Comment @.>
Subject: Re: [Niko1221/Strata] [Engine] Let the harness decide undeclared tool-call names: add a switch and a non-terminal refusal (Issue #4622)
[https://avatars.githubusercontent.com/u/39221755?s=20&v=4]macmmm81 left a comment (Niko1221/Strata#4622)https://github.com/Niko1221/Strata/issues/4622#issuecomment-6617241597
I can confirm experiencing this issue with Qwen 3.8 Flash-Next (ISTA IQ3_S) running through Strata 0.2.10 (build 0.1.56; python 3.12.15 ) + DeepSeek Harness (DSH) in Programmatic Tool Calling (PTC) mode.
Environment:
Observed behavior:
In PTC mode, DSH exposes run_code as the callable tool, with other tools accessible through the generated TypeScript SDK.
However, Qwen intermittently attempts to invoke those underlying tools directly, producing output such as:
<tool_call>
<function=read>
<parameter=file_path>decomp/ASSESSMENT.md
</tool_call>
Instead of invoking run_code with the appropriate SDK call:
const result = await tools.read({
file_path: "decomp/ASSESSMENT.md"
});
console.log(result);
The incorrect invocation appears as raw XML in the conversation rather than being handled as a structured tool call that DSH can reject and provide feedback on.
Interestingly, manually correcting the model works temporarily. After explicitly explaining the PTC calling convention, Qwen resumes using run_code correctly and can continue executing tools autonomously.
However, after further execution, it eventually reverts to direct XML-style tool calls, causing the same failure again.
This suggests two separate problems:
I understand the reasoning behind restricting structured tool calls to explicitly declared tools, but an opt-in mechanism such as the proposed undeclared_tool_calls: "call" option would be extremely useful for agent frameworks that already implement their own tool validation.
It would allow DSH to reject invalid calls and return actionable feedback to the model, rather than leaving raw XML in the conversation and potentially terminating an otherwise productive autonomous session.
I support making this behavior configurable while retaining the current strict behavior as the default.
Happy to provide additional logs or test a proposed fix if useful.
—
Reply to this email directly, view it on GitHubhttps://github.com/Niko1221/Strata/issues/4622?email_source=notifications&email_token=AESFMY2F5YUF5Y6VLI4OTGL5XJMYBA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMNRRG4ZDIMJVHE32M4TFMFZW63VHMNXW23LFNZ2KKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6617241597, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AESFMYYU3X3PCKBUZSXTFRT5XJMYBAVCNFSNUABGKJSXA33TNF2G64TZHMYTGOBVHE2DMMZQGE5US43TOVSTWNRRGAZTCOBZG4ZDFILWAI.
You are receiving this because you commented.Message ID: @.***>
@Niko1221 commented on GitHub (Nov 7, 2026):
Part 1 is in v0.2.12: the config key
undeclared_tool_calls("text"by default, which is today's behaviour;"call"returns a well-formed call of an undeclared tool astool_calls), also asSTRATA_UNDECLARED_TOOL_CALLS=call, documented in docs/DETAILS.md (75acfca32).Part 2 (a non-terminal signal on the default path) is not in this release, so this issue stays open for it.
Released in Strata v0.2.12: https://github.com/Niko1221/Strata/releases/tag/v0.2.12