mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3395] [CLOSED] [Other] preserve Chat Completions tool result order #4614
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#4614
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/3395
Author: @j-luwierski
Created: 10/20/2026
Status: ❌ Closed
Base:
main← Head:codex/chat-tool-results-main-20261020📝 Commits (1)
7b87be6[Other] preserve Chat Completions tool result order📊 Changes
2 files changed (+166 additions, -1 deletions)
View changed files
📝
serve/frontend.py(+33 -1)➕
serve/test_chat_tool_results.py(+133 -0)📄 Description
Problem and result
When an OpenAI Chat Completions request contains multiple tool calls and the client returns their tool results in a different order, the serving layer drops the call IDs before rendering the prompt. The model then sees anonymous results in arrival order, even when the results belong to calls with the same function name. The fix restores the call order for complete, unambiguous result runs before removing the temporary IDs.
Related discussion
This follows the closed tracker-reset submission #2952. The new branch is based on current main; the v0.2.0-beta tag is an ancestor of the base revision.
Approach
The Chat Completions conversion retains call IDs only while normalizing a request. It reorders a result run only when call and result IDs are nonempty unique strings with matching sets and counts. Missing, duplicate, unknown, or incomplete IDs keep their received order. IDs are removed before prompt rendering. No engine, template, Anthropic, Responses, or default behavior changes.
Validation
Environment: Linux, Python 3.12.14, dependencies from the repository's pinned requirements.txt.
Passed:
5bda973a43: /tmp/strata-pr2952-venv/bin/python -m unittest serve.test_chat_tool_results -q ran 7 tests and reproduced 4 failures, including reversed same-function results and the HTTP-to-engine prompt order.7b87be6220: /tmp/strata-pr2952-venv/bin/python -m unittest serve.test_chat_tool_results serve.test_frontend serve.test_server serve.test_responses -q ran 415 tests; OK (skipped=1) in 128.991 seconds.Failed:
Not run:
Limits
Only complete, unambiguous tool-result runs are reordered. Incomplete or ambiguous histories preserve their incoming order.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.