@@ -4,6 +4,7 @@
|
4 | 4 | |
5 | 5 | import { spawn } from "node:child_process"; |
6 | 6 | import { |
| 7 | +appendFileSync, |
7 | 8 | chmodSync, |
8 | 9 | createWriteStream, |
9 | 10 | existsSync, |
@@ -2552,27 +2553,51 @@ async function runModelsSet(params) {
|
2552 | 2553 | } |
2553 | 2554 | |
2554 | 2555 | async function runAgentTurn(params) { |
2555 | | -const sessionId = `cross-os-release-check-${params.label}-${Date.now()}`; |
2556 | | -const result = await runOpenClaw({ |
2557 | | -lane: params.lane, |
2558 | | -env: params.env, |
2559 | | -args: [ |
2560 | | -"agent", |
2561 | | -"--agent", |
2562 | | -"main", |
2563 | | -"--session-id", |
2564 | | -sessionId, |
2565 | | -"--message", |
2566 | | -"Reply with exact ASCII text OK only.", |
2567 | | -"--json", |
2568 | | -], |
2569 | | -logPath: params.logPath, |
2570 | | -timeoutMs: 10 * 60 * 1000, |
2571 | | -}); |
2572 | | -if (!agentOutputHasExpectedOkMarker(result.stdout, { logPath: params.logPath })) { |
2573 | | -throw new Error("Agent output did not contain the expected OK marker."); |
| 2556 | +let lastError; |
| 2557 | +for (let attempt = 1; attempt <= 2; attempt += 1) { |
| 2558 | +const sessionId = `cross-os-release-check-${params.label}-${Date.now()}-${attempt}`; |
| 2559 | +try { |
| 2560 | +const result = await runOpenClaw({ |
| 2561 | +lane: params.lane, |
| 2562 | +env: params.env, |
| 2563 | +args: [ |
| 2564 | +"agent", |
| 2565 | +"--agent", |
| 2566 | +"main", |
| 2567 | +"--session-id", |
| 2568 | +sessionId, |
| 2569 | +"--message", |
| 2570 | +"Reply with exact ASCII text OK only.", |
| 2571 | +"--json", |
| 2572 | +], |
| 2573 | +logPath: params.logPath, |
| 2574 | +timeoutMs: 10 * 60 * 1000, |
| 2575 | +}); |
| 2576 | +if (!agentOutputHasExpectedOkMarker(result.stdout, { logPath: params.logPath })) { |
| 2577 | +throw new Error("Agent output did not contain the expected OK marker."); |
| 2578 | +} |
| 2579 | +return result; |
| 2580 | +} catch (error) { |
| 2581 | +lastError = error; |
| 2582 | +if (attempt >= 2 || !shouldRetryCrossOsAgentTurnError(error)) { |
| 2583 | +throw error; |
| 2584 | +} |
| 2585 | +appendFileSync( |
| 2586 | +params.logPath, |
| 2587 | +`\n[release-checks] retrying agent turn after bundled runtime deps staging failure: ${ |
| 2588 | + error instanceof Error ? error.message : String(error) |
| 2589 | + }\n`, |
| 2590 | +); |
| 2591 | +} |
2574 | 2592 | } |
2575 | | -return result; |
| 2593 | +throw lastError; |
| 2594 | +} |
| 2595 | + |
| 2596 | +export function shouldRetryCrossOsAgentTurnError(error) { |
| 2597 | +const message = error instanceof Error ? error.message : String(error); |
| 2598 | +return /failed to (?:install|stage) bundled runtime deps|failed to stage bundled runtime deps after/u.test( |
| 2599 | +message, |
| 2600 | +); |
2576 | 2601 | } |
2577 | 2602 | |
2578 | 2603 | export function agentOutputHasExpectedOkMarker(stdout, options = {}) { |
|