{"record":{"id":"135a462dfd02f22b","repo":"can1357/oh-my-pi","slug":"label-failed-reason","errorCode":null,"errorMessage":"${label} failed: ${reason}","messagePattern":"(.+?) failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/eval/kernel-base.ts","lineNumber":606,"sourceCode":"\t\t}\n\t\tconst timer =\n\t\t\ttimeoutMs > 0\n\t\t\t\t? setTimeout(() => controller.abort(createAbortError(\"TimeoutError\", `${label} timed out`)), timeoutMs)\n\t\t\t\t: undefined;\n\t\tif (timer) cleanups.push(() => clearTimeout(timer));\n\t\ttry {\n\t\t\tthrowIfAborted(controller.signal, label);\n\t\t\tconst result = await this.execute(code, {\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tsilent: true,\n\t\t\t\tstoreHistory: false,\n\t\t\t} as TExecuteOptions);\n\t\t\tif (result.cancelled) {\n\t\t\t\tthrow createAbortError(result.timedOut ? \"TimeoutError\" : \"AbortError\", `${label} cancelled`);\n\t\t\t}\n\t\t\tif (result.status === \"error\") {\n\t\t\t\tconst reason = result.error?.value ?? `${this.#options.languageName} kernel init failed`;\n\t\t\t\tthrow new Error(`${label} failed: ${reason}`);\n\t\t\t}\n\t\t} finally {\n\t\t\tfor (const cleanup of cleanups) cleanup();\n\t\t}\n\t}\n\n\t#waitForExitWithTimeout(timeoutMs: number): Promise<number | null> {\n\t\tif (!this.#exitedPromise) return Promise.resolve(0);\n\t\tconst exitedPromise = this.#exitedPromise;\n\t\tconst timeout = new Promise<null>(resolve => {\n\t\t\tconst timer = setTimeout(() => resolve(null), Math.max(0, timeoutMs));\n\t\t\ttimer.unref?.();\n\t\t});\n\t\treturn Promise.race([exitedPromise.then(code => code as number | null), timeout]);\n\t}\n}\n","sourceCodeStart":588,"sourceCodeEnd":623,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/eval/kernel-base.ts#L588-L623","documentation":"`executeWithBudget` runs an initialization/setup code snippet with cancellation and timeout support. If the snippet reports status \"error\", it throws `\"<label> failed: <reason>\"` with the kernel-reported error value (or a default \"init failed\" message). This wraps kernel-side failures during setup (e.g. prelude/bootstrap code) into a single actionable error.","triggerScenarios":"Kernel bootstrap/prelude code executed via `executeWithBudget` (called from `start`) returns a result with `status === \"error\"` — e.g. the init script raised an exception, or the execution was cut short by error after partial failure.","commonSituations":"A bad prelude/config injected into the kernel raising on startup; a kernel that starts but fails importing required modules during init; version drift between the eval harness and the kernel runtime causing init script incompatibility.","solutions":["Read the embedded `reason` (the kernel error value) — it names the actual init failure","Fix the prelude/init code that fails (syntax, missing dependency, unsupported API)","Verify the language runtime/interpreter version supports the init script"],"exampleFix":"// before: init prelude uses unavailable API\nconst sys = await import(\"node:foo\"); // fails in kernel realm\n// after\nconst fs = await import(\"node:fs\"); // supported module","handlingStrategy":"try-catch","validationCode":"// validate the init script against the target runtime before start\n// e.g. ensure imports used by the prelude exist in the kernel realm\nfor (const mod of requiredModules) {\n  if (!supportedModules.has(mod)) throw new Error(`prelude needs unsupported module ${mod}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await kernel.start();\n} catch (err) {\n  if (err instanceof Error && / failed: /.test(err.message)) {\n    logger.error(\"kernel init failed\", { reason: err.message });\n    // fix prelude or restart with a minimal prelude\n  }\n}","preventionTips":["Test prelude/bootstrap snippets against the exact kernel runtime version","Keep init scripts minimal to reduce failure surface","Log the embedded reason — it names the real init error"],"tags":["kernel","init","bootstrap","eval"],"backgroundTag":"kernel-init-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}