[PR #4710] [Engine] serve: opt-in "undeclared_tool_calls": "call" returns a call for an undeclared name as a call (#4622) #5144

Open
opened 2026-11-07 16:33:02 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4710
Author: @AntonioNoOne
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: f-4622-undeclared-tool-calls


📝 Commits (1)

  • e5444d1 serve: opt-in "undeclared_tool_calls": "call" returns a call for an undeclared name as a call (#4622)

📊 Changes

4 files changed (+55 additions, -4 deletions)

View changed files

📝 docs/DETAILS.md (+2 -1)
📝 serve/frontend.py (+10 -2)
📝 serve/server.py (+6 -1)
📝 serve/test_server.py (+37 -0)

📄 Description

Closes the first ask of #4622 (a documented switch for undeclared tool-call names). The second ask (a non-terminal refusal on the default path) is not in this PR.

Problem

Since 0.2.2 (#3075), with tools declared, a well-formed <function=NAME> for a name the request did not declare comes back as text with finish_reason: "stop". An OpenAI-shaped harness reads that as a finished answer and ends the turn: nothing runs, no error, no retry. The strata_rejected_tool_calls marker (#3796) helps clients that know it, but a generic client does not.

Observed with pi in codemode (codemode.mode: "only"), which declares one tool, codemode, and lists the other tools inside its description as tools.bash(...) etc. On 0.2.7.1 / engine 0.1.52, Qwen3.8-Flash-Next IQ3_S (SC117), the model calls the member directly as <function=tools__bash>. One captured pi request, replayed 3 times, gave tools__bash as text 3/3 and pi ended each run after one turn without running anything.

Change

A new config key, "undeclared_tool_calls": "text" (default, today's behaviour) or "call". With "call" and tools declared, a well-formed call for an undeclared name is returned as a call (tool_calls, finish_reason: "tool_calls"), as before 0.2.2, so the harness can answer with its own unknown-tool error and the model can retry. Only the template's own <function=NAME> form is affected: a drifted opener (#3441) still needs a declared name, and a request that declared no tools is not changed (declared_only still applies). Any other value refuses to start the server, like tool_call_recovery.

The change is one condition in the parser's well-formed-call branch, the Service attribute, the config read in main, and one row in docs/DETAILS.md plus a pointer in the #3796 paragraph.

Validation

Revision: this branch on main; a first version (same well-formed path, without the drifted-opener and no-tools guards) also ran on v0.2.7.1. Windows 11, 2x RTX 3090 24 GB (GPUs 1+2), Qwen3.8-Flash-Next-GSQ-RCO-abliterated IQ3_S, engine 0.1.52.

Passed:

  • python -m unittest serve.test_server.UndeclaredToolCallSwitch (new): "text" keeps the block as text and names it in rejected_tool_calls; "call" returns ("tools__bash", {"command": "ls"}) and no text; "call" with no tools declared keeps the text. Each fails without the corresponding part of the frontend.py change.
  • python -m unittest serve.test_server serve.test_frontend serve.test_reasoning_tools serve.test_reasoning_rescue serve.test_parser_call_scan: 431 tests OK (3 skipped) on main; 428 OK on v0.2.7.1 (before the no-tools test was added).
  • Hardware, on v0.2.7.1 + the first version of this commit (same well-formed path), "undeclared_tool_calls": "call": the same captured pi request replayed 3 times returned tool_calls: [tools__bash {"command":"ls -la /lavoro/file"}], finish_reason: "tool_calls", 3/3 (before: text, 3/3).
  • pi end to end on the same server: the model called tools__bash, pi answered Tool tools__bash not found, the next turn called codemode with await tools.bash(...) and finished the task.

Not run: GPU builds (no C++/CUDA/HIP/SYCL file is touched), the Metal/Mac path, /v1/messages and Responses routes on hardware (the parser path is shared; the unit tests cover Chat Completions).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4710 **Author:** [@AntonioNoOne](https://github.com/AntonioNoOne) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `f-4622-undeclared-tool-calls` --- ### 📝 Commits (1) - [`e5444d1`](https://github.com/Niko1221/Strata/commit/e5444d1ea3efc81767dde22b7319274ca2955cbe) serve: opt-in "undeclared_tool_calls": "call" returns a call for an undeclared name as a call (#4622) ### 📊 Changes **4 files changed** (+55 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+2 -1) 📝 `serve/frontend.py` (+10 -2) 📝 `serve/server.py` (+6 -1) 📝 `serve/test_server.py` (+37 -0) </details> ### 📄 Description Closes the first ask of #4622 (a documented switch for undeclared tool-call names). The second ask (a non-terminal refusal on the default path) is not in this PR. ## Problem Since 0.2.2 (#3075), with tools declared, a well-formed `<function=NAME>` for a name the request did not declare comes back as text with `finish_reason: "stop"`. An OpenAI-shaped harness reads that as a finished answer and ends the turn: nothing runs, no error, no retry. The `strata_rejected_tool_calls` marker (#3796) helps clients that know it, but a generic client does not. Observed with [pi](https://github.com/earendil-works/pi) in `codemode` (`codemode.mode: "only"`), which declares one tool, `codemode`, and lists the other tools inside its description as `tools.bash(...)` etc. On 0.2.7.1 / engine 0.1.52, Qwen3.8-Flash-Next IQ3_S (SC117), the model calls the member directly as `<function=tools__bash>`. One captured pi request, replayed 3 times, gave `tools__bash` as text 3/3 and pi ended each run after one turn without running anything. ## Change A new config key, `"undeclared_tool_calls"`: `"text"` (default, today's behaviour) or `"call"`. With `"call"` and tools declared, a well-formed call for an undeclared name is returned as a call (`tool_calls`, `finish_reason: "tool_calls"`), as before 0.2.2, so the harness can answer with its own unknown-tool error and the model can retry. Only the template's own `<function=NAME>` form is affected: a drifted opener (#3441) still needs a declared name, and a request that declared no tools is not changed (`declared_only` still applies). Any other value refuses to start the server, like `tool_call_recovery`. The change is one condition in the parser's well-formed-call branch, the `Service` attribute, the config read in `main`, and one row in `docs/DETAILS.md` plus a pointer in the #3796 paragraph. ## Validation Revision: this branch on `main`; a first version (same well-formed path, without the drifted-opener and no-tools guards) also ran on `v0.2.7.1`. Windows 11, 2x RTX 3090 24 GB (GPUs 1+2), Qwen3.8-Flash-Next-GSQ-RCO-abliterated IQ3_S, engine 0.1.52. Passed: - `python -m unittest serve.test_server.UndeclaredToolCallSwitch` (new): `"text"` keeps the block as text and names it in `rejected_tool_calls`; `"call"` returns `("tools__bash", {"command": "ls"})` and no text; `"call"` with no tools declared keeps the text. Each fails without the corresponding part of the `frontend.py` change. - `python -m unittest serve.test_server serve.test_frontend serve.test_reasoning_tools serve.test_reasoning_rescue serve.test_parser_call_scan`: 431 tests OK (3 skipped) on `main`; 428 OK on `v0.2.7.1` (before the no-tools test was added). - Hardware, on `v0.2.7.1` + the first version of this commit (same well-formed path), `"undeclared_tool_calls": "call"`: the same captured pi request replayed 3 times returned `tool_calls: [tools__bash {"command":"ls -la /lavoro/file"}]`, `finish_reason: "tool_calls"`, 3/3 (before: text, 3/3). - pi end to end on the same server: the model called `tools__bash`, pi answered `Tool tools__bash not found`, the next turn called `codemode` with `await tools.bash(...)` and finished the task. Not run: GPU builds (no C++/CUDA/HIP/SYCL file is touched), the Metal/Mac path, `/v1/messages` and Responses routes on hardware (the parser path is shared; the unit tests cover Chat Completions). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5144
No description provided.