Skip to content

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

Closed

Description

@stackbilt-admin

Problem

A real Workers AI response from @cf/meta/llama-3.3-70b-instruct-fp8-fast fails the package's envelope validation, so a valid completion becomes an error:

SchemaDriftError: Response schema drift at choices[0].message.reasoning: expected string, got null

Reproduction

@stackbilt/[email protected], in a deployed Worker with a real AI binding, on 2026-10-31:

const llm = new LLMProviders({
  cloudflare: { ai: env.AI, maxRetries: 0 },
  fallbackRules: [],
  stateScope: 'client',
});
await llm.generateResponse({
  model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast',
  maxTokens: 20,
  temperature: 0,
  messages: [{ role: 'user', content: 'Reply with the word ready.' }],
});

In the same run, @cf/zai-org/glm-5.3-flash and @cf/openai/gpt-oss-20b succeeded.

Likely cause

src/providers/cloudflare.ts:52-53 declares:

{ path: 'message.reasoning', type: 'string', optional: true },
{ path: 'message.reasoning_content', type: 'string', optional: true },

It looks like optional accepts a missing field but not an explicit null, and Workers AI appears to return null for models with no reasoning. I inferred this from the error text and the schema, and did not capture the raw response.

Why it matters

The catalog lists this model as active, and routes it for cost-effective, balanced, high-performance, and tool-calling use. It's also on Cloudflare's JSON mode list. With other providers configured, the failure would presumably trigger fallback, which hides it and may send the request to another vendor. With fallback off, the model can't be used.

Expected

Treat null as absent for optional response fields, and add a live-shaped fixture for this response. Other OpenAI-compatible adapters with the same field may need the same check.

Scope

One deployed call on each of three models. Mocked tests can't show this, since they don't reproduce the live response shape. Our project recorded it as an M2 finding and is evaluating the other two models for now.

Activity

  1. added
    bug
    P1-high
    on Oct 31, 2026
  2. added a commit that references this issue on Nov 6, 2026
    4aecbd0
  3. added a commit that references this issue on Nov 7, 2026
    d899c46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-highbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions