openclaw - 💡(How to fix) Fix Claude CLI live session returns false 'out of extra usage' errors while subscription has capacity

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…

When OpenClaw runs Claude CLI as a live session subprocess (--input-format stream-json --output-format stream-json), the Claude CLI intermittently returns 400 invalid_request_error: "You're out of extra usage" — even though the subscription has available capacity. Direct Claude CLI calls (claude --print) work fine at the exact same time, using the same credentials and same subscription.

Error Message

400 {"type":"error","error":{"type":"invalid_request_error","message":"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."}}

  • Direct claude --print calls work during the error period (same token, same subscription)

Error timeline (12 days of data)

All failed sessions complete in 550-920ms. Successful calls take 10-200+ seconds. This suggests the Claude CLI subprocess returns the error instantly without making a real API call — possibly from cached internal state.

3. The error correlates with long-running live sessions

OpenClaw keeps Claude CLI alive as a persistent subprocess using --input-format stream-json --output-format stream-json. The process can run for days. The error accumulates over time. Fresh processes don't have the issue. "stopReason": "error", "errorMessage": "400 {"type":"error","error":{"type":"invalid_request_error","message":"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."}}" 2. Is there a way to force the live session subprocess to restart after a billing error, instead of keeping the same process alive? 3. Could a rate-limit error on one model (e.g., Opus) in a live session affect calls to other models (e.g., Sonnet) in the same session?

Root Cause

When OpenClaw runs Claude CLI as a live session subprocess (--input-format stream-json --output-format stream-json), the Claude CLI intermittently returns 400 invalid_request_error: "You're out of extra usage" — even though the subscription has available capacity. Direct Claude CLI calls (claude --print) work fine at the exact same time, using the same credentials and same subscription.

Fix Action

Workaround

Restarting the gateway clears the stale state:

systemctl --user restart openclaw-gateway.service

But this is not a long-term solution — it kills all active sessions and requires manual intervention.

Code Example

400 {"type":"error","error":{"type":"invalid_request_error","message":"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."}}

---

Date       | OK calls | FAIL calls | Fail rate
2026-05-15 |        8 |          3 |       27%
2026-05-16 |        0 |          3 |      100%
2026-05-17 |        0 |          2 |      100%
2026-05-18 |        2 |          3 |       60%
2026-05-19 |        5 |          0 |        0%
2026-05-20 |       27 |          5 |       16%
2026-05-21 |       11 |          7 |       39%
2026-05-22 |       16 |          1 |        6%
2026-05-23 |        0 |          2 |      100%100% failure from here
2026-05-24 |        0 |          2 |      100%
2026-05-25 |        0 |          4 |      100%
2026-05-26 |        0 |         26 |      100%

---

{
  "type": "model.completed",
  "ts": "2026-05-25T23:33:01.128Z",
  "data": {
    "messagesSnapshot": [{
      "role": "assistant",
      "api": "anthropic-messages",
      "provider": "anthropic",
      "model": "claude-sonnet-4-6",
      "usage": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0},
      "stopReason": "error",
      "errorMessage": "400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"You're out of extra usage. Add more at claude.ai/settings/usage and keep going.\"}}"
    }]
  }
}

---

systemctl --user restart openclaw-gateway.service

---

{
  "auth": {
    "cooldowns": {
      "billingBackoffHours": 0.5,
      "billingBackoffHoursByProvider": {
        "claude-cli": 0.5
      },
      "billingMaxHours": 1
    },
    "profiles": {
      "anthropic:default": {
        "provider": "claude-cli",
        "mode": "oauth"
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "claude-cli/claude-sonnet-4-6",
        "fallbacks": ["claude-cli/claude-haiku-4-5"]
      },
      "contextTokens": 128000,
      "thinkingDefault": "medium"
    }
  }
}
RAW_BUFFERClick to expand / collapse

Bug: Claude CLI live session returns false "out of extra usage" errors

Summary

When OpenClaw runs Claude CLI as a live session subprocess (--input-format stream-json --output-format stream-json), the Claude CLI intermittently returns 400 invalid_request_error: "You're out of extra usage" — even though the subscription has available capacity. Direct Claude CLI calls (claude --print) work fine at the exact same time, using the same credentials and same subscription.

Environment

  • OpenClaw gateway: 2026.4.26
  • Claude CLI: 2.1.100 (Claude Code)
  • Node.js: v22.22.1
  • OS: Linux 6.8.0-110-generic (x86_64)
  • Subscription: Max x20 (rateLimitTier: default_claude_max_20x)
  • Auth mode: OAuth (claude-cli provider)
  • Extra usage: NOT enabled (hasExtraUsageEnabled: None)

Reproduction

  1. Configure an agent with claude-cli/claude-sonnet-4-6 as primary model
  2. Agent has ~45 tools, ~18K token system prompt
  3. Let the agent run for several hours via Telegram (handling user messages + cron tasks)
  4. After some period, ALL API calls start returning:
    400 {"type":"error","error":{"type":"invalid_request_error","message":"You're out of extra usage. Add more at claude.ai/settings/usage and keep going."}}
  5. At the same time, running claude --print --model claude-sonnet-4-6 "say ok" directly works perfectly

Evidence that limits are NOT exhausted

  • Direct claude --print calls work during the error period (same token, same subscription)
  • User continues using Claude Code CLI interactively — no issues
  • claude.ai usage dashboard shows <20% of 5-hour limit consumed
  • After restarting openclaw-gateway (which kills and respawns the Claude CLI subprocess), the agent immediately works again

Error timeline (12 days of data)

Date       | OK calls | FAIL calls | Fail rate
2026-05-15 |        8 |          3 |       27%
2026-05-16 |        0 |          3 |      100%
2026-05-17 |        0 |          2 |      100%
2026-05-18 |        2 |          3 |       60%
2026-05-19 |        5 |          0 |        0%
2026-05-20 |       27 |          5 |       16%
2026-05-21 |       11 |          7 |       39%
2026-05-22 |       16 |          1 |        6%
2026-05-23 |        0 |          2 |      100%  ← 100% failure from here
2026-05-24 |        0 |          2 |      100%
2026-05-25 |        0 |          4 |      100%
2026-05-26 |        0 |         26 |      100%

Pattern: intermittent failures for a week, then 100% failure for 4 days until gateway restart.

Key observations

1. Failed calls complete in <1 second

All failed sessions complete in 550-920ms. Successful calls take 10-200+ seconds. This suggests the Claude CLI subprocess returns the error instantly without making a real API call — possibly from cached internal state.

2. Gateway restart fixes the issue immediately

After systemctl --user restart openclaw-gateway.service, the agent processes requests successfully on the very first attempt. This confirms the problem is in the Claude CLI subprocess's runtime state, not in the account/subscription/token.

3. The error correlates with long-running live sessions

OpenClaw keeps Claude CLI alive as a persistent subprocess using --input-format stream-json --output-format stream-json. The process can run for days. The error accumulates over time. Fresh processes don't have the issue.

4. Multiple cron tasks may contribute

The agent has 20+ cron jobs, some using claude-opus-4-6. It's possible that a transient rate limit on one model (e.g., Opus) poisons the entire live session, causing subsequent calls on other models (Sonnet) to also fail.

Trajectory excerpt (failed call)

{
  "type": "model.completed",
  "ts": "2026-05-25T23:33:01.128Z",
  "data": {
    "messagesSnapshot": [{
      "role": "assistant",
      "api": "anthropic-messages",
      "provider": "anthropic",
      "model": "claude-sonnet-4-6",
      "usage": {"input":0,"output":0,"cacheRead":0,"cacheWrite":0,"total":0},
      "stopReason": "error",
      "errorMessage": "400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"You're out of extra usage. Add more at claude.ai/settings/usage and keep going.\"}}"
    }]
  }
}

Note: usage is all zeros — no tokens were consumed. The call was rejected before processing.

Questions for the OpenClaw team

  1. Does the Claude CLI live session cache billing/rate-limit state internally? If a transient 400 or 429 is received, does it block all subsequent calls without retrying the API?
  2. Is there a way to force the live session subprocess to restart after a billing error, instead of keeping the same process alive?
  3. Could a rate-limit error on one model (e.g., Opus) in a live session affect calls to other models (e.g., Sonnet) in the same session?
  4. Is there a --no-cache-billing-state flag or similar option to prevent this behavior?

Workaround

Restarting the gateway clears the stale state:

systemctl --user restart openclaw-gateway.service

But this is not a long-term solution — it kills all active sessions and requires manual intervention.

Config (relevant section)

{
  "auth": {
    "cooldowns": {
      "billingBackoffHours": 0.5,
      "billingBackoffHoursByProvider": {
        "claude-cli": 0.5
      },
      "billingMaxHours": 1
    },
    "profiles": {
      "anthropic:default": {
        "provider": "claude-cli",
        "mode": "oauth"
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "claude-cli/claude-sonnet-4-6",
        "fallbacks": ["claude-cli/claude-haiku-4-5"]
      },
      "contextTokens": 128000,
      "thinkingDefault": "medium"
    }
  }
}

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…

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 - 💡(How to fix) Fix Claude CLI live session returns false 'out of extra usage' errors while subscription has capacity