release(core): @ai_kit/core 1.9.0 — resilient structured output - #118
Merged
Conversation
…eFormat Structured-output agents on non-OpenAI providers (e.g. Scaleway) fail intermittently with AI_NoObjectGeneratedError when the model returns valid JSON but with drifted keys (casing/separator like documentType↔document_type, or semantic/translated aliases like type↔document_type). Nothing constrains the model since these providers don't enforce responseFormat. Adds two agnostic resilience layers to the structured pipeline, on by default and backward-compatible (a conformant object passes through unchanged, no extra LLM call): 1. Deterministic key normalization — recursively remaps keys onto the schema's property names, insensitive to case/separator. Fixes casing drift with zero LLM cost. 2. Error-driven repair retry — when the object still misses required keys or violates enums, re-queries the model (default 2 attempts) reinjecting the issues and the exact expected keys. Generic safety net for semantic aliases. Also fixes shouldUseStructuredPipeline, which gated on structuredOutput.type but the AI SDK's Output.object() identifies via .name === "object" — so the pipeline (and thus any resilience) was never selected for real usage. Now accepts type ?? name, consistent with getJsonSchemaFromStructuredOutput. New opt-out options on Agent config and per call: normalizeStructuredKeys, structuredOutputRepair. Validated live against Scaleway gpt-oss-120b: drifted keys converge to a zod-conformant object in one repair; disabling resilience reproduces the original failure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
feat(core): resilient structured output (key drift) + activate pipeline gate
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.
Promotes
dev→main, publishing @ai_kit/core 1.9.0 to npm (via realease-core.yml).Includes #117: resilient structured output for non-OpenAI providers — deterministic key normalization + error-driven repair retry (both on by default, backward-compatible), plus the
shouldUseStructuredPipelinegate fix (type ?? name) that activates the pipeline for realOutput.object()usage.Validated live against Scaleway
gpt-oss-120bthrough the publicAgent.generateAPI.🤖 Generated with Claude Code