Skip to content

fix: accept null Cloudflare reasoning fields - #134

Merged
stackbilt-admin merged 4 commits into
Stackbilt-dev:mainfrom
mikemikimike:fix/130-cloudflare-null-reasoning
Nov 6, 2026
Merged

stackbilt-admin merged 4 commits into
Stackbilt-dev:mainfrom
mikemikimike:fix/130-cloudflare-null-reasoning

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cloudflare Workers AI can return null for optional message.reasoning and message.reasoning_content fields. Treat those values as absent while preserving the generated message and rejecting other invalid field types.

Fixes #130
#130

The cloudflare-reasoning-null.json fixture is synthetic because #130 did not include a captured raw response payload.

Validation

  • npm test (792 passed)
  • npm run typecheck
  • npm run build
  • npm run test:worker-import
  • Package smoke: packed and installed the tarball; CommonJS and ESM imports passed, and all 33 JavaScript source maps contained embedded source.

@stackbilt-admin stackbilt-admin left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The fix is correct and as narrow as it should be. string-or-null still rejects numbers and objects (your second test checks numeric values), and joinReasoning already turns null into undefined, so no null reaches LLMResponse.reasoning. Both new tests fail when the schema change is reverted, so they guard the regression.

Two small changes before merge:

  1. Internal types: WorkersAIChoice.message.reasoning and reasoning_content in src/providers/cloudflare.ts are still typed string. Please make them string | null to match the schema and the existing content field. This has no runtime effect, but it keeps later code that reads these fields from assuming a string.
  2. Fixture provenance: #130 says the raw response wasn't captured, so cloudflare-reasoning-null.json is synthetic. Please say so in the PR description and/or a nearby test comment, rather than calling it live-shaped. If you later capture a real payload, we'd welcome it as a replacement.

Optional: add a case where both reasoning fields are null together, and a case where content: null comes with null reasoning.

Not in scope here: the same strict string schema exists for reasoning fields in the Groq, OpenAI and Cerebras adapters. That's tracked in #138, so this PR can stay Cloudflare-only.

CI is waiting on maintainer approval for fork PRs. We'll require normal CI to pass on the final commit before merging. The failing supply-chain check is a known repo-level problem unrelated to this PR, tracked in #137.

@stackbilt-admin
stackbilt-admin merged commit d899c46 into Stackbilt-dev:main Nov 6, 2026
2 checks passed
stackbilt-admin pushed a commit that referenced this pull request Nov 6, 2026
The #134 regression test triggered two SchemaDriftErrors in one test; the
degraded breaker then rejected the second request about 10% of the time.
Also cite release PR #141 in the issue-sweep checkpoint.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
stackbilt-admin added a commit that referenced this pull request Nov 6, 2026
Accept null Workers AI reasoning fields (#134, fixes #130). Bumps
package.json, package-lock.json and src/version.ts to 1.24.1, adds the
CHANGELOG entry, refreshes the issue-sweep checkpoint, and resets the
circuit breaker between the schema-drift cases in #134's regression test
so it no longer fails at random.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Live Workers AI responses with reasoning: null fail with SchemaDriftError, making Llama 3.3 fp8-fast unusable

2 participants