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

Parked opened this
Closed without merging

scout/forge:scout/1923-sentinel-crew-runs-in-trevato-quorum-kee → main 1 commit fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
5 files changed +50 −2
src/crew/interrupted.ts +1 −1
@@ -37,8 +37,8 @@ export function interruptionOf(summary: string): Interruption | undefined {
3737 }
3838 if (/^declined\b/i.test(s)) return undefined;
3939 if (RESTART.test(s)) return "restart";
40 if (PROVIDER.test(s)) return "provider limit";
4140 if (NETWORK.test(s)) return "network error";
41 if (PROVIDER.test(s)) return "provider limit";
4242 return undefined;
4343 }
4444
src/crew/limits.ts +2 −1
@@ -6,6 +6,7 @@
66 */
77
88 import type { LimitWindow } from "../core/standing.ts";
9 import { isNetworkError } from "./network.ts";
910 import type { ClaudeOutcome } from "./claude.ts";
1011
1112 /** How many times one task may be paused before the forge gives up on it. */
@@ -22,7 +23,7 @@ const SLACK_MS = 60_000;
2223 * the limit, and is checked too in case the ending is named differently.
2324 */
2425 export function isRateLimited(outcome: ClaudeOutcome): boolean {
25 if (outcome.ok) return false;
26 if (outcome.ok || isNetworkError(outcome)) return false;
2627 return (
2728 outcome.reason === "api_error" ||
2829 /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 =
1313 /** Seconds to wait before each retry; its length is the number of retries. */
1414 export const NETWORK_RETRY_SECONDS: readonly number[] = [5, 20, 60];
1515
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
1619 /** Whether the run ended on the network rather than on the work. */
1720 export function isNetworkError(outcome: ClaudeOutcome): boolean {
1821 if (outcome.ok) return false;
src/crew/runner.ts +19
@@ -78,6 +78,7 @@ import {
7878 import { policyBrief } from "../contract/audit.ts";
7979 import {
8080 isNetworkError,
81 NETWORK_PAUSE_MS,
8182 NETWORK_RETRY_SECONDS,
8283 pause,
8384 } from "./network.ts";
@@ -1076,6 +1077,24 @@ async function work(
10761077 turns: result.turns + again.turns,
10771078 };
10781079 }
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 }
10791098 noteRunProgress(app.db, run.id, {
10801099 sessionId: result.sessionId,
10811100 costUsd: result.costUsd,
test/crew-network.test.ts +25
@@ -9,6 +9,8 @@ import type { Repo } from "../src/core/repos.ts";
99 import type { User } from "../src/core/users.ts";
1010 import { assignIssue, openIssue } from "../src/actions/issues.ts";
1111 import { isNetworkError } from "../src/crew/network.ts";
12 import { isRateLimited } from "../src/crew/limits.ts";
13 import { interruptionOf } from "../src/crew/interrupted.ts";
1214 import type { ClaudeOutcome } from "../src/crew/claude.ts";
1315 import {
1416 agentRunSettled,
@@ -78,3 +80,26 @@ describe("the crew, with a stand-in Claude Code: network errors", () => {
7880 expect(run.summary).toContain("opened pull");
7981 }, 60_000);
8082 });
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 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs