[PR #1804] [CLOSED] structured: one-string-field json_schema answered as plain text (opt-in), progress in structured keep-alives #3686

Closed
opened 2026-11-07 15:30:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1804
Author: @gt50
Created: 10/10/2026
Status: ❌ Closed

Base: main ← Head: plain-string


📝 Commits (1)

  • 468c6df structured: a one-string-field json_schema answered as plain text (opt-in structured_plain_string); progress in structured keep-alives

📊 Changes

4 files changed (+197 additions, -13 deletions)

View changed files

📝 docs/DETAILS.md (+13 -1)
📝 serve/server.py (+27 -6)
📝 serve/structured.py (+90 -6)
📝 serve/test_structured.py (+67 -0)

📄 Description

Title

Structured output: a one-string-field schema answered as plain text (opt-in), and progress in structured keep-alives

Summary

Split out of #1789 (which now only carries the Windows AMD images), as AGENTS.md asks: one change per PR, a new feature opt-in.

What changed

  • "structured_plain_string": true (opt-in): a json_schema that is one required string field, with an optional description/title and no enum, pattern or length limit, is answered as plain text, and the server builds the object around it.
    • Measured on a scanned rent roll (UD-IQ4_XS, temperature 0, a "write out every word on this page" prompt):

      Asked for Result
      {"text": ...} the table inside the string, then the escaped newline 256 times instead of the page's last lines and the closing quote
      plain text the whole page in 165 tokens, ending on its own
    • A model that writes the JSON object anyway is taken at its word, and that object is validated as before; an invalid one is still an error. Not with tools.

  • Structured SSE keep-alives now say how far the answer is (: keep-alive: structured output buffered until it is validated, N pieces (M characters) written so far), so a long answer can be told from a stuck one. They are SSE comments, which clients ignore.
  • Docs: docs/DETAILS.md.

Extra Notes

  • Default path: without the setting, prepare_format writes the same directive and validated_json validates as before.
  • The one change everyone gets: the text of the structured-stream keep-alive comments, once content has been written. It is comment text only; data lines and the result are unchanged. Happy to put that behind the setting too if you prefer.
  • Tests: serve/test_structured.py covers the wrap (streamed and not), JSON-anyway, off by default, which schemas qualify, and the progress notes. All serve and setup test files pass on main fb58e0d.

🤖 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/1804 **Author:** [@gt50](https://github.com/gt50) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `plain-string` --- ### 📝 Commits (1) - [`468c6df`](https://github.com/Niko1221/Strata/commit/468c6df2daef76e76caca7cbca610e1355221dcb) structured: a one-string-field json_schema answered as plain text (opt-in structured_plain_string); progress in structured keep-alives ### 📊 Changes **4 files changed** (+197 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+13 -1) 📝 `serve/server.py` (+27 -6) 📝 `serve/structured.py` (+90 -6) 📝 `serve/test_structured.py` (+67 -0) </details> ### 📄 Description ## Title Structured output: a one-string-field schema answered as plain text (opt-in), and progress in structured keep-alives ## Summary Split out of #1789 (which now only carries the Windows AMD images), as AGENTS.md asks: one change per PR, a new feature opt-in. ## What changed - **`"structured_plain_string": true` (opt-in):** a `json_schema` that is one required string field, with an optional description/title and no enum, pattern or length limit, is answered as plain text, and the server builds the object around it. - Measured on a scanned rent roll (UD-IQ4_XS, temperature 0, a "write out every word on this page" prompt): | Asked for | Result | | --- | --- | | `{"text": ...}` | the table inside the string, then the escaped newline 256 times instead of the page's last lines and the closing quote | | plain text | the whole page in 165 tokens, ending on its own | - A model that writes the JSON object anyway is taken at its word, and that object is validated as before; an invalid one is still an error. Not with tools. - **Structured SSE keep-alives** now say how far the answer is (`: keep-alive: structured output buffered until it is validated, N pieces (M characters) written so far`), so a long answer can be told from a stuck one. They are SSE comments, which clients ignore. - **Docs:** `docs/DETAILS.md`. ## Extra Notes - **Default path:** without the setting, `prepare_format` writes the same directive and `validated_json` validates as before. - **The one change everyone gets:** the text of the structured-stream keep-alive comments, once content has been written. It is comment text only; data lines and the result are unchanged. Happy to put that behind the setting too if you prefer. - **Tests:** `serve/test_structured.py` covers the wrap (streamed and not), JSON-anyway, off by default, which schemas qualify, and the progress notes. All `serve` and setup test files pass on `main` fb58e0d. 🤖 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>
bsakaguchi 2026-11-07 15:30:04 +07:00
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#3686
No description provided.