fix: stabilize code mode timeout and prompt snapshots (#87809) · openclaw/openclaw@2ba725e
RomneyDa
·
2026-05-29
·
via Recent Commits to openclaw:main
File tree
test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path
| Original file line number | Diff line number | Diff line change |
|---|
@@ -889,6 +889,32 @@ describe("Code Mode", () => {
|
889 | 889 | expect(details.code).toBe("timeout"); |
890 | 890 | }); |
891 | 891 | |
| 892 | +it("normalizes QuickJS interrupt timeout errors", () => { |
| 893 | +expect( |
| 894 | +testing.normalizeCodeModeWorkerResult({ |
| 895 | +status: "failed", |
| 896 | +code: "timeout", |
| 897 | +error: "interrupted", |
| 898 | +output: [], |
| 899 | +}), |
| 900 | +).toMatchObject({ |
| 901 | +code: "timeout", |
| 902 | +error: "code mode timeout exceeded", |
| 903 | +}); |
| 904 | + |
| 905 | +expect( |
| 906 | +testing.normalizeCodeModeWorkerResult({ |
| 907 | +status: "failed", |
| 908 | +code: "internal_error", |
| 909 | +error: "interrupted", |
| 910 | +output: [], |
| 911 | +}), |
| 912 | +).toMatchObject({ |
| 913 | +code: "internal_error", |
| 914 | +error: "interrupted", |
| 915 | +}); |
| 916 | +}); |
| 917 | + |
892 | 918 | it("classifies missing worker runtime as unavailable", async () => { |
893 | 919 | const config = resolveCodeModeConfig({ tools: { codeMode: true } } as never); |
894 | 920 | const missingWorkerUrl = new URL("./missing-code-mode.worker.js", import.meta.url); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -546,6 +546,16 @@ function failedCodeModeWorkerResult(
|
546 | 546 | }; |
547 | 547 | } |
548 | 548 | |
| 549 | +function normalizeCodeModeWorkerResult(result: CodeModeWorkerResult): CodeModeWorkerResult { |
| 550 | +if (result.status === "failed" && result.code === "timeout" && result.error === "interrupted") { |
| 551 | +return { |
| 552 | + ...result, |
| 553 | +error: "code mode timeout exceeded", |
| 554 | +}; |
| 555 | +} |
| 556 | +return result; |
| 557 | +} |
| 558 | + |
549 | 559 | async function runCodeModeWorker( |
550 | 560 | workerData: unknown, |
551 | 561 | timeoutMs: number, |
@@ -581,16 +591,15 @@ async function runCodeModeWorker(
|
581 | 591 | }, timeoutMs); |
582 | 592 | worker.once("message", (message: unknown) => { |
583 | 593 | void worker.terminate(); |
584 | | -finish( |
585 | | -isRecord(message) |
586 | | - ? (message as CodeModeWorkerResult) |
587 | | - : { |
588 | | -status: "failed", |
589 | | -error: "invalid code mode worker response", |
590 | | -code: "internal_error", |
591 | | -output: [], |
592 | | -}, |
593 | | -); |
| 594 | +const result = isRecord(message) |
| 595 | + ? (message as CodeModeWorkerResult) |
| 596 | + : ({ |
| 597 | +status: "failed", |
| 598 | +error: "invalid code mode worker response", |
| 599 | +code: "internal_error", |
| 600 | +output: [], |
| 601 | +} satisfies CodeModeWorkerResult); |
| 602 | +finish(normalizeCodeModeWorkerResult(result)); |
594 | 603 | }); |
595 | 604 | worker.once("error", (error) => { |
596 | 605 | finish(failedCodeModeWorkerResult(error, "runtime_unavailable")); |
@@ -992,6 +1001,7 @@ export const testing = {
|
992 | 1001 | activeRuns, |
993 | 1002 | resumingRunIds, |
994 | 1003 | codeModeWorkerUrl, |
| 1004 | + normalizeCodeModeWorkerResult, |
995 | 1005 | runCodeModeWorker, |
996 | 1006 | resolveCodeModeWorkerUrl, |
997 | 1007 | resolveCodeModeConfig, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1185,7 +1185,7 @@
|
1185 | 1185 | "maxChars": { |
1186 | 1186 | "description": "Max chars returned; truncates.", |
1187 | 1187 | "minimum": 100, |
1188 | | -"type": "number" |
| 1188 | +"type": "integer" |
1189 | 1189 | }, |
1190 | 1190 | "url": { |
1191 | 1191 | "description": "HTTP(S) URL.", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1217,7 +1217,7 @@
|
1217 | 1217 | "maxChars": { |
1218 | 1218 | "description": "Max chars returned; truncates.", |
1219 | 1219 | "minimum": 100, |
1220 | | -"type": "number" |
| 1220 | +"type": "integer" |
1221 | 1221 | }, |
1222 | 1222 | "url": { |
1223 | 1223 | "description": "HTTP(S) URL.", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1181,7 +1181,7 @@
|
1181 | 1181 | "maxChars": { |
1182 | 1182 | "description": "Max chars returned; truncates.", |
1183 | 1183 | "minimum": 100, |
1184 | | -"type": "number" |
| 1184 | +"type": "integer" |
1185 | 1185 | }, |
1186 | 1186 | "url": { |
1187 | 1187 | "description": "HTTP(S) URL.", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -221,7 +221,7 @@ This is the deterministic model-bound layer stack OpenClaw can snapshot for the
|
221 | 221 | "roughTokens": 0 |
222 | 222 | }, |
223 | 223 | "dynamicToolsJson": { |
224 | | -"chars": 40278, |
| 224 | +"chars": 40279, |
225 | 225 | "roughTokens": 10070 |
226 | 226 | }, |
227 | 227 | "openClawDeveloperInstructions": { |
@@ -233,8 +233,8 @@ This is the deterministic model-bound layer stack OpenClaw can snapshot for the
|
233 | 233 | "roughTokens": 6925 |
234 | 234 | }, |
235 | 235 | "totalWithDynamicToolsJson": { |
236 | | -"chars": 67980, |
237 | | -"roughTokens": 16995 |
| 236 | +"chars": 67981, |
| 237 | +"roughTokens": 16996 |
238 | 238 | }, |
239 | 239 | "userInputText": { |
240 | 240 | "chars": 1629, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -221,7 +221,7 @@ This is the deterministic model-bound layer stack OpenClaw can snapshot for the
|
221 | 221 | "roughTokens": 0 |
222 | 222 | }, |
223 | 223 | "dynamicToolsJson": { |
224 | | -"chars": 39999, |
| 224 | +"chars": 40000, |
225 | 225 | "roughTokens": 10000 |
226 | 226 | }, |
227 | 227 | "openClawDeveloperInstructions": { |
@@ -233,7 +233,7 @@ This is the deterministic model-bound layer stack OpenClaw can snapshot for the
|
233 | 233 | "roughTokens": 6544 |
234 | 234 | }, |
235 | 235 | "totalWithDynamicToolsJson": { |
236 | | -"chars": 66177, |
| 236 | +"chars": 66178, |
237 | 237 | "roughTokens": 16545 |
238 | 238 | }, |
239 | 239 | "userInputText": { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -222,7 +222,7 @@ This is the deterministic model-bound layer stack OpenClaw can snapshot for the
|
222 | 222 | "roughTokens": 0 |
223 | 223 | }, |
224 | 224 | "dynamicToolsJson": { |
225 | | -"chars": 41094, |
| 225 | +"chars": 41095, |
226 | 226 | "roughTokens": 10274 |
227 | 227 | }, |
228 | 228 | "openClawDeveloperInstructions": { |
@@ -234,7 +234,7 @@ This is the deterministic model-bound layer stack OpenClaw can snapshot for the
|
234 | 234 | "roughTokens": 6780 |
235 | 235 | }, |
236 | 236 | "totalWithDynamicToolsJson": { |
237 | | -"chars": 68215, |
| 237 | +"chars": 68216, |
238 | 238 | "roughTokens": 17054 |
239 | 239 | }, |
240 | 240 | "userInputText": { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。