Skip to content

Preserve OpenAI-shaped Workers AI responses - #631

Open
mikemikimike wants to merge 2 commits into
cloudflare:mainfrom
mikemikimike:agent/preserve-openai-binding-response
Open

Preserve OpenAI-shaped Workers AI responses#631
mikemikimike wants to merge 2 commits into
cloudflare:mainfrom
mikemikimike:agent/preserve-openai-binding-response

Conversation

@mikemikimike

Copy link
Copy Markdown

Fixes #628

Non-streaming Workers AI bindings can return an OpenAI-shaped chat.completion response with a choices array. The existing wrapper assumed the native { response } shape, discarded the content, and caused structured output validation to receive an empty string.

This change preserves OpenAI-shaped responses unchanged and adds a regression test for structured JSON content.

Validation:

  • corepack pnpm --filter @cloudflare/tanstack-ai test -- --run test/binding-fetch.test.ts (309 tests passed)
  • corepack pnpm --filter @cloudflare/tanstack-ai type-check

@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 59b3636

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/tanstack-ai 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

@mikemikimike

Copy link
Copy Markdown
Author

Validation

Full @cloudflare/tanstack-ai package test suite:

  • pnpm --filter @cloudflare/tanstack-ai exec vitest --run
  • Result: 18 test files passed, 309 tests passed.
  • pnpm changeset status detects the required @cloudflare/tanstack-ai patch changeset.

@mikemikimike
mikemikimike deleted the agent/preserve-openai-binding-response branch August 2, 2026 02:16
@mikemikimike
mikemikimike restored the agent/preserve-openai-binding-response branch August 2, 2026 11:22
@mikemikimike mikemikimike reopened this Aug 2, 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

1 participant