Repository navigation
SWF(bug): enforce text.format schemas in the Responses API - #65
Merged
Merged
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
devin-ai-integration
Bot
changed the base branch from
devin/1795385477-fix-spark-test-build
to
main
November 22, 2026 22:24
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
devin-ai-integration
Bot
force-pushed
the
devin/1795385672-responses-text-format
branch
from
November 22, 2026 22:24
2db2d89 to
6be1a34
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/v1/responsesnow enforcestext.format(json_schema/json_object) the same way/v1/chat/completionsenforcesresponse_format. Before this change it ignored the format without any error.Root cause:
lower_responses_to_chatincrates/spark-server/src/openai/responses_lowering.rshard-codedresponse_format: None, so the schema never reached the chat pipeline's grammar constraint.Fix: a small
lower_text_formathelper maps Responses' flat{type:"json_schema", name, schema, strict}onto chat's nested{type:"json_schema", json_schema:{...}}and deserializes it into the existingResponseFormat. No new schema types were added.json_objectpasses through unchanged, andtextor an absent format stays unconstrained. A malformed format now gets a 400invalid text.format: ..., which matches what chat does with a malformedresponse_format.Rebased onto main after #63 (the
--bin sparktest build fix) merged.Test plan
New regression tests are in
crates/spark-server/src/openai/tests/responses_text_format.rs. They check that json_schema keeps name, description, schema and strict; that json_object is kept; that text is unconstrained; and that a malformed format is rejected.Before the fix:
After the fix:
Full
ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark:ok. 3244 passed; 0 failed; 14 ignored(on main after #63, rebased).cargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --testsbash scripts/check-license-headers.sh(4266 valid, 0 invalid)typosmodel_not_loadedbefore lowering runs, so it cannot show this change.Try it (against a served model):
Notes for reviewers
Untested: whether a live model's output actually conforms to the schema. Both the streaming and the blocking Responses paths turn the lowered request into the existing chat request, which derives the grammar from
response_format. That was checked by reading the code, not by running it.CLA
Implemented in session Enforce text.format schemas in Responses API
Review with Devin · Open in Devin Desktop