Skip to content

Accept null reasoning fields in Groq, OpenAI and Cerebras adapters #138

Open

Description

@stackbilt-admin

Follow-up to #130 and the Cloudflare fix proposed in #134.

Problem

#130 reports a live failure on Cloudflare. For the providers below this is a suspected compatibility gap, not an observed failure: their current schemas would reject an explicit null, but we have no live failures from them. These response schemas still declare reasoning fields as type: 'string', optional: true:

  • src/providers/groq.ts: message.reasoning, message.reasoning_content
  • src/providers/openai.ts: message.reasoning, message.reasoning_content
  • src/providers/cerebras.ts: message.reasoning, message.reasoning_content, message.thinking_content

OpenAI-compatible backends (vLLM-style servers in particular) can return these keys as explicit null. If these providers ever do, validation would throw SchemaDriftError. With fallback enabled, the error is hidden by switching to another provider; without fallback, the call fails.

Fix

Change each field to string-or-null, as #134 proposes for Cloudflare. The code after validation already handles null, because every adapter goes through joinReasoning. Update the matching internal interface types to string | null.

Tests

For each adapter:

  • a null reasoning field is accepted, and LLMResponse.reasoning is undefined;
  • a non-string, non-null value (for example 42) still throws SchemaDriftError.

Release

Patch.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions