Skip to content

fix(openclaw): handle object format for agents.defaults.model #176

@HalAssistant

Description

@HalAssistant

Summary

resolveOpenClawGatewayProvider() fails when OpenClaw uses the current config schema where agents.defaults.model is an object with {primary, fallbacks} instead of a plain string.

Environment

  • ClawVault: v3.3.0
  • OpenClaw: 2026.3.x (current)
  • Node: v22.x

Steps to Reproduce

  1. Configure OpenClaw with the current schema:
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "anthropic/claude-opus-4-5-20251101",
        "fallbacks": []
      }
    }
  },
  "gateway": {
    "port": 18789,
    "auth": { "token": "..." },
    "http": {
      "endpoints": {
        "chatCompletions": { "enabled": true }
      }
    }
  }
}
  1. Set ClawVault to use provider: openclaw in .clawvault.json:
{
  "observe": {
    "provider": "openclaw"
  }
}
  1. Run any command that uses LLM (e.g., clawvault maintain)

Expected Behavior

ClawVault detects the OpenClaw gateway provider and uses it for LLM completions.

Actual Behavior

resolveOpenClawGatewayProvider() throws an exception and returns null, causing workers to fall back to heuristic mode.

Error: raw.agents?.defaults?.model?.trim is not a function

Root Cause

In src/lib/llm-provider.ts, line ~31:

const defaultModel = raw.agents?.defaults?.model?.trim() || DEFAULT_MODELS.openclaw;

This assumes agents.defaults.model is a string, but OpenClaw's current schema uses:

{
  primary: "anthropic/claude-opus-4-5-20251101",
  fallbacks: []
}

Calling .trim() on an object throws.

Suggested Fix

const modelValue = raw.agents?.defaults?.model;
const defaultModel = (typeof modelValue === 'string' 
  ? modelValue.trim() 
  : modelValue?.primary?.trim()) 
  || DEFAULT_MODELS.openclaw;

This handles both the legacy string format and the current object format.

Workaround

Manually patch dist/chunk-DVOUSOR3.js line 31 with the fix above.

Related

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