{"record":{"id":"17072c012a9e0cd9","repo":"can1357/oh-my-pi","slug":"out-n-n-message","errorCode":null,"errorMessage":"${out}\\n\\n[${message}]","messagePattern":"(.+?)\\\\n\\\\n\\[(.+?)\\]","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"warning","filePath":"packages/coding-agent/src/tools/bash.ts","lineNumber":664,"sourceCode":"\t */\n\t#throwIfUnfinished(\n\t\tresult: BashResult | BashInteractiveResult,\n\t\ttimeoutSec: number | undefined,\n\t\toutputText: string,\n\t): void {\n\t\tif (result.cancelled) {\n\t\t\t// Local executor output already carries a leading `[Command cancelled]`\n\t\t\t// notice from the sink; PTY/bridge output does not, so annotate only\n\t\t\t// the latter.\n\t\t\tconst out = normalizeResultOutput(result);\n\t\t\tconst annotated = out.startsWith(\"[Command cancelled]\") ? out : out ? `${out}\\n\\n[Command aborted]` : out;\n\t\t\tthrow new ToolError(annotated || \"Command aborted\");\n\t\t}\n\t\tif (result.timedOut === true) {\n\t\t\tconst out = normalizeResultOutput(result);\n\t\t\tconst message =\n\t\t\t\ttimeoutSec === undefined ? \"Command timed out\" : `Command timed out after ${timeoutSec} seconds`;\n\t\t\tthrow new ToolError(out ? `${out}\\n\\n[${message}]` : message);\n\t\t}\n\t\tif (result.exitCode === undefined) {\n\t\t\tthrow new ToolError(`${outputText}\\n\\nCommand failed: missing exit status`);\n\t\t}\n\t}\n\n\tasync #buildCompletedResult(\n\t\tresult: BashResult | BashInteractiveResult,\n\t\ttimeoutSec: number | undefined,\n\t\toptions: {\n\t\t\trequestedTimeoutSec?: number;\n\t\t\tnotices?: readonly string[];\n\t\t\tterminalId?: string;\n\t\t\twallTimeMs?: number;\n\t\t} = {},\n\t): Promise<AgentToolResult<BashToolDetails>> {\n\t\tconst exitCode = result.exitCode;\n\t\tconst failedExit = exitCode !== undefined && exitCode !== 0;","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/bash.ts#L646-L682","documentation":"When result.timedOut === true, BashTool throws a ToolError reporting the timeout. The message is 'Command timed out' or 'Command timed out after N seconds' (when the tool call specified a timeoutSec), and any captured output is prepended so the user sees what the command produced before it was killed.","triggerScenarios":"The bash tool call exceeded its allowed runtime: a timeoutSec was supplied in the tool arguments and the command ran longer than it, or a default timeout fired (timeoutSec undefined).","commonSituations":"Long-running installs, builds, watches, servers, or interactive prompts (commands waiting on stdin) that never exit; network operations hanging without timeouts of their own.","solutions":["Increase the timeoutSec parameter for legitimately long commands.","Run long-lived processes in the background (nohup ... &, redirect logs) and poll them instead of blocking the tool call.","Fix the command so it actually terminates — add its own timeouts, remove interactive prompts, pipe input.","Disable pagers/interactive behavior with flags (e.g. --no-progress, CI=1, </dev/null) that commonly cause hangs."],"exampleFix":"// before\nawait bash.run(\"npm install\", {}); // hangs past default timeout\n// after\nawait bash.run(\"npm install\", { timeoutSec: 600 });","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await bash.run(cmd, opts); } catch (e) { if (e instanceof ToolError && e.message.includes('Command timed out')) { /* raise timeoutSec, background the process, or fix the hang */ } else throw e; }","preventionTips":["Always set an explicit timeoutSec sized to the command's expected runtime.","Background long-lived servers/watchers instead of blocking the tool call.","Eliminate interactive stdin prompts (use </dev/null, CI env flags).","Give network commands their own internal timeouts."],"tags":["bash","timeout","long-running"],"backgroundTag":"command-timed-out","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}