[PR #4755] [Engine] response_format json_object: an array reply is not a successful object #5162

Open
opened 2026-11-07 16:33:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 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_json starts 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_failed error. Text before an object still works as before.

None found in issues or pull requests.

Approach

Before the existing object scan, extract_json looks 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:

  • New tests against unchanged 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 serve and 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.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4755 **Author:** [@Tsury](https://github.com/Tsury) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-json-object-array-root` --- ### 📝 Commits (1) - [`fce1b3d`](https://github.com/Niko1221/Strata/commit/fce1b3d623ff76fec3c0ee01d576092d87c67136) [Engine] response_format json_object: an array reply is not a successful object ### 📊 Changes **2 files changed** (+73 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `serve/structured.py` (+11 -0) 📝 `serve/test_structured.py` (+62 -0) </details> ### 📄 Description ## Problem and result With `response_format: json_object`, `extract_json` starts 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_failed` error. Text before an object still works as before. ## Related discussion None found in issues or pull requests. ## Approach Before the existing object scan, `extract_json` looks 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:** - New tests against unchanged `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 serve` and 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](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5162
No description provided.