惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
Y
Y Combinator Blog
WordPress大学
WordPress大学
L
LangChain Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
About on SuperTechFans
小众软件
小众软件
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
Recent Announcements
Recent Announcements
GbyAI
GbyAI
I
InfoQ
The GitHub Blog
The GitHub Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
罗磊的独立博客
C
Check Point Blog
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
量子位
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: preserve code mode failure output · openclaw/opencla...
steipete · 2026-05-26 · via Recent Commits to openclaw:main

@@ -53,7 +53,12 @@ type CodeModeWorkerResult =

5353

| {

5454

status: "failed";

5555

error: string;

56-

code: "invalid_input" | "runtime_unavailable" | "timeout" | "internal_error";

56+

code:

57+

| "invalid_input"

58+

| "runtime_unavailable"

59+

| "timeout"

60+

| "snapshot_limit_exceeded"

61+

| "internal_error";

5762

output: unknown[];

5863

};

5964

@@ -71,6 +76,21 @@ class CodeModeWorkerFailure extends Error {

7176

}

7277

}

737879+

class CodeModeWorkerFailureWithOutput extends CodeModeWorkerFailure {

80+

readonly output: unknown[];

81+82+

constructor(

83+

code: Extract<CodeModeWorkerResult, { status: "failed" }>["code"],

84+

message: string,

85+

output: unknown[],

86+

options?: ErrorOptions,

87+

) {

88+

super(code, message, options);

89+

this.name = "CodeModeWorkerFailureWithOutput";

90+

this.output = output;

91+

}

92+

}

93+7494

class CodeModeGuestError extends Error {

7595

constructor(message: string) {

7696

super(message);

@@ -337,6 +357,49 @@ function takeOutput(vm: QuickJS): unknown[] {

337357

}

338358

}

339359360+

function takeOutputSafely(vm: QuickJS): unknown[] {

361+

try {

362+

return takeOutput(vm);

363+

} catch {

364+

return [];

365+

}

366+

}

367+368+

function throwWorkerFailureWithOutput(params: {

369+

error: unknown;

370+

didTimeout: () => boolean;

371+

output: unknown[];

372+

vm: QuickJS;

373+

}): never {

374+

const timedOut = params.didTimeout() || isQuickJsInterruptedError(params.error);

375+

const failureOutput = params.output.length > 0 ? params.output : takeOutputSafely(params.vm);

376+

if (timedOut) {

377+

throw new CodeModeWorkerFailureWithOutput(

378+

"timeout",

379+

"code mode timeout exceeded",

380+

failureOutput,

381+

{ cause: params.error },

382+

);

383+

}

384+

if (params.error instanceof CodeModeWorkerFailure) {

385+

throw new CodeModeWorkerFailureWithOutput(

386+

params.error.code,

387+

params.error.message,

388+

failureOutput,

389+

{ cause: params.error },

390+

);

391+

}

392+

if (failureOutput.length > 0) {

393+

throw new CodeModeWorkerFailureWithOutput(

394+

"internal_error",

395+

errorMessage(params.error),

396+

failureOutput,

397+

{ cause: params.error },

398+

);

399+

}

400+

throw params.error;

401+

}

402+340403

function drainPendingJobs(vm: QuickJS): void {

341404

for (let index = 0; index < 1000; index += 1) {

342405

if (vm.executePendingJobs() === 0) {

@@ -377,7 +440,7 @@ function waitingResult(params: {

377440

}): CodeModeWorkerResult {

378441

const snapshotBytes = QuickJS.serializeSnapshot(params.vm.snapshot());

379442

if (snapshotBytes.byteLength > params.config.maxSnapshotBytes) {

380-

throw new Error("code mode snapshot limit exceeded");

443+

throw new CodeModeWorkerFailure("snapshot_limit_exceeded", "code mode snapshot limit exceeded");

381444

}

382445

return {

383446

status: "waiting",

@@ -394,14 +457,15 @@ async function runExec(input: Extract<CodeModeWorkerInput, { kind: "exec" }>) {

394457

config: input.config,

395458

pendingRequests,

396459

});

460+

let output: unknown[] = [];

397461

try {

398462

vm.evalCode(

399463

buildUserSource(input.source),

400464

"openclaw-code-mode:user.js",

401465

EvalFlags.ASYNC,

402466

).dispose();

403467

drainPendingJobs(vm);

404-

const output = takeOutput(vm);

468+

output = takeOutput(vm);

405469

const resultHandle = getResultHandle(vm);

406470

try {

407471

if (pendingRequests.length > 0) {

@@ -419,10 +483,7 @@ async function runExec(input: Extract<CodeModeWorkerInput, { kind: "exec" }>) {

419483

resultHandle.dispose();

420484

}

421485

} catch (error) {

422-

if (didTimeout() || isQuickJsInterruptedError(error)) {

423-

throw new CodeModeWorkerFailure("timeout", "code mode timeout exceeded", { cause: error });

424-

}

425-

throw error;

486+

return throwWorkerFailureWithOutput({ error, didTimeout, output, vm });

426487

} finally {

427488

vm.dispose();

428489

}

@@ -435,6 +496,7 @@ async function runResume(input: Extract<CodeModeWorkerInput, { kind: "resume" }>

435496

config: input.config,

436497

pendingRequests,

437498

});

499+

let output: unknown[] = [];

438500

try {

439501

const settle = vm.global.getProp("__openclawSettleBridge");

440502

try {

@@ -458,7 +520,7 @@ async function runResume(input: Extract<CodeModeWorkerInput, { kind: "resume" }>

458520

settle.dispose();

459521

}

460522

drainPendingJobs(vm);

461-

const output = takeOutput(vm);

523+

output = takeOutput(vm);

462524

const resultHandle = getResultHandle(vm);

463525

try {

464526

if (pendingRequests.length > 0) {

@@ -476,10 +538,7 @@ async function runResume(input: Extract<CodeModeWorkerInput, { kind: "resume" }>

476538

resultHandle.dispose();

477539

}

478540

} catch (error) {

479-

if (didTimeout() || isQuickJsInterruptedError(error)) {

480-

throw new CodeModeWorkerFailure("timeout", "code mode timeout exceeded", { cause: error });

481-

}

482-

throw error;

541+

return throwWorkerFailureWithOutput({ error, didTimeout, output, vm });

483542

} finally {

484543

vm.dispose();

485544

}

@@ -525,7 +584,7 @@ async function main(): Promise<CodeModeWorkerResult> {

525584

status: "failed",

526585

error: errorMessage(error),

527586

code: error instanceof CodeModeWorkerFailure ? error.code : "internal_error",

528-

output: [],

587+

output: error instanceof CodeModeWorkerFailureWithOutput ? error.output : [],

529588

};

530589

}

531590

}