Skip to content

Agent models.json not synced from global openclaw.json config #22747

Description

@1960697431

Bug Description

When updating model providers in the global openclaw.json configuration, the changes are not automatically synced to individual agent models.json files. This causes agents to not see newly added models/providers.

Problem Context

OpenClaw has two levels of model configuration:

  1. Global config: ~/.openclaw/openclaw.jsonmodels.providers
  2. Per-agent config: ~/.openclaw/agents/{agentId}/agent/models.jsonproviders

The global config is the source of truth, but agent configs are not automatically updated when the global config changes.

Real-world Impact

My case:

  • Fixed gateway config issue (invalid apiKeys section + missing alibaba provider config)
  • Updated openclaw.json with correct alibaba provider configuration
  • Gateway restarted successfully
  • But main agent still couldn't see the qwen3.5-plus model
  • Other agents (worker-exec, worker-review) also missing the alibaba provider in their models.json

Root cause:

global openclaw.json: { minimax, zai, kimi-coding, alibaba } ✅
agents/main/agent/models.json: { minimax, zai, kimi-coding, alibaba } ✅ (manually fixed)
agents/worker-exec/agent/models.json: { minimax, zai } ❌ (missing alibaba, kimi-coding)
agents/worker-review/agent/models.json: { minimax, zai } ❌ (missing alibaba, kimi-coding)

Expected Behavior

When running openclaw gateway restart (or any config change command), the system should:

  1. Validate global config ✅
  2. Auto-sync model providers to all agent models.json files ❌ (missing)
  3. Restart gateway with updated config

Current Workaround

Manual sync required:

# Write a custom script to copy providers from global to each agent
python3 << 'EOF'
import json, os
with open('~/.openclaw/openclaw.json') as f:
    global_config = json.load(f)
global_providers = global_config['models']['providers']
for agent_id in os.listdir('~/.openclaw/agents'):
    models_json = f'~/.openclaw/agents/{agent_id}/agent/models.json'
    if os.path.exists(models_json):
        with open(models_json) as f:
            agent_config = json.load(f)
        agent_config['providers'] = global_providers.copy()
        with open(models_json, 'w') as f:
            json.dump(agent_config, f, indent=2)
EOF

Proposed Solutions

Option 1: Auto-sync on gateway restart (Recommended)

Add automatic sync in openclaw gateway restart command to update all agent models.json files from global config.

Option 2: New CLI command

openclaw agents sync-models

Option 3: Remove per-agent models.json

Have agents read directly from global config at runtime (may break agent isolation design).

Environment

  • OpenClaw version: 2026.2.19-2
  • OS: macOS
  • Gateway mode: local

Additional Context

This is a design gap - the agent isolation model expects each agent to have its own config, but model providers should be managed centrally and propagated to agents automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions