[BUG] Non-interactive session incorrectly reports "session limit" despite 0% usage confirmed moments earlier (Pro plan, launchd/cron)

Status Open
Reported on v2.1.177
Maintainer reply None cached
Activity 0 comments · opened Aug 7, 2026

Description

When running Claude Code non-interactively via claude -p "..." from a launchd/cron
job on macOS, the process frequently exits within 5–10 minutes reporting
"You've hit your session limit · resets 5am (Asia/Tokyo)" — even when the
Claude.ai Usage screen was checked immediately beforehand (within ~1 hour)
and showed 0% usage for the current session.

No agent/task work appears to happen before the limit message: with explicit
start/end echo logging added around each sub-task (via the Task tool) and
sed -u used to force line-buffered log output (to rule out buffering as the
cause of "missing" logs), zero task-start log lines are written before the
limit error appears. This suggests the limit check is failing before any
actual work/token consumption occurs, rather than the session being
genuinely exhausted.

Manually re-running the identical script/prompt a few hours later (after the
stated reset time) completes successfully in ~8–9 minutes with full agent
output, using well under 100% of session capacity (~60-70%).

Steps to Reproduce

  1. Authenticate claude via claude login (Pro subscription, not API key)

on macOS.

  1. Create a script that sources env vars and calls:

claude --dangerously-skip-permissions -p "$PROMPT" where $PROMPT
instructs Claude to launch several parallel sub-agents via the Task tool.

  1. Schedule the script via launchd (or cron) to run at a fixed time

(e.g. 00:00 daily), with no other Claude Code usage after ~19:00 the
prior day.

  1. Confirm via the Claude.ai web Usage screen at ~22:00–23:00 that the

current session shows 0% usage.

  1. Observe the 00:00 scheduled run.

Expected Behavior

Given confirmed 0% usage ~1–2 hours prior, and no other usage in between,
the scheduled run should proceed normally (or at minimum should attempt the
requested work before determining a limit has been reached).

Actual Behavior

The run exits after 5–10 minutes with:
You've hit your session limit · resets 5am (Asia/Tokyo)
with no evidence (via explicit per-task logging) that any sub-agent/task
work was attempted. This has recurred repeatedly (roughly weekly) over
~7 weeks of daily scheduled runs, on days when usage was not manually
re-checked close to the scheduled run time. On days when usage was checked
via the web UI shortly before the scheduled run, the run has (usually)
succeeded — suggesting a possible desync between locally-cached session
state and server-side session state that a web UI check appears to
refresh.

Environment

  • Claude Code version: 2.1.177
  • Platform: Anthropic API / Pro subscription (claude login, not

ANTHROPIC_API_KEY)

  • OS: macOS (Apple Silicon)
  • Terminal/invocation: non-interactive, via launchd scheduled job

(claude --dangerously-skip-permissions -p "...")

  • Related: possibly connected to previously reported CLI/Web UI reset-time

mismatch issues.

Additional Notes

Happy to share full timestamped logs from multiple occurrences (with
sensitive tokens/paths redacted) if useful for investigation.

View original on GitHub ↗