mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #625] [CLOSED] serve: stable tool order on the DeepSeek paths too (a reordered tool list re-rendered the prompt head, so the engine re-read the conversation) #631
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#631
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/mw00/project-maya/pull/625
Author: @SeriousRising
Created: 10/28/2026
Status: ❌ Closed
Base:
main← Head:serve-ds4-tool-order📝 Commits (1)
9fc017bserve: stable tool order on the DeepSeek paths too (a reordered tool list re-rendered the prompt head, so the engine re-read the conversation)📊 Changes
3 files changed (+51 additions, -9 deletions)
View changed files
📝
serve/frontend.py(+5 -3)📝
serve/test_ds41_conformance.py(+16 -6)📝
serve/test_server.py(+30 -0)📄 Description
Problem. On the DeepSeek paths a request whose
toolslist arrives in a different order renders the tool block, at the prompt's head, in that new order. The engine's prefix match then breaks at the system prompt and it re-reads the whole conversation. Agent clients do reorder tools (an MCP hub's server order, plugin tools registered late). On 2x CMP 170HX that is ~33-38 s for a 60K-token conversation (an estimate: 60K tokens at the 1700-1850 tok/s we measured for 16K-32K fresh prompts; platform-specific).Cause (v1.1.35):
serve/frontend.py:491(openai_to_messages, DeepSeek branch):tools = tools_from_openai_format(declared) if declared else None, with nostable_tool_order, unlike the legacy path at:534.serve/frontend.py:601-602(anthropic_to_messages):if not deepseek: tools = stable_tool_order(tools), so DeepSeek is excluded explicitly.Fix.
stable_tool_orderon the DeepSeek OpenAI and Anthropic paths too.tools_from_openai_formatreturns flat dicts keyed by the namespace-qualified encoding name (ns::name), so namespaced tools with equal names stay distinct. It is the trade the legacy path already makes: a reordered turn renders bit-identical to the first-seen order, schemas untouched.stable_tool_order's memory (_TOOL_ORDERS) is process-global and the DeepSeek converters use it now, so the DeepSeek conformance goldens (serve/test_ds41_conformance.py) clear it insetUpand no longer depend on test order.Output: a DeepSeek prompt whose tools arrive in a new order now renders them in the first-seen order (the same set, the same schemas). Unchanged for a request whose order does not change, and for the legacy path.
Tests.
serve/test_server.pyStableToolOrdergainstest_deepseek_paths_are_stabilized_too(OpenAI and Anthropic DeepSeek converters, the same set in three orders) andtest_deepseek_namespaced_tools_key_on_the_encoding_name; both fail on v1.1.35'sfrontend.pyand pass with the fix. Not measured end to end: we did not replay a rotated-tool session through the server. This is a prefix-reuse fix, not a speed claim.Checks (as
.github/workflows/tests.yml):tools/check_hip_compat.pyOK; server tests 465 OK (12 skipped; v1.1.35 runs 463 - the two new DeepSeek tool-order tests); installer and tools tests 584 OK (31 skipped).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.