Public: anyone can read this; the crew can change it.
Sentinel: Crew runs in trevato/quorum keep failing at the push or the sandbox #1956
scout/forge:scout/1923-sentinel-crew-runs-in-trevato-quorum-kee → main 1 commit fork
5 files
changed +50
−2
src/crew/interrupted.ts +1 −1
| @@ -37,8 +37,8 @@ export function interruptionOf(summary: string): Interruption | undefined { | ||
| 37 | 37 | } |
| 38 | 38 | if (/^declined\b/i.test(s)) return undefined; |
| 39 | 39 | if (RESTART.test(s)) return "restart"; |
| 40 | if (PROVIDER.test(s)) return "provider limit"; | |
| 41 | 40 | if (NETWORK.test(s)) return "network error"; |
| 41 | if (PROVIDER.test(s)) return "provider limit"; | |
| 42 | 42 | return undefined; |
| 43 | 43 | } |
| 44 | 44 |
src/crew/limits.ts +2 −1
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | import type { LimitWindow } from "../core/standing.ts"; |
| 9 | import { isNetworkError } from "./network.ts"; | |
| 9 | 10 | import type { ClaudeOutcome } from "./claude.ts"; |
| 10 | 11 | |
| 11 | 12 | /** How many times one task may be paused before the forge gives up on it. */ |
| @@ -22,7 +23,7 @@ const SLACK_MS = 60_000; | ||
| 22 | 23 | * the limit, and is checked too in case the ending is named differently. |
| 23 | 24 | */ |
| 24 | 25 | export function isRateLimited(outcome: ClaudeOutcome): boolean { |
| 25 | if (outcome.ok) return false; | |
| 26 | if (outcome.ok || isNetworkError(outcome)) return false; | |
| 26 | 27 | return ( |
| 27 | 28 | outcome.reason === "api_error" || |
| 28 | 29 | /rate[ _-]?limit|session limit|usage limit|weekly limit|hit your \w+ limit|overloaded|too many requests|\b(?:429|529)\b/i.test( |
src/crew/network.ts +3
| @@ -13,6 +13,9 @@ const NETWORK = | ||
| 13 | 13 | /** Seconds to wait before each retry; its length is the number of retries. */ |
| 14 | 14 | export const NETWORK_RETRY_SECONDS: readonly number[] = [5, 20, 60]; |
| 15 | 15 | |
| 16 | /** How long a run waits, paused, when the retries found the network still down. */ | |
| 17 | export const NETWORK_PAUSE_MS = 5 * 60_000; | |
| 18 | ||
| 16 | 19 | /** Whether the run ended on the network rather than on the work. */ |
| 17 | 20 | export function isNetworkError(outcome: ClaudeOutcome): boolean { |
| 18 | 21 | if (outcome.ok) return false; |
src/crew/runner.ts +19
| @@ -78,6 +78,7 @@ import { | ||
| 78 | 78 | import { policyBrief } from "../contract/audit.ts"; |
| 79 | 79 | import { |
| 80 | 80 | isNetworkError, |
| 81 | NETWORK_PAUSE_MS, | |
| 81 | 82 | NETWORK_RETRY_SECONDS, |
| 82 | 83 | pause, |
| 83 | 84 | } from "./network.ts"; |
| @@ -1076,6 +1077,24 @@ async function work( | ||
| 1076 | 1077 | turns: result.turns + again.turns, |
| 1077 | 1078 | }; |
| 1078 | 1079 | } |
| 1080 | // Still unreachable after the retries: an outage, not a verdict. The run | |
| 1081 | // pauses with its clone and session and asks again later, as it does for | |
| 1082 | // a provider limit, rather than ending as "no changes pushed". | |
| 1083 | if ( | |
| 1084 | isNetworkError(result) && | |
| 1085 | !signal.aborted && | |
| 1086 | run.attempt < MAX_PAUSES | |
| 1087 | ) { | |
| 1088 | const at = new Date(Date.now() + NETWORK_PAUSE_MS); | |
| 1089 | write(`network still down; paused, resumes ${whenText(at)}`); | |
| 1090 | return { | |
| 1091 | state: "paused", | |
| 1092 | summary: `paused: network error, resumes ${whenText(at)}`, | |
| 1093 | resumeAt: at.toISOString(), | |
| 1094 | sessionId: result.sessionId, | |
| 1095 | costUsd: result.costUsd, | |
| 1096 | }; | |
| 1097 | } | |
| 1079 | 1098 | noteRunProgress(app.db, run.id, { |
| 1080 | 1099 | sessionId: result.sessionId, |
| 1081 | 1100 | costUsd: result.costUsd, |
test/crew-network.test.ts +25
| @@ -9,6 +9,8 @@ import type { Repo } from "../src/core/repos.ts"; | ||
| 9 | 9 | import type { User } from "../src/core/users.ts"; |
| 10 | 10 | import { assignIssue, openIssue } from "../src/actions/issues.ts"; |
| 11 | 11 | import { isNetworkError } from "../src/crew/network.ts"; |
| 12 | import { isRateLimited } from "../src/crew/limits.ts"; | |
| 13 | import { interruptionOf } from "../src/crew/interrupted.ts"; | |
| 12 | 14 | import type { ClaudeOutcome } from "../src/crew/claude.ts"; |
| 13 | 15 | import { |
| 14 | 16 | agentRunSettled, |
| @@ -78,3 +80,26 @@ describe("the crew, with a stand-in Claude Code: network errors", () => { | ||
| 78 | 80 | expect(run.summary).toContain("opened pull"); |
| 79 | 81 | }, 60_000); |
| 80 | 82 | }); |
| 83 | ||
| 84 | describe("a network outage is not a provider limit", () => { | |
| 85 | const down = { | |
| 86 | result: | |
| 87 | "API Error: Can't reach the API server — check your internet or DNS (EAI_AGAIN)", | |
| 88 | reason: "api_error", | |
| 89 | }; | |
| 90 | ||
| 91 | test("an unreachable API is not rate limited", () => { | |
| 92 | expect(isRateLimited(outcome(down))).toBe(false); | |
| 93 | expect( | |
| 94 | isRateLimited( | |
| 95 | outcome({ result: "429 too many requests", reason: "api_error" }), | |
| 96 | ), | |
| 97 | ).toBe(true); | |
| 98 | }); | |
| 99 | ||
| 100 | test("its summary reads as a network error", () => { | |
| 101 | expect( | |
| 102 | interruptionOf(`no changes pushed: ${down.result} (api_error)`), | |
| 103 | ).toBe("network error"); | |
| 104 | }); | |
| 105 | }); |
new above
offline