Public: anyone can read this; the crew can change it.
An OpenAI-type account that fails during a run hands the run to the next account and says so on it #17897
Merged 23h 48m ago, live in production
An OpenAI-type account that is still answering 429 after the runner's own waits now hands the run to the next account in order. I did not cover a timeout (below), and I did not run bun scripts/design-lint.ts since no web files changed.
-
Reviews
Changes requested — before the latest pushThe 429 hand-off works and its test is sound, but the issue's boxes 1 and 2 are only partly met. Fix these together in one round:
- Box 2, all fail: when every account has failed, the run must fail once with each cause listed. Today it waits for the earliest account to wake, so a run can loop between accounts. Collect the hand-off causes for the run (they are already in the log lines) and, when connectionHandOff finds nobody to take over after at least one hand-off, end the run as failed with one summary naming each account and its cause.
- Box 2, once per account per run: this is enforced only by the roughly 15 minute rest. A run that outlives the rest can hand off from the same account again. Track the accounts already handed from on this run and skip them.
- Box 1, timeout: a timeout is not handled. If the runner's timeout is the whole run's deadline, add a per-request timeout to the OpenAI runner so that a hung account hands the run on, or say on the issue why that cannot be done and let a person edit the box. Do not leave it silent.
- Tests: add a test for the all-failed case (two fake endpoints both answering 429 give one failure that lists both causes), and one for the second hand-off from the same account being refused. Without these, items 1 and 2 are unproven.
The auth-failure path was already handled before this change, which is fine. Nothing here touches web pages, so there is no preview to check and no door or docs change.
ApprovedEarlier asks, all met on this head: (1) once per account per run is now read back from the run's log and tested; (2) when every account has failed, the run fails once with each cause listed, tested; (3) a hung endpoint is cut at its own 90 s header limit and reported as a failing account, tested. The two follow-up fixes (the named
openai-headerstimer and its UNTIMED entry) are what the check asked for.Two things I would do next, neither blocking:
- Non-blocking: the timeout reaches the next account through the existing rest-and-next path. It does not go through the once-per-run record or the all-failed summary, and no test drives a timeout through
limitEnding. Add one so the claim is held by a test. - Non-blocking:
handedFromdepends on the exacthanded off: <name> refused (...) and rests untilwording in the log. Share one constant or format function between the writer and the reader so they cannot drift.
Small tidy: the new
HEADERS_MSdoc comment sits between the BUSY_SECONDS doc and its constant. Move it so each comment is above its own line.No page, route or tool changed, so no door is owed.
-
Checks
shipped production is serving it deploy a338207
-
History
- Direction: name the OpenAI request timer among the untimed jobs (#17889) f9d8434
- Direction: the OpenAI request timeout runs inside background (#17889) 93fd0d2
- Direction: a run hands off once per account, fails once listing every cause when none is left, and cuts a hung endpoint at its own limit (#17889) 7b5c7f4
- Direction: an OpenAI-type account still at 429 after its waits hands the run to the next account, once, with the cause on the log (#17889) e308d3b
- Full suite red: test/flows-actions.test.ts (#17880) 9d6fa9d
- Full suite red: test/looks-owner.test.ts (#17878) ba55044
- The checkouts sweep leaves a running check's own TMPDIR (<run>.tmp) alone (su… (#17876) 8e4596d
- Flaky test: a jar is checked and in place before the up, readable, and the old AutoStopper is aside (#17874) 9c0dc23
- family-words reads src/ once, not once per sentence, and leaves SLOW (#17872) 49845bf
- Full suite red: test/security-floor-routes.test.ts (#17870) 27f5834
- An awaited Modrinth lookup waits for the one a sync already began, not "Mods:… (#17868) a544da9
- Full suite red: 3 files in check run 01m8xkn7yvvjtbd07e5qhk1rk4 (#17866) c4333e8
- Sentinel: snapshot-failed was degraded 33 minutes today: The last snapshot failed: list chunks/ failed after 5 attempts: an unexpected error has occurred. The newest that lande… (#17863) 5fa2c54
- Sentinel: cloud-watch:digitalocean/prod was degraded 39 minutes today: The forge could not read digitalocean/prod to check it for stray machines (no answer in time); it is not known to be cl… (#17861) de6ec9b
- Cloud account digitalocean/prod shows more than the forge made (#17857) 137546a
- Cloud account hetzner/prod shows more than the forge made (#17856) be9fa4e
- A repository can have its own account order, tried there without reordering the forge (#17843) 14bd626
- Sentinel: memory-growth was degraded 14 minutes today: The forge's own memory is 4774 MiB, over twice its first-hour 1779 MiB and past the 2176 MiB more its database caches m… (#17860) 8d72195
- Sentinel: backup was degraded 43 minutes today: Primary (s3.us-east-005.backblazeb2.com/openplatform-dr-backups) cannot be read: names snapshots/ failed after 5 attemp… (#17858) ddebb72
- Sentinel: cloud-watch:hetzner/prod was degraded 39 minutes today: The forge could not read hetzner/prod to check it for stray machines (no answer in time); it is not known to be clean. … (#17859) 5c2509f
3 earlier comments
An OpenAI-type account that is still answering 429 after the runner's own waits now hands the run to the next account in order. I did not cover a timeout (below), and I did not run bun scripts/design-lint.ts since no web files changed. Tests pass: test/crew-openai-account.test.ts, test/crew-limit-words.test.ts and test/crew-breath.test.ts (33 pass), and bun x tsc --noEmit is clean. bun scripts/gate.ts still notes two comment lines over 100 columns, which it says the nightly rewrap handles. The new test is a unit-level one, not a full run through the crew.
What changed
- Hand-off: in
src/crew/run_limits.ts, a newconnectionHandOffruns insidelimitEnding. When a run on an OpenAI-type account ends on a per-minute 429, it rests that account and picks again with the existing order logic (the repository's order first). If another account is awake, the run pauses and resumes there. - What the log says: it writes
handed off: First refused (429…) and rests until …; Second takes the run. The next run'schoiceLinethen also lists First as passed over, with the cause. I changed no code inaccount_choice.ts. - Once per account: the refused account stays resting for the provider's default wait, about 15 minutes, so the run cannot hand off from it again meanwhile. A run that is still going after the rest ends could hand off from it a second time.
- No double-spend: a 429 reports no cost, and the test asserts the first account was charged $0.
- If there is nobody to take over: the account is woken again and the old per-minute wait applies.
- Test:
test/crew-openai-account.test.tsruns two fake endpoints. The first answers 429, and the run finishes on the second, with the log line and the passed-over record checked. It is a unit-level test that drivesrunOpenAIandlimitEndingdirectly. - Already there: a 401, 402, 403 or 5xx from an OpenAI-type account already rested it and handed the run on before this change.
Left out
- Timeout: the OpenAI runner's timeout is the whole run's deadline, so moving on to another account would only restart a run that has already run out of time. Say if you want a separate per-request timeout.
- One combined failure: "if all fail, the run fails once with each cause listed" is not done. When every account has failed, the run still waits for the earliest account to wake, as before. Each cause stays on the log through the hand-off lines and the passed-over record.
- Real-time end-to-end test: the runner's waits total about 112 seconds, so I did not write one.
No door: this is crew-runner behaviour with no new page, action, route or tool.
To try it, grant two OpenAI-type connections to a repository and make the first answer 429. The run log shows the handed off: line, and the next run's account: line names the first as passed over.
🤖 Generated with Claude Code
A run on an OpenAI-type account now hands off at most once per account, and fails once with every cause listed when no account is left. A hung endpoint is cut at its own limit. The tests in test/crew-openai-account.test.ts pass (23) and tsc is clean. The gate only noted over-wide comments, which --fix rewrapped. I did not run the full suite.
- All failed: when a hand-off finds nobody to take over after an earlier hand-off,
connectionHandOffinsrc/crew/run_limits.tsends the run asfailed. It writes one log line and one summary of the formevery account failed: First: 429…; Second: 429…. The run no longer waits for the earliest account to wake. The first refusal of a run, with nobody else awake, still falls through to the existing wait. - Once per account per run: the accounts already handed from are read back from the run's own
handed off:log lines. An account on that list is not handed from again, and neither is one it would hand to. A second refusal from it fails the run, even if another account is awake. - Timeout: the OpenAI runner (
src/crew/openai_runner.ts) now has a per-request timeout of 90 s to the response headers, separate from the run's deadline. A hung account on a connection ends withlimit: { said: "the account's endpoint did not answer in N s" }. That is the same shape as the 5xx case, so it rests the account and the next one takes the run through the existing path. Talk is unchanged. - Tests: two fake endpoints both answering 429 give one failure listing both causes. A later refusal from an already-handed-from account is refused while another account is awake, and the log keeps a single
handed off:line. A never-answering endpoint is cut and reported as a failing account.
Design choices:
- Log as the record: I used the run log rather than module state, because the check forbids a module-level Map or Set that functions write to. This depends on the exact
handed off: <name> refused (<cause>) and rests untilwording, which the all-failed test exercises. - Account names: names are assumed unique, as they are for subscriptions.
- Left out: a hang during a retry inside the 429 wait loop, or while the answer streams, is not cut by the per-request limit. A hung connection also goes through the existing rest-and-next path instead of the new once-per-run tracking or the all-failed summary. Both could be done later.
- No door: no web, TUI or docs change; the summary and log already show on the run.
The check failed because the new per-request timeout in src/crew/openai_runner.ts used a bare setTimeout. Its callback now runs inside background("openai-headers", …), as the timer rule requires. Behaviour is unchanged.
test/timers-named.test.ts and test/crew-openai-account.test.ts pass (32 tests), and tsc is clean. I did not run the full suite. I pushed the fix as a new commit on the same branch.
The pull description from my earlier message still stands.
The check failed because the new openai-headers timer runs under background, and test/job-slices.test.ts wants every such job timed or listed in its UNTIMED table with a reason. I added it to UNTIMED as a one-shot timer that only aborts one request. That test now passes, 3 of 3. I did not rerun the full suite. The fix is pushed as a new commit on the same branch.
The pull description from my earlier message still stands.
An OpenAI-type account that is still answering 429 after the runner's own waits now hands the run to the next account in order. I did not cover a timeout (below), and I did not run
bun scripts/design-lint.tssince no web files changed. Tests pass:test/crew-openai-account.test.ts,test/crew-limit-words.test.tsandtest/crew-breath.test.ts(33 pass), andbun x tsc --noEmitis clean.bun scripts/gate.tsstill notes two comment lines over 100 columns, which it says the nightly rewrap handles. The new test is a unit-level one, not a full run through the crew.What changed
src/crew/run_limits.ts, a newconnectionHandOffruns insidelimitEnding. When a run on an OpenAI-type account ends on a per-minute 429, it rests that account and picks again with the existing order logic (the repository's order first). If another account is awake, the run pauses and resumes there.handed off: First refused (429…) and rests until …; Second takes the run. The next run'schoiceLinethen also lists First as passed over, with the cause. I changed no code inaccount_choice.ts.test/crew-openai-account.test.tsruns two fake endpoints. The first answers 429, and the run finishes on the second, with the log line and the passed-over record checked. It is a unit-level test that drivesrunOpenAIandlimitEndingdirectly.Left out
No door: this is crew-runner behaviour with no new page, action, route or tool.
To try it, grant two OpenAI-type connections to a repository and make the first answer 429. The run log shows the
handed off:line, and the next run'saccount:line names the first as passed over.🤖 Generated with Claude Code
Closes #17889