Skip to content

release(core): @ai_kit/core 1.9.0 — resilient structured output - #118

Merged
Killian-Aidalinfo merged 2 commits into
mainfrom
dev
Jun 3, 2026
Merged

release(core): @ai_kit/core 1.9.0 — resilient structured output#118
Killian-Aidalinfo merged 2 commits into
mainfrom
dev

Conversation

@Killian-Aidalinfo

Copy link
Copy Markdown
Collaborator

Promotes devmain, 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 shouldUseStructuredPipeline gate fix (type ?? name) that activates the pipeline for real Output.object() usage.

Validated live against Scaleway gpt-oss-120b through the public Agent.generate API.

🤖 Generated with Claude Code

Killian-Aidalinfo and others added 2 commits June 3, 2026 22:04
…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
@Killian-Aidalinfo
Killian-Aidalinfo merged commit 6a5a494 into main Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant