fix(ai): make ADR-0033 blueprint authoring work with OpenAI structured outputs#1547
Merged
Merged
Conversation
…d outputs Two bugs found via a live Studio e2e run against a real model (OpenAI via the Vercel AI Gateway), both missed by unit tests: 1. propose_blueprint failed under OpenAI strict structured outputs. SolutionBlueprintSchema uses optional fields + a z.record seedData; strict mode requires every property in `required` and rejects open additionalProperties. Add SolutionBlueprintStrictSchema (optional→nullable, no z.record) as the generateObject output contract only; keep the lenient schema for validation; strip the nulls the strict contract emits. 2. Tool-only assistant turns failed to persist (ai_messages.content required), dropping the turn and losing context so the agent re-proposed instead of applying. addMessage now stores a tool-name placeholder + a defensive non-empty fallback. Adds unit tests for both. Verified end-to-end in Studio: propose → confirm → batch-draft objects/views/dashboards/app → review/diff → publish. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
What & why
Two bugs found by a live end-to-end run of the ADR-0033 loop in Studio (chat → blueprint → draft → review → publish) against a real model — OpenAI
gpt-5.5via the Vercel AI Gateway. Both were invisible to the existing unit tests (they validate the Zod schema directly and never round-trip through OpenAI's strict JSON-schema check or a multi-turn conversation).1.
propose_blueprintfailed against OpenAI strict structured outputsSolutionBlueprintSchemauses.optional()fields and a free-formseedDataz.record. OpenAI's strict structured outputs (whatgenerateObjectuses through the gateway) require every property inrequiredand reject openadditionalProperties, so the call errored:…and the agent silently fell back to free-text — the blueprint→draft path never ran on OpenAI models.
Fix: add
SolutionBlueprintStrictSchema— a strict-compatible mirror (optional →nullable, noz.record) used only as thegenerateObjectoutput contract. The lenientSolutionBlueprintSchema(and every existing consumer/test) is unchanged; the blueprint toolsstripNullsthe values the strict contract emits so downstream stays clean.2. Tool-only assistant turns failed to persist → context loss
ai_messages.contentis required, but an assistant turn that only emits a tool call has no text. The insert failed, the turn was dropped, and the next turn was rebuilt without it — so after the user confirmed, the agent re-proposed instead of applying. Fix:ObjectQLConversationService.addMessagenow synthesizes a readable placeholder from the tool names ((called propose_blueprint)) + a defensive non-empty fallback.Verification
apply_blueprintdrafts 8 artifacts (objects/views/app, self-correcting a dashboard) → chat "查看 8 项变更" → designer generic DraftReviewPanel diff → Publish →GET /meta/object/projectreturns the live object,?state=draft→ 404 (promoted). 0 schema errors, 0 persist failures in the log post-fix.🤖 Generated with Claude Code