Skip to content

fix(workers-ai-provider): preserve structured output schema name#562

Closed
slegarraga wants to merge 2 commits into
cloudflare:mainfrom
slegarraga:fix/workers-ai-json-schema-name
Closed

fix(workers-ai-provider): preserve structured output schema name#562
slegarraga wants to merge 2 commits into
cloudflare:mainfrom
slegarraga:fix/workers-ai-json-schema-name

Conversation

@slegarraga

Copy link
Copy Markdown
Contributor

Summary

  • wrap AI SDK structured-output schemas in the OpenAI-compatible json_schema envelope before sending them to Workers AI
  • preserve Output.object({ name, description }) on the request body, defaulting the schema name to response when not provided
  • add REST regression coverage for the request body sent by workers-ai-provider

Fixes #559.

Validation

  • corepack pnpm --filter workers-ai-provider exec vitest --watch=false test/structured-output.test.ts
  • corepack pnpm --filter workers-ai-provider type-check
  • corepack pnpm --filter workers-ai-provider test:ci
  • corepack pnpm exec oxfmt --check packages/workers-ai-provider/src/workersai-chat-language-model.ts packages/workers-ai-provider/test/structured-output.test.ts

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a406b61

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
workers-ai-provider Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@threepointone

Copy link
Copy Markdown
Collaborator

Thanks for this, @slegarraga — your diagnosis of #559 was correct, and the request-body regression test was a great instinct (we ended up adding similar wire-shape assertions).

We've resolved #559 a different way, so I'm closing this as superseded. Two pieces landed:

That's the main reason we went this route over the envelope approach in this PR — applying the OpenAI envelope to @cf/... requests would have changed the native wire contract. Combined, the partner failure you hit is fixed by the routing and the native gap is fixed by #576.

Really appreciate you digging in and filing both the issue and the fix. 🙏

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.

workers-ai-provider: response_format.json_schema missing name — breaks structured output on OpenAI partner models (e.g. openai/gpt-5.4-mini)

2 participants