Skip to content

[Bug]: Non-default agents get 401 Missing scopes: model.request with OpenAI Codex OAuth — same token works for default agent #28293

Description

@aespinosa89

Summary

Non-default agents (engineer, strategist) fail with 401 Missing scopes: model.request when attempting to use OpenAI Codex models via OAuth. The default agent (main) works perfectly with the exact same OAuth token.

This breaks both:

  • sessions_spawn (main → engineer/strategist)
  • sessions_send (agent-to-agent communication)
  • Cron jobs with agentId: "engineer" or agentId: "strategist" when the model is set to openai-codex/*

Steps to reproduce

  1. Configure 3 agents in openclaw.json:
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "openai-codex/gpt-5.3-codex"
      }
    },
    "list": [
      { "id": "main", "default": true, "model": "openai-codex/gpt-5.3-codex" },
      { "id": "engineer", "model": "openai-codex/gpt-5.3-codex", "agentDir": "..." },
      { "id": "strategist", "model": "openai-codex/gpt-5.2", "agentDir": "..." }
    ]
  }
}
  1. Complete OpenAI Codex OAuth flow (works — main agent uses models successfully)

  2. Enable agent-to-agent communication:

{
  "tools": {
    "agentToAgent": {
      "enabled": true,
      "allow": ["main", "engineer", "strategist"]
    }
  }
}
  1. From main, run sessions_spawn targeting engineer or strategist

  2. Result: Non-default agents immediately fail with:

401 Missing scopes: model.request

### Expected behavior

All agents should be able to use OpenAI Codex models since the OAuth flow was completed and the token is shared across all agent auth stores.




### Actual behavior


- `main` (default): ✅ Works — `errorCount: 0`, uses `openai-codex/gpt-5.3-codex` successfully
- `engineer`: ❌ Fails — `errorCount: N`, `failureCounts: { "auth": N }`
- `strategist`: ❌ Fails — `errorCount: N`, `failureCounts: { "auth": N }`

### OpenClaw version

2026.2.26 (beta channel)

### Operating system

macOS

### Install method

npm global

### Logs, screenshots, and evidence

```shell
ll three agents have **identical** OAuth tokens in their `auth-profiles.json` (same JWT, same refresh token, same accountId). Decoding the JWT payload shows:


{
  "scp": ["openid", "profile", "email", "offline_access"],
  "client_id": "app_EMoamEEZ33f0CkXaXp7hrann",
  "chatgpt_plan_type": "pro"
}


The `model.request` scope is **not** present in the JWT. However, the **default agent uses this same token successfully**, suggesting the runtime handles the token differently for the default agent.

### What We Tried (all failed)

1. **Forced token refresh** — Set `expires: 1` in engineer/strategist `auth-profiles.json` to trigger refresh. Token refreshed (new JWT, new refresh_token) but still lacks `model.request` scope. Default agent continued working.

2. **Deleted auth-profiles.json** — Removed `auth-profiles.json` from `agents/engineer/agent/` and `agents/strategist/agent/` to trigger the fallback inheritance mechanism. Files were regenerated but the 401 persists.

3. **Reset error counters** — Cleared `errorCount`, `failureCounts`, and `cooldownUntil` from usageStats. Agents retried but immediately failed again.

4. **CLI re-authentication attempts:**
   - `openclaw models auth login --agent engineer --provider openai-codex` → `Unknown provider 'openai-codex'. Loaded providers: minimax-portal`
   - `openclaw models auth setup-token --agent engineer --provider openai-codex` → `Only --provider anthropic is supported`
   - `openclaw models auth add --agent engineer` → Only shows Anthropic option
   - `openclaw onboard --agent engineer` → `unknown option '--agent'`

### Suspected Root Cause

The runtime appears to handle the default agent's OAuth token with a different code path that either:
- Adds the `model.request` scope during the API request
- Uses a different authentication mechanism (not just the bearer token)
- Has a scope bypass for the default agent

This is likely related to **Issue #13964** (isolated cron jobs use wrong agent's auth config) and **PR #13983** (fix auth config resolution for isolated agents), which does not appear to be included in version 2026.2.26.

Impact and severity

Multi-agent setups are fundamentally broken with OpenAI Codex as sole provider. Any user running 2+ agents on OpenAI OAuth cannot use sessions_spawn, sessions_send, or cron jobs targeting non-default agents without hitting 401.
No CLI workaround exists. Every openclaw models auth subcommand either doesn't support OpenAI Codex or doesn't support per-agent targeting. Users are stuck.
Forced fallback to non-OpenAI providers. Non-default agents can only function by falling back to kimi-coding, deepseek, or other providers — defeating the purpose of configuring OpenAI as the primary model.
Agent-to-agent communication is dead on arrival. agentToAgent was enabled specifically to allow inter-agent coordination, but it's useless if spawned agents can't make a single model call.
Silent degradation. Cron jobs for non-default agents silently fall back to fallback providers without alerting the user, leading to unexpected model quality differences across agents.

Additional information

What We Tried (all failed)

Forced token refresh — Set expires: 1 in engineer/strategist auth-profiles.json to trigger refresh. Token refreshed (new JWT, new refresh_token) but still lacks model.request scope. Default agent continued working.
Deleted auth-profiles.json — Removed auth-profiles.json from agents/engineer/agent/ and agents/strategist/agent/ to trigger the fallback inheritance mechanism. Files were regenerated but the 401 persists.
Reset error counters — Cleared errorCount, failureCounts, and cooldownUntil from usageStats. Agents retried but immediately failed again.
CLI re-authentication attempts:

openclaw models auth login --agent engineer --provider openai-codex → Unknown provider 'openai-codex'. Loaded providers: minimax-portal
openclaw models auth setup-token --agent engineer --provider openai-codex → Only --provider anthropic is supported
openclaw models auth add --agent engineer → Only shows Anthropic option
openclaw onboard --agent engineer → unknown option '--agent'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked 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