Skip to content

Mark headless runs stopped by a plan usage limit - #21

Merged
simoncrypta merged 1 commit into
masterfrom
usage-limit-reason
Oct 31, 2026
Merged

simoncrypta merged 1 commit into
masterfrom
usage-limit-reason

Conversation

@simoncrypta

@simoncrypta simoncrypta commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

When a headless bstack or autopilot run exits nonzero on a plan usage limit, the runner adds the optional field reason: "usage-limit" to .bercail/handoff-result.json, so Shep can propose a rerun on another plan. status, summary and session_id are unchanged. Nothing reruns or switches plans.

  • ChatGPT: session error type provider.chatgpt-limit, or code subscription_sharing_usage_limit_exceeded in the error body.
  • Claude: the limit and out-of-credits sentences Claude Code composes (e.g. "You've hit your 5-hour limit"), read from the JSON error event, or from non-JSON stderr when the process exits before one.
  • A plain 429 / provider.rate-limit is not a usage limit (xAI's weekly-limit body is unverified).

Docs: README, docs/bstack/07-handoff.md, skills/handoff/SKILL.md.

Tests

Review

Only the Grok council reviewer ran (two rounds); the Claude and GPT reviewers were at their plan usage limits. A manual review fixed one bug: the stderr fallback piped jq into grep -q under pipefail, so on a long log grep's early exit SIGPIPE'd jq and the match was lost (reproduced with a 20k-line log). It now uses grep -E ... >/dev/null.

Overlap

When a headless bstack or autopilot run exits nonzero on a ChatGPT or Claude plan limit, the runner adds reason: "usage-limit" to .bercail/handoff-result.json. status, summary and session_id are unchanged, a plain 429 is not a usage limit, and nothing reruns or switches plans. Adds tests/usage_limit_reason_test.sh (stubs only).
@simoncrypta
simoncrypta merged commit e22ef36 into master Oct 31, 2026
2 checks passed
@simoncrypta
simoncrypta deleted the usage-limit-reason branch November 1, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant