Hold a subscription's runs until its usage allowance resets
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start with subscription_problem() in secondshift/jobs/execution.py, failure_reason() in secondshift/runner/agent_image/agent.py, and FAILURE_SUMMARIES in secondshift/runs/execution/cli_agent.py. Use a real exhausted login in the dev stack to check whether Codex or Claude Code exposes a reset time in its events or error output. Done means the reset-time source and held-run behavior are decided; the issue does not yet define those decisions.
Written by the indexing model from the issue text.
Description
Problem
When a subscription's usage allowance runs out, every run on that login fails until the provider resets it.
What happens today:
- The run starts as usual.
subscription_problem()insecondshift/jobs/execution.pyblocks only a disconnected login, a sign-in refused at its last check, an owner who left, and themax_runs_per_daycap. - The CLI hits its limit. The agent image reports
AgentOutcome.QUOTA_EXHAUSTED(failure_reason()insecondshift/runner/agent_image/agent.py). - The run fails with "Subscription usage exhausted. Wait for your provider's allowance to reset, then start a new run." (
FAILURE_SUMMARIESinsecondshift/runs/execution/cli_agent.py). The usual notifications go out. - Nothing retries, and nothing falls back to a model API key.
- The next scheduled runs still start. Each one starts a container and fails the same way until the reset.
- We don't know the reset time, so the summary can't say when to retry.
Proposal
When a run ends with quota_exhausted, record when the login's allowance resets. Until then, hold that login's runs instead of starting them.
- Store the reset time on the login, like
last_check. - Make
subscription_problem()report the hold, so Models and the run pages show it. For example: "Usage resets at 3:00 PM." - Decide what a held run does. It could wait and start after the reset, or be skipped with a clear reason. Scheduled runs probably wait. Manual runs might ask.
- Put the reset time in the failure summary.
- Clear the hold early when a login check or a run succeeds.
- If no reset time is known, fall back to a short hold or today's behaviour.
Investigate first
Use a real exhausted login in the dev stack. Find out what Claude Code and Codex report when a limit is hit, and whether it includes a reset time.
- Codex writes
rate_limits(used_percent,resets_at, and 5-hour and weekly windows) to its session files. Our agent runscodex exec --ephemeral, so it writes none. Check whether the same data appears in--jsonevents or in the error text. - Claude Code has no known machine-readable source. Check its stream-json error events and result text.
- The agent image must keep returning only reasons and fixed fields, never raw CLI text. A reset time should be a parsed timestamp.
Related
- Per-login run cap: #187
- Login check on save: #196
- Confirm an expired sign-in with a check: #197. A check that ends in
quota_exhaustedproves the sign-in works. It doesn't block runs.
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- Avg merge
- 1h 9m
- Merged PRs (30d)
- 322
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from piotrekno1/second-shift
-
code-review secondshift
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
piotrekno1/second-shift#419 ·
Maintainers usually reply within 1 day
-
area: deployment
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
piotrekno1/second-shift#310 ·
Maintainers usually reply within 1 day
-
code-review secondshift
Difficulty 4/5 3-5 days Newbie friendliness 46/100
piotrekno1/second-shift#421 ·
Maintainers usually reply within 1 day
-
code-review secondshift
Difficulty 4/5 3-5 days Newbie friendliness 56/100
piotrekno1/second-shift#420 ·
Maintainers usually reply within 1 day
-
Fix failed-delivery retries on PostgreSQLPossibly taken @piotrekno1 claimed this today. Opencode-review fix-approved secondshift
Difficulty 3/5 1-2 days Newbie friendliness 35/100
piotrekno1/second-shift#418 ·
Maintainers usually reply within 1 day
All issues in piotrekno1/second-shift
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
area:cli area:security enhancement priority:medium size:small
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
RonaldHensbergen/composable-data-stack#1338 ·
Maintainers usually reply within 1 day
-
area:stdlib effort:S impact:med platform:linux type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
automated endpoint-dead needs-curation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
almanac-data/climate-almanac#139 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
UKGovernmentBEIS/inspect_ai#6695 · 1 comment ·
Maintainers usually reply within 1 day