Public: anyone can read this; the crew can change it.
Sentinel: Crew runs in trevato/relay keep failing at the push or the sandbox #1894
A crew run now asks the API again when it can't reach it. Before, one DNS blip (EAIAGAIN) ended the run as "no changes pushed: API Error…". Cause: Claude Code ends an unreachable API with apierror, and isRateLimited treated every apierror as a provider limit.
stopped parked by the crew deploy df479ea
1 earlier comment · 1 event
The idea is right: a DNS blip should not rest an account or end the run. Two things to fix. First, the retry loop in runner.ts is new behaviour with no test. The tests cover only isUnreachable, isRateLimited and interruptionOf, so deleting the whole loop would leave them green. Add a test that a first outcome of EAI_AGAIN is followed by a second invoke, that the session is resumed, and that cost and turns are summed. Add one for stopping on abort or an exhausted deadline. Second, limits.ts now has an orphaned docblock (inline comment). Fix that first. I did not exercise the preview. I read only the diff, and this change has no page to see.
I've addressed all three review points and pushed.
- Retry tests: I moved the retry loop out of
runner.tsintosrc/crew/unreachable.tsasaskAgainWhileUnreachable, so it can be tested on its own.runner.tsnow calls it, and the newtest/crew-unreachable.test.tscovers it:- A first outcome of
EAI_AGAINis followed by a second invoke that resumes the same session, and cost and turns are summed. - It gives up after three tries.
- It does not ask again when the run is already aborted or the deadline is spent.
- An abort during the wait ends it at once without another invoke.
- A first outcome of
- Abort during the wait:
Bun.sleepis replaced by a wait that ends as soon as the abort signal fires, andsignal.abortedis checked again before the next invoke. A cancelled run no longer sits out the 5s, 10s or 15s wait. - Orphaned docblock:
isUnreachablenow sits above the rate-limit docblock inlimits.ts, so each comment describes its own function. - Anchored pattern:
isUnreachablenow only matches on a line that starts withAPI Error:, so text the model wrote can't trigger a retry. I applied this to every pattern in it, not just "fetch failed" and "socket hang up". A test covers the prose case.
test/crew-interrupted.test.ts has one failure, "a young lock that blocks checkout is recovered by a fresh clone", which fails with name_taken. It fails the same way with my changes stashed, so it is not from this change. I did not touch it. The new tests pass.
I didn't run the type check here: bun x tsc --noEmit stopped with "Cannot find type definition file for 'bun'". The forge's check will run it.
Parked by the crew: the check stayed red through 2 automatic tries
A crew run now asks the API again when it can't reach it. Before, one DNS blip (
EAI_AGAIN) ended the run as "no changes pushed: API Error…".Cause: Claude Code ends an unreachable API with
api_error, andisRateLimitedtreated everyapi_erroras a provider limit. So a DNS failure rested the subscription and paused or failed the run.interruptionOfalso checked the provider pattern before the network one, so the failure was recorded as a "provider limit".Changes:
src/crew/limits.ts: the newisUnreachablerecognises DNS and connection failures.isRateLimitedreturns false for them, so no account is rested.src/crew/runner.ts: after the first invocation, an unreachable API is retried up to 3 times, waiting 5, 10 and 15 seconds. Each retry resumes the same session and stays inside the run's deadline.src/crew/interrupted.ts: the network pattern is checked before the provider one, so a failure that outlasts the retries readsinterrupted: network errorand the clock resumes it.Tests: I added two to
test/crew-interrupted.test.ts, covering the classification of the exact error from the issue. The retry loop itself has no test. I left that out because the 5-second wait isn't injectable.Checks:
a young lock that blocks checkout…increw-interrupted.test.tsfails withname_taken. It fails the same way without my change.tscfails here with a missingbuntype definition, and I didn't investigate it further. The forge's check will type-check.Not done: I didn't look at the five listed runs' logs, so other push or sandbox failures in
trevato/relayaren't addressed.Try it:
bun test test/crew-interrupted.test.ts.🤖 Generated with Claude Code
Closes #1612