mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#2733
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/635
Author: @Avicennasis
Created: 10/3/2026
Status: ❌ Closed
Base:
main← Head:fix/serve-malformed-tools📝 Commits (1)
6365b90serve: a malformed "tools" value is a 400 naming the field, not a closed connection (#592)📊 Changes
2 files changed (+71 additions, -4 deletions)
View changed files
📝
serve/frontend.py(+26 -4)📝
serve/test_server.py(+45 -0)📄 Description
Fixes #592. One fail-closed change on the request seam, with tests against the mock engine (no model, no GPU).
serve/frontend.py: a malformed"tools"is a 400 naming the field, where it closed the connectionopenai_to_messages(serve/frontend.py:185) handed every entry of a request'stoolson unchanged unless it was a{"type": "function"}object, andanthropic_to_messages(:235) didt["name"]on each; the next consumer,server.py:2422'sown = {t.get("name") for t in tools or []}, assumed an object. So"tools": "auto",["get_weather"], or[{"type": "function", "function": "get_weather"}]raisedAttributeError/TypeError/KeyErrorin the request thread and the connection closed with no reply - the502behind a proxy in #592. Reproduced here with the mock engine onmain: 6 of the 8 shapes I sent (the issue's three and a stringfunction, over both endpoints) came backRemoteDisconnected, withAttributeError: 'str' object has no attribute 'get'x3,TypeError: string indices must be integersx2 andKeyError: 'name'x1 on the server's console. The issue's third shape,[{"name": "get_weather"}], already answered 200 on both APIs: a bare object with a name is the unwrapped form, and it stays so.Both converters now go through
_tool_list, next to the #460_object_listit builds on. A value that is not a list of objects (a JSON-encoded string is decoded first, asmessagesis), an entry whose"function"is not an object or that has no"name"string, or a"parameters"/"input_schema"that is not an object is aValueError, which the dispatcher already turns into the 400 the other field refusals use:That is the mock engine on a free port; the issue's
[{"type":"function","function":"get_weather"}]answerstools[0]: "function" must be an object[400], a function object without a nametools[0] has no "name" string[400], and[{"name":"f","parameters":[]}]tools[0] (f): "parameters" must be an object[400]. No field,nulland[]are still no tools.server.py:2422is unchanged: the list it gets is now always objects with a name, so the consumer needs no second guard./v1/messages/count_tokensreads the same request and refuses the same way.Not overlapping with #510: that one is the history side,
json.loadson atool_callsentry'sargumentsatfrontend.py:181; this is the request'stoolslist, four lines down, and the hunks do not touch.Tests:
serve/test_server.py(ClientShapes,python -m unittest serve.test_server): 13 malformed shapes over/v1/chat/completionsand/v1/messages, pluscount_tokens, are a 400 whose message namestools; a well-formed tool on each API still renders into the prompt (the name and a schema property are read back from the mock engine's prompt); the bare form answers 200 on both; the empty forms areNone. Onmainwith the same test file: 9 errors (the connection closed with no reply, as in the issue) and 5 failures (shapes such as{"name": 5},{"name": null}or"parameters": []that were accepted with 200 and rendered as they came).What I ran, and where
Linux x86_64 (Ubuntu 24.04, AMD Ryzen 7 5800X - no AVX-512, no NVIDIA GPU), Python 3.12.3. Nothing under
src/is touched, so nothing was built.python -m unittest serve.test_server: 120 tests OK in 55 s (118 as before plus these 2; the 2 run in 0.6 s).python -m unittest serve.test_server.ClientShapesagainstmain'sserve/frontend.pywith the same test file: 9 errors, 5 failures, as above.git diff --checkclean.Branch is on
99f3dbd(0.1.38); happy to rebase if it has moved by the time you look.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.