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#2774
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/701
Author: @bsorensen110
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:fix/serve-tools-400📝 Commits (3)
0b5aa7aserve: a malformed "tools" is a 400 naming the field (#592)883b0bbFix: handle wrapped tool calls also1d9a8d0serve/test_server.py: the wrapped-tool case the Copilot review found📊 Changes
3 files changed (+116 additions, -5 deletions)
View changed files
📝
serve/frontend.py(+33 -4)📝
serve/server.py(+1 -1)📝
serve/test_server.py(+82 -0)📄 Description
Summary
A request whose
toolsis not a list of tool objects takes the request thread down with anAttributeError/TypeError/KeyError. The client sees a connection reset (a reverse proxy shows502), and it looks like the engine died. This validatestoolswhere the request is parsed, so the caller's existingValueError → 400path answers with a message naming the field. Fixes #592.Where it broke
toolswas the one request field that skipped the repo's shape validation:serve/frontend.py(OpenAI path):t.get("function", t) if isinstance(t, dict) and ... else t— a non-dict entry is handed on unchanged;serve/server.py:2422:own = {t.get("name") for t in tools or []}— assumes every entry is a mapping →AttributeError: 'str' object has no attribute 'get';serve/frontend.py(Anthropic path):t["name"]→TypeError: string indices must be integerson a string,KeyErroron a dict withoutname.The same file already has the right convention for
messagesandtool_calls(_object_list, #460): decode a double-encoded JSON string, acceptNoneas no field, raiseValueErrorfor anything else — the server turns that into a 400 naming the field.toolsjust wasn't wired through it.The change
serve/frontend.py: new_tools_of()(the #460 convention) used by bothopenai_to_messagesandanthropic_to_messages; the Anthropic path additionally requires a non-empty"name"string per tool.serve/server.py: the consumer keepsif isinstance(t, dict)as a second line of defence (the reporter's suggestion).serve/test_server.py:ToolsShape, 4 tests on the mock engine — no GPU, no pack.No behavior change for valid requests: flat-form tools,
{"type":"function",...}tools, a double-encoded JSON string, and an absent field all behave exactly as before.Evidence
RED, reproduced on this repo at
99f3dbd— mock server (python -m serve.server --engine mock --port 8095), the issue's three repros verbatim:tools"auto"400—tools must be a list of objects["get_weather"]400—tools must be a list of objects[{"name":"get_weather"}](OpenAI)[{"name":"get_weather"}][{"description":"no name"}]KeyError→ thread dies400—tools: every tool needs a "name" stringServer log before the fix: 4
Tracebackentries (AttributeError: 'str' object has no attribute 'get'atserve/server.py:2422), matching the report.Unit tests (
python -m unittest serve.test_server.ToolsShape -v):origin/main:Ran 4 tests ... FAILED (errors=4)— every malformed case raiseshttp.client.RemoteDisconnected: Remote end closed connection without response, the exact reported symptom;Regression (mock engine, no GPU): full
serve.test_server122 tests OK;serve.test_security,test_structured,test_monitor,test_lifecycle,test_detok,test_mcpall OK.Test plan
ToolsShapeRED on main (4 errors: RemoteDisconnected), GREEN with the fixserve.test_server(122) + security/structured/monitor/lifecycle/detok/mcp suites passtools, server answers the next request normally🤖 Generated with Hermes Agent
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.