mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1788] [CLOSED] serve: preserve tool prefixes for tool_choice=none #3674
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#3674
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/1788
Author: @llj098
Created: 10/10/2026
Status: ❌ Closed
Base:
main← Head:fix/tool-choice-none-cache-prefix📝 Commits (1)
a64c7f3serve: preserve tool prefixes when tool_choice is none📊 Changes
4 files changed (+116 additions, -16 deletions)
View changed files
📝
serve/frontend.py(+13 -4)📝
serve/server.py(+15 -8)📝
serve/test_frontend.py(+32 -1)📝
serve/test_server.py(+56 -3)📄 Description
Summary
Keep tool declarations in the Chat Completions prompt when
tool_choiceis"none", while independently disabling structured tool-call output and the MCP tool-execution loop.A client can keep its conversation and tools unchanged, append a summarization/compaction instruction, and set
tool_choice: "none". Currently_openai()replacestoolswithNone. Because the model's template puts tool declarations near the beginning, this changes the leading prompt tokens and prevents an otherwise matching conversation checkpoint from being reused. A long context is not necessary to reproduce this input-prefix mismatch.Related: #1222 addressed Codex/Responses compaction. This PR targets
/v1/chat/completions; it does not change the Responses compaction mechanism or require client/session metadata.What changed
tool_choice: "none".parse_tools=TruetoOutputParserandService.run. Chat Completions sets it to false fornone, including disabling recovery of calls inside reasoning. Preserve the existingtool_call_recoveryoption for other requests.run_with_mcpundernone; MCP declarations can remain in the prompt without executing model-requested tools.response_formatwith tool declarations whentool_choiceisnone; the existing structured-output/MCP restriction remains.If the model writes tool-shaped text under
none, it is returned as ordinary reasoning/content, nottool_callsor atool_callsfinish reason. This is an output-parsing/execution restriction, not a new grammar or sampling constraint.Normal
auto/absent/required/named behavior, Responses and Anthropic routing, the native engine, and KV formats/policies are left alone. The branch is based directly on upstreamfb58e0dbc8399662c0e47c76578c6e878b14f6cfand contains only this change, in four Python files.Validation
CPU/mock regressions
372 tests passed on the PR worktree. No GPU backend files changed.
Short-context prefix reproduction
Compared unmodified upstream
fb58e0dwith this patch using the real model tokenizer/chat template, actual isolated HTTP handlers, andMockEnginegeneration. The fixture has two tool definitions and 128 short synthetic records, followed by an assistant reply and a summarization request withtool_choice: "none". The context limit is 4096 tokens.The ordinary request's token sequence is identical before/after. For the final row, a synthetic checkpoint token sequence ending before the first assistant turn (3191 tokens) was supplied to the unmodified upstream C++
conversation_prefixfunction.This checks HTTP rendering and native token matching only: no actual KV/GDN snapshot was captured or restored, and no GPU inference or cache-hit/performance benchmark was performed. It removes this specific source of prefix invalidation; it does not guarantee hits when other prompt content or checkpoint boundaries change.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.