Skip to content

Grok model crashes with undefined.includes() error after Anthropic credit failure #12165

@MattCMilne

Description

@MattCMilne

Grok model crashes with "Cannot read properties of undefined (reading 'includes')"

Issue

After Anthropic API credits ran out, switching to Grok (xai/grok-4-1-fast-reasoning) now consistently throws a JavaScript error:

Cannot read properties of undefined (reading 'includes')

Timeline

  1. Anthropic credits expired → started getting similar undefined errors
  2. Switched to Grok → same "undefined.includes()" error appears
  3. Gateway restart → error persists
  4. Removed compat flags from Grok config → error persists
  5. Sonnet/Haiku work fine → no errors

Evidence

  • Sonnet (anthropic/claude-sonnet-4-5): ✅ Works perfectly
  • Haiku (anthropic/claude-3-5-haiku-latest): ✅ Works in cron jobs
  • Grok reasoning (xai/grok-4-1-fast-reasoning): ❌ Crashes with undefined error
  • Grok non-reasoning (xai/grok-4-1-fast-non-reasoning): ❌ Crashes in cron jobs

Root Cause Hypothesis

The Anthropic credit failure corrupted some internal model resolution state. Even after:

  • Refilling Anthropic credits
  • Restarting gateway multiple times
  • Removing Grok's compat flags (supportsDeveloperRole, supportsReasoningEffort)

The error persists when using ANY xAI model.

Gateway Logs

2026-02-08T22:15:50.007Z [agent:nested] session=agent:main:cron:23b5f86d-39e7-4236-979d-63e0592fe347 run=b232226c-1b3f-48bd-87a3-c9ab0b55aede channel=webchat Cannot read properties of undefined (reading 'includes')

Error appears in:

  • Main chat session when switching to Grok
  • Cron job isolated sessions using Grok non-reasoning

Config (Grok section)

"xai": {
  "baseUrl": "https://api.x.ai/v1",
  "apiKey": "XAI_API_KEY",
  "api": "openai-completions",
  "models": [
    {
      "id": "grok-4-1-fast-reasoning",
      "name": "Grok 4.1 Fast (Reasoning)",
      "api": "openai-completions",
      "reasoning": true,
      "input": ["text"],
      "cost": {
        "input": 0.2,
        "output": 0.5,
        "cacheRead": 0.05,
        "cacheWrite": 0.2
      },
      "contextWindow": 2000000,
      "maxTokens": 8192
    }
  ]
}

Environment

  • Clawdbot version: 2026.1.24-3 (885167d)
  • OS: macOS (arm64)
  • Node: v25.5.0
  • Auth: xai:manual token mode

Workaround

Switched to Sonnet as default, but this is burning credits faster. Grok is 15x cheaper ($0.20/$0.50 vs $3/$15 per M tokens).

Request

  1. Fix the undefined .includes() error when using xAI models
  2. Add better error handling/logging so we can see WHAT is undefined
  3. Ensure provider errors don't corrupt model resolution state

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions