mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4828] [CLOSED] [Engine] tool_choice "required" with several tools gives a real call, not raw markup, on chat and messages #5198
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#5198
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4828
Author: @gdevenyi
Created: 10/31/2026
Status: ❌ Closed
Base:
main← Head:api/tool-choice-required-opening📝 Commits (1)
c9d1d40tool_choice "required" with several tools: write only "<tool_call>\n", because from a written "<function=" the model went on with names no tool has and the reply came back as text📊 Changes
3 files changed (+10 additions, -10 deletions)
View changed files
📝
serve/frontend.py(+2 -2)📝
serve/test_frontend.py(+1 -1)📝
serve/test_server.py(+7 -7)📄 Description
Problem and result
On a real model,
tool_choice: "required"on/v1/chat/completions, and{"type": "any"}on/v1/messages, gave no call when the request had two or more tools. The reply was a 200 holding raw<tool_call>markup as text.The server wrote
<tool_call>\n<function=for the model, and Qwen3.8 went on with a name the request never offered (getTime,call_ExternalTool00,update_plan,parse_time).Now the server writes only
<tool_call>\n, and the model writes<function=NAME>itself. Every forced run gave a call to an offered tool.Real engine, two tools offered, the same script on both sides. Calls to an offered tool:
main"required", whole"required", whole"required", streamed"required", streamed"required", whole"required", wholeany, wholeany, wholeany, wholeany, wholeTotals:
main7/70, this PR 70/70.Related discussion
#790 (closed) added
forced_call. #3441 (closed) is about the same symptom, a malformed<function=...>block coming back as plain content, from another cause. No open issue reports this. It is a focused fix, so there is no scope issue. I found the problem while checking a change for/v1/responses, which I am sending as a separate PR on top of this one.Approach
One line in
forced_call. A named choice, and"required"with one tool, still write the whole<function=NAME>\n, because the server knows the name.The cause is not proven. The vocabulary has
=get(27362) as one token, so a model's own<function=get_time>likely does not pass through a lone=. I did not test that explanation. What I measured is the result of the change.DeepSeek does not change.
to_dsml_forcereturns the same text for the old and the new opening (<|DSML| calls>\n<|DSML| invoke name="), checked by calling it. So the same problem could exist there; I did not run DeepSeek.Requests with
auto,none, notool_choice, a named choice or one tool never reach this line.Validation
Revision:
c9d1d402against basec62d5e3a. Linux, Python 3.12.Real engine: RTX 5080 16 GB, engine 0.1.55 from release v0.2.9, Qwen3.8-Flash-Next IQ3_S, context 65536, temperature 0.7, tools
get_timeandget_weather, 127.0.0.1. Plain HTTP, no SDK.Passed:
get_timein every Paris run. On "Say hi." the choice varies between the two tools, as nothing in the prompt fits either.main, 0 on this PR. Themaincount also covers the Responses runs of the same session, which do not force a call.autois not forced, chat, 3 runs each, both sides: the Paris promptget_time3/3, "Say hi." text 3/3.python -m unittest serve.test_server serve.test_frontend serve.test_anthropic_base_url serve.test_chat_tool_results serve.test_dsv41: 461 tests, failures=1, skipped=1. The failure is listed below.serve.test_server.ForcedToolChoiceandserve.test_frontend.ForcedCallOpeninggive failures=10 onc62d5e3a.Failed:
serve.test_server.GpuChoice.test_hip_ordinal:AssertionError: '0,1' != '1,0'. It fails the same way onc62d5e3a. Nothing here touches it.Not run:
/v1/messages.Limits
<tool_call>\n. That did not happen in these 70 forced runs, and its rate on other models is not measured.requiredasks for.🤖 Generated with Claude Code
https://claude.ai/code/session_01W53iURzvDQMjnYemag8uvv
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.