mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #790] [CLOSED] serve: honour OpenAI tool_choice "required" and a named function #2831
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#2831
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/790
Author: @aguindehi
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:serve-tool-choice📝 Commits (1)
7d67a0bserve: honour OpenAI tool_choice "required" and a named function📊 Changes
3 files changed (+214 additions, -16 deletions)
View changed files
📝
serve/frontend.py(+21 -0)📝
serve/server.py(+48 -16)📝
serve/test_server.py(+145 -0)📄 Description
What
/v1/chat/completionsnow honours a forcedtool_choice:"required": the reply is a call to one of the request's tools.{"type": "function", "function": {"name": N}}: the reply is a call toN.Strata has no grammar decoder, so the server writes the call's opening itself:
<tool_call>\n<function=(plusN>\nfor a named choice). The model can thenonly continue with a call. Where the opening goes:
character split across tokens), the same way the
reasoning_budget_tokenswrap-up continues from the prefix the engine already holds;
REASONING_WRAP_UP."auto"and notool_choiceare unchanged."none"offers no tools, as theResponses route already does. An unknown name, a forced choice without tools,
other values, and a forced choice together with MCP tools are a 400 instead of
being silently ignored.
Why
Agents force a tool on specific turns. Hindsight's reflect agent, for example,
sends
tool_choice: "required"on its first turns and on itsdonecall.Until now Strata ignored
tool_choice, so those turns could come back as text.Limits
as
response_formattoday).max_tokensstaysfinish_reason: "length"withouttool_calls, as before.tool_choicecanreuse
forced_call()in a follow-up.Tests
serve/test_server.pygetsForcedToolChoice(6 tests, withMockEngineandByteTokenizer):"required"and named, thinking on and off, streamed andwhole replies, budget wrap-up,
"auto"/absent/"none", a call cut by maxtokens, and the refused values.
python -m pytest servepasses: 267 passed,7 skipped.
The same change, on
v0.1.38(99f3dbd), has been deployed behind LiteLLMsince 2026-10-03 for Hindsight's forced reflect turns.
🤖 Generated with Claude Code
https://claude.ai/code/session_013Dd7NbnghR6cgQdQ2rTkUZ
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.