openclaw - ✅(Solved) Fix [Bug]: onboard writes auth-profiles only to agents/main/, not to all configured agents [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#44571Fetched 2026-04-08 00:45:06
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

When running openclaw onboard with multiple agents configured in openclaw.json, the auth token (or tokenRef) is only written to ~/.openclaw/agents/main/agent/auth-profiles.json. It is not distributed to the other configured agents (e.g., agents/chief/, agents/developer/, agents/qa/, etc.).

This causes non-default agents to fall back to free/fallback models silently, since they have no auth credentials for the primary model provider.

Error Message

  • Other agents either have stale tokens (with error cooldowns) or no auth file at all

Root Cause

  • Only ~/.openclaw/agents/main/agent/auth-profiles.json gets the new tokenRef
  • Other agents either have stale tokens (with error cooldowns) or no auth file at all
  • Agents silently fall back to free fallback models (e.g., GLM 4.5 Air) without any warning to the user
  • The silent fallback is particularly confusing because the user thinks agents are using Sonnet/Opus but they're actually on a much weaker free model

Fix Action

Workaround

Manually copy the auth-profiles.json to all agent directories:

for agent in chief developer qa secretary lawyer writer experimenter; do
  mkdir -p ~/.openclaw/agents/$agent/agent
  cp ~/.openclaw/agents/main/agent/auth-profiles.json ~/.openclaw/agents/$agent/agent/
done
openclaw gateway start  # restart to pick up new tokens

PR fix notes

PR #44644: fix(onboard): sync api keys to sibling agents during onboarding

Description (problem / solution / changelog)

Summary

Fixes #44571 - Onboard writes auth-profiles only to agents/main/

Root Cause

The set*ApiKey functions in onboard-auth.credentials.ts only wrote credentials to a single agent directory, ignoring the syncSiblingAgents pattern that was already implemented for writeOAuthCredentials.

Fix

  1. Added syncSiblingAgents?: boolean option to ApiKeyStorageOptions type
  2. Created upsertAuthProfileWithSync helper function that follows the same pattern as writeOAuthCredentials:
    • Primary write to the specified agent dir must succeed
    • Sibling sync is best-effort (ignores individual failures)
  3. Updated all set*ApiKey functions to use the new helper
  4. Updated callers in auth-choice.apply.*.ts and onboard-non-interactive to pass syncSiblingAgents: true

Test plan

  • Test interactive onboarding with API key (Anthropic, OpenAI, Gemini)
  • Test non-interactive onboarding with --anthropic-api-key etc.
  • Verify credentials are written to all sibling agent directories
  • Verify sibling agent sync failure doesn't block primary onboarding

Changed files

  • src/commands/auth-choice.apply.anthropic.ts (modified, +4/-1)
  • src/commands/auth-choice.apply.api-providers.ts (modified, +4/-1)
  • src/commands/auth-choice.apply.openai.ts (modified, +4/-1)
  • src/commands/onboard-auth.credentials.ts (modified, +199/-90)
  • src/commands/onboard-non-interactive/local/auth-choice.api-key-providers.ts (modified, +1/-4)
  • src/commands/onboard-non-interactive/local/auth-choice.ts (modified, +4/-3)

Code Example

{
  "agents": {
    "list": [
      { "id": "chief", "default": true, "model": "anthropic/claude-opus-4-6" },
      { "id": "developer", "model": "anthropic/claude-sonnet-4-6" },
      { "id": "qa", "model": "anthropic/claude-opus-4-6" },
      { "id": "secretary", "model": "anthropic/claude-sonnet-4-6" },
      { "id": "lawyer", "model": "anthropic/claude-opus-4-6" },
      { "id": "writer", "model": "openrouter/z-ai/glm-4.5-air:free" },
      { "id": "experimenter", "model": "anthropic/claude-opus-4-6" }
    ]
  }
}

---

ls ~/.openclaw/agents/*/agent/auth-profiles.json

---

for agent in chief developer qa secretary lawyer writer experimenter; do
  mkdir -p ~/.openclaw/agents/$agent/agent
  cp ~/.openclaw/agents/main/agent/auth-profiles.json ~/.openclaw/agents/$agent/agent/
done
openclaw gateway start  # restart to pick up new tokens
RAW_BUFFERClick to expand / collapse

Summary

When running openclaw onboard with multiple agents configured in openclaw.json, the auth token (or tokenRef) is only written to ~/.openclaw/agents/main/agent/auth-profiles.json. It is not distributed to the other configured agents (e.g., agents/chief/, agents/developer/, agents/qa/, etc.).

This causes non-default agents to fall back to free/fallback models silently, since they have no auth credentials for the primary model provider.

Steps to reproduce

  1. Configure 7 agents in openclaw.json:
{
  "agents": {
    "list": [
      { "id": "chief", "default": true, "model": "anthropic/claude-opus-4-6" },
      { "id": "developer", "model": "anthropic/claude-sonnet-4-6" },
      { "id": "qa", "model": "anthropic/claude-opus-4-6" },
      { "id": "secretary", "model": "anthropic/claude-sonnet-4-6" },
      { "id": "lawyer", "model": "anthropic/claude-opus-4-6" },
      { "id": "writer", "model": "openrouter/z-ai/glm-4.5-air:free" },
      { "id": "experimenter", "model": "anthropic/claude-opus-4-6" }
    ]
  }
}
  1. Run openclaw onboard and authenticate with Anthropic (setup-token via env var reference)

  2. Check auth files:

ls ~/.openclaw/agents/*/agent/auth-profiles.json

Expected behavior

onboard should write auth-profiles.json to all agent directories listed in agents.list, not just agents/main/.

Alternatively, the gateway should resolve auth from a single canonical location (e.g., agents/main/agent/auth-profiles.json) when an agent-specific auth file is missing, so agents inherit the default auth automatically.

Actual behavior

  • Only ~/.openclaw/agents/main/agent/auth-profiles.json gets the new tokenRef
  • Other agents either have stale tokens (with error cooldowns) or no auth file at all
  • Agents silently fall back to free fallback models (e.g., GLM 4.5 Air) without any warning to the user
  • The silent fallback is particularly confusing because the user thinks agents are using Sonnet/Opus but they're actually on a much weaker free model

Workaround

Manually copy the auth-profiles.json to all agent directories:

for agent in chief developer qa secretary lawyer writer experimenter; do
  mkdir -p ~/.openclaw/agents/$agent/agent
  cp ~/.openclaw/agents/main/agent/auth-profiles.json ~/.openclaw/agents/$agent/agent/
done
openclaw gateway start  # restart to pick up new tokens

Environment

  • OpenClaw version: 2026.3.8
  • OS: Ubuntu Linux 22.04
  • Auth method: Anthropic setup-token (env var reference)
  • Agent count: 7

Related

  • #28293 — Non-default agents get 401 with same token (similar symptom, different root cause)
  • #38336 — OAuth renewal doesn't update provisioned copy (related auth distribution gap)

extent analysis

Fix Plan

To distribute the auth token to all configured agents, we need to modify the openclaw onboard command to write the auth-profiles.json file to each agent directory.

Here are the steps:

  • Modify the onboard function to iterate over all agents in openclaw.json and write the auth-profiles.json file to each agent directory.
  • Update the gateway to resolve auth from a single canonical location (e.g., agents/main/agent/auth-profiles.json) when an agent-specific auth file is missing.

Example code snippet in Python:

import json
import os

def onboard(agents_config, auth_token):
    # Iterate over all agents and write auth-profiles.json
    for agent in agents_config['list']:
        agent_dir = os.path.join('~/.openclaw/agents', agent['id'], 'agent')
        auth_file = os.path.join(agent_dir, 'auth-profiles.json')
        os.makedirs(agent_dir, exist_ok=True)
        with open(auth_file, 'w') as f:
            json.dump({'tokenRef': auth_token}, f)

def gateway_start(agents_config):
    # Resolve auth from a single canonical location when agent-specific auth file is missing
    canonical_auth_file = os.path.join('~/.openclaw/agents/main/agent/auth-profiles.json')
    for agent in agents_config['list']:
        agent_dir = os.path.join('~/.openclaw/agents', agent['id'], 'agent')
        auth_file = os.path.join(agent_dir, 'auth-profiles.json')
        if not os.path.exists(auth_file):
            # Copy canonical auth file to agent directory
            with open(canonical_auth_file, 'r') as f:
                with open(auth_file, 'w') as f2:
                    f2.write(f.read())

# Example usage:
agents_config = {
    'list': [
        {'id': 'chief', 'default': True, 'model': 'anthropic/claude-opus-4-6'},
        {'id': 'developer', 'model': 'anthropic/claude-sonnet-4-6'},
        # ...
    ]
}
auth_token = 'your_auth_token_here'
onboard(agents_config, auth_token)
gateway_start(agents_config)

Verification

To verify that the fix worked, run the following steps:

  • Run openclaw onboard with multiple agents configured in openclaw.json.
  • Check that the auth-profiles.json file is written to each agent directory using ls ~/.openclaw/agents/*/agent/auth-profiles.json.
  • Restart the gateway using openclaw gateway start.
  • Verify that all agents are using the correct auth token by checking the gateway logs or using a tool like curl to test API requests.

Extra Tips

  • Make sure to update the `

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

onboard should write auth-profiles.json to all agent directories listed in agents.list, not just agents/main/.

Alternatively, the gateway should resolve auth from a single canonical location (e.g., agents/main/agent/auth-profiles.json) when an agent-specific auth file is missing, so agents inherit the default auth automatically.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: onboard writes auth-profiles only to agents/main/, not to all configured agents [1 pull requests, 1 participants]