{"record":{"id":"2a78395cbcf8dee1","repo":"can1357/oh-my-pi","slug":"finaltext-eval-cell-failed","errorCode":null,"errorMessage":"${finalText} || Eval cell failed","messagePattern":"(.+?) \\|\\| Eval cell failed","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/eval.ts","lineNumber":568,"sourceCode":"\t\t\tlabel,\n\t\t\tasync ({ jobId, signal: runSignal, reportProgress }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await run(runSignal, (text, details) => {\n\t\t\t\t\t\tlatestText = text;\n\t\t\t\t\t\tlatestDetails = details;\n\t\t\t\t\t\tvoid reportProgress(text, { async: { state: \"running\", jobId, type: \"eval\" } });\n\t\t\t\t\t\tif (forwardUpdates) emitToolUpdate?.(text, details);\n\t\t\t\t\t});\n\t\t\t\t\tconst finalText = result.content.find(block => block.type === \"text\")?.text ?? \"\";\n\t\t\t\t\tlatestText = finalText;\n\t\t\t\t\t// Hand the full result (images included) to the foreground waiter\n\t\t\t\t\t// before deciding the job's terminal state.\n\t\t\t\t\tcompletion.resolve({ kind: \"completed\", result });\n\t\t\t\t\tif (result.isError === true) {\n\t\t\t\t\t\t// A failed, cancelled, or timed-out cell is a completed execution\n\t\t\t\t\t\t// that errored. Re-enter the failure path so the job manager\n\t\t\t\t\t\t// records it as failed and delivers the error text.\n\t\t\t\t\t\tthrow new ToolError(finalText || \"Eval cell failed\");\n\t\t\t\t\t}\n\t\t\t\t\tawait reportProgress(finalText, { async: { state: \"completed\", jobId, type: \"eval\" } });\n\t\t\t\t\treturn finalText;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tlatestText = message;\n\t\t\t\t\tcompletion.resolve({ kind: \"failed\", error });\n\t\t\t\t\tawait reportProgress(message, { async: { state: \"failed\", jobId, type: \"eval\" } });\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ ownerId: session.getAgentId?.() ?? undefined },\n\t\t);\n\n\t\tif (startBackgrounded) {\n\t\t\treturn this.#buildBackgroundStartResult(jobId, cells, languages, notice, latestText, latestDetails);\n\t\t}\n\t\t// Suppress the completion delivery up front so a job finishing while we","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/eval.ts#L550-L586","documentation":"When an eval cell runs as a managed auto-background job, the job wrapper inspects the final AgentToolResult. If result.isError === true (the cell failed, was cancelled, or timed out — a *completed* execution that errored), it re-throws a ToolError carrying the cell's final output text so the job manager records the job as failed and delivers the error text. This is how backend-level cell failures surface to the agent through the background-job path.","triggerScenarios":"An auto-backgrounded eval cell completes with isError=true: the code itself threw, the cell timed out, or the cell was cancelled by the backend. The final text block content becomes the ToolError message.","commonSituations":"Long-running Python/JS cells that exceed timeout and get auto-backgrounded; user code with unhandled exceptions in backgrounded cells; backgrounded cells cancelled while waiting for the foreground result.","solutions":["Read the delivered error text: it is the cell's own output/exception; fix the user code that failed.","Increase the cell timeout (params.timeout) if the failure was a timeout on long work.","Disable auto-background (eval.autoBackground.enabled=false) if foreground execution with inline errors is preferred."],"exampleFix":"// before: cell times out and is backgrounded\n{ \"language\": \"py\", \"code\": \"time.sleep(600)\", \"timeout\": 10 }\n// after: explicit longer timeout so it completes\n{ \"language\": \"py\", \"code\": \"time.sleep(600)\", \"timeout\": 700 }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isEvalCellFailure(msg: string): boolean { return msg === \"Eval cell failed\" || msg.length > 0; } // the message is the cell's own output text","tryCatchPattern":"try {\n  await evalTool.execute(id, params, signal);\n} catch (e) {\n  if (e instanceof ToolError) {\n    const cellOutput = e.message; // final streamed cell text — inspect/repair the user code\n    // retry with adjusted timeout or corrected code\n  } else throw e;\n}","preventionTips":["Set realistic per-cell timeouts so long work doesn't fail in background.","Test cell code in the foreground first before relying on auto-background.","Treat the delivered message as the cell's own error output and fix the root cause in the code."],"tags":["eval-tool","cell-failed","background-job","timeout"],"backgroundTag":"background-job-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}