mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4755] [Engine] response_format json_object: an array reply is not a successful object #5162
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#5162
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/4755
Author: @Tsury
Created: 10/30/2026
Status: 🔄 Open
Base:
main← Head:fix-json-object-array-root📝 Commits (1)
fce1b3d[Engine] response_format json_object: an array reply is not a successful object📊 Changes
2 files changed (+73 additions, -0 deletions)
View changed files
📝
serve/structured.py(+11 -0)📝
serve/test_structured.py(+62 -0)📄 Description
Problem and result
With
response_format: json_object,extract_jsonstarts at the first{. A reply that is a JSON array of objects therefore passes:[{"answer":1},{"answer":2}]comes back as{"answer":1}, a 200 with the rest of the reply silently dropped.After this change, a reply whose root is an array is kept whole, so validation fails it with the existing
structured_output_failederror. Text before an object still works as before.Related discussion
None found in issues or pull requests.
Approach
Before the existing object scan,
extract_jsonlooks at each[before the first{. It returns from that[when only brackets and space come between, or when the bracket parses as an array that contains the object.Validation
Passed:
main(870aedd9): 18 subtest failures. With the change: all pass.python -m unittest serve.test_server serve.test_structured: 374 tests pass (Linux, Python 3.14).Not run:
python -m unittest discover -s serveand any GPU or model run. This change was split from a maintained v0.2.8 build that runs on an RTX 5090 Laptop; the unit tests above are the evidence for this branch.Limits
A reply that was accepted by accident now fails with 502, by design.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.