mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5398] [Engine] Integrate tool and JSON constraints on Metal, with Mac regression evidence #5413
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#5413
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/5398
Author: @tuhochi
Created: 11/6/2026
Status: 🔄 Open
Base:
main← Head:contribution/tool-json-metal📝 Commits (10+)
1903bb4[Engine] integrate tool and JSON token constraints with Metal verification58e44df[Engine] preserve exact tool-name masks for Responses namespacesf72a483[Engine] preserve parallel request IDs when adding token masks0cb8b78[Tests] exercise minimal and optional JSON validation modes independently01ed660[Tests] remove platform and stale-version assumptions from app fixtures3030aa3[Tests] isolate launch pilot terminal capabilities from the runnerb7dbc59[Tests] identify the full server regression gate explicitlya3e29a8[Tests] simulate the destination disk in the low-space warning test2881d47[Tests] isolate TUI screens from installed network helpers6fe85c2[Tests] verify legacy download guard before the explicit override📊 Changes
38 files changed (+2998 additions, -61 deletions)
View changed files
📝
.github/workflows/terminal-minimal-server.yml(+24 -4)📝
apps/host/tests/component-updates.test.mjs(+1 -1)📝
docs/DETAILS.md(+37 -2)➕
include/strata/core/token_mask.hpp(+162 -0)📝
include/strata/core/verify.hpp(+18 -0)📝
metal/src/engine/window.cpp(+40 -1)📝
requirements.txt(+1 -0)➕
serve/constrain.py(+751 -0)➕
serve/fake_mask_engine.py(+89 -0)📝
serve/responses.py(+23 -2)📝
serve/server.py(+112 -4)📝
serve/structured.py(+8 -0)➕
serve/test_constrain.py(+971 -0)📝
serve/test_ds_parallel.py(+9 -1)📝
serve/test_server.py(+2 -2)📝
serve/test_structured.py(+44 -0)➕
serve/test_tool_name_constraint.py(+349 -0)📝
setup.py(+2 -1)📝
src/core/verify.cpp(+70 -0)📝
src/program/generate.cpp(+91 -6)...and 18 more files
📄 Description
Description
Problem and approach
Requests could return undeclared tool names or schema-invalid JSON despite
providing tools or a response format. Combining tools and JSON constraints
also exposed a mask-width mismatch on Metal.
This builds on ncphri’s #3800 and #4222, which provide the original
constraint implementation. This PR adds:
The architectural reference is llama.cpp: constrain tokens before emission,
then stream accepted output. Identical behavior in every case is not claimed.
Apple Silicon results
Same model and frozen requests, comparing unpatched Strata with our integrated fork:
Across 113 requests, ordinary control outputs were unchanged. Warm median latency changed by +0.4–0.7% for tool workloads and −0.7–+2.5% for JSON workloads. These measurements cover this integrated fork, not either original PR in isolation.
Reproduction, raw results and measurement limits (https://github.com/tuhochi/Strata/blob/07544207d16993c31f5dda2067b2c0671b33be40/fork/evaluation/P3-HARDWARE-20261106.md)
Validation and remaining limits
uniqueItemsmakes llguidance compilation fail, and the existing fallback drops the mask.uniqueItemsenforcement, but retains supported constraints when skipping it; fallback parity remains incomplete.Keeping this PR in draft while the outstanding checks are addressed.
## Apple Silicon resultsSame model and frozen requests, comparing unpatched Strata with our integrated fork:
Across 113 requests, ordinary control outputs were unchanged. Warm median
latency changed by +0.4–0.7% for tool workloads and −0.7–+2.5% for JSON
workloads. These measurements cover this integrated fork, not either
original PR in isolation.
Reproduction, raw results and measurement limits (https://github.com/tuhochi/Strata/blob/07544207d16993c31f5dda2067b2c0671b33be40/fork/evaluation/P3-HARDWARE-20261106.md)
Validation and remaining limits
the explicit tool-name-guard opt-out.
passing server suite is not claimed.
One array case still fails: unsupported uniqueItems makes llguidance
compilation fail, and the existing fallback drops the mask.
lacks uniqueItems enforcement, but retains supported constraints when
skipping it; fallback parity remains incomplete.
Keeping this PR in draft while the outstanding checks are addressed.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.