{"record":{"id":"dde92c28af8e6c01","repo":"earendil-works/pi","slug":"invalid-timeout-maximum-is-max-timeout-seconds","errorCode":null,"errorMessage":"Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds","messagePattern":"Invalid timeout: maximum is (.+?) seconds","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/harness/tools/bash.ts","lineNumber":47,"sourceCode":"\nexport type BashPrepare<TContext extends ExecutionToolContext = ExecutionToolContext> = (\n\texecution: BashExecution,\n\tcontext: TContext,\n\tsignal?: AbortSignal,\n) => void | Promise<void>;\n\nexport interface BashToolOptions<TContext extends ExecutionToolContext = ExecutionToolContext> {\n\tcommandPrefix?: string;\n\tprepare?: BashPrepare<TContext>;\n}\n\nfunction validateTimeout(timeout: number | undefined): void {\n\tif (timeout === undefined) return;\n\tif (!Number.isFinite(timeout) || timeout <= 0) {\n\t\tthrow new Error(\"Invalid timeout: must be a finite number of seconds\");\n\t}\n\tif (timeout > MAX_TIMEOUT_SECONDS) {\n\t\tthrow new Error(`Invalid timeout: maximum is ${MAX_TIMEOUT_SECONDS} seconds`);\n\t}\n}\n\nexport function createBashTool<TContext extends ExecutionToolContext = ExecutionToolContext>(\n\toptions?: BashToolOptions<TContext>,\n): AgentHarnessTool<TContext, typeof bashSchema, BashToolDetails | undefined> {\n\treturn {\n\t\tname: \"bash\",\n\t\tlabel: \"bash\",\n\t\tdescription: `Execute a bash command in the current working directory. Returns stdout and stderr. Output is truncated to last ${DEFAULT_MAX_LINES} lines or ${DEFAULT_MAX_BYTES / 1024}KB (whichever is hit first). If truncated, full output is saved to a temp file. Optionally provide a timeout in seconds.`,\n\t\tparameters: bashSchema,\n\t\tasync execute(_toolCallId, { command, timeout }, signal, onUpdate, context) {\n\t\t\tvalidateTimeout(timeout);\n\t\t\tconst { env } = context;\n\t\t\tconst execution: BashExecution = {\n\t\t\t\tcommand: options?.commandPrefix ? `${options.commandPrefix}\\n${command}` : command,\n\t\t\t\tcwd: env.cwd,\n\t\t\t\tenv: {},","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/agent/src/harness/tools/bash.ts#L29-L65","documentation":"validateTimeout caps the bash tool's timeout at MAX_TIMEOUT_SECONDS = 2147483.647 (bash.ts:8), which is 2^31-1 milliseconds expressed in seconds, the largest value the underlying setTimeout can schedule. Anything larger throws immediately rather than silently overflowing the timer.","triggerScenarios":"timeout: 3600000 intending 'one hour' but actually passing 3.6 million seconds; passing Number.MAX_SAFE_INTEGER or another huge sentinel for 'forever'; day-scale arithmetic producing multi-million second counts.","commonSituations":"Millisecond/second confusion, since the field is seconds; using a very large number to mean 'no limit' instead of omitting the field entirely.","solutions":["Omit timeout for unlimited; the tool has no default timeout","Convert milliseconds to seconds (ms / 1000) before passing","Cap at a realistic value, for example 3600 for one hour"],"exampleFix":"// before\nawait bashTool.execute(id, { command, timeout: 60 * 60 * 1000 }); // ms value -> throws\n\n// after\nawait bashTool.execute(id, { command, timeout: 3600 }); // seconds","handlingStrategy":"validation","validationCode":"const MAX_TIMEOUT_SECONDS = 2_147_483_647 / 1000; // 2147483.647\nconst timeoutSec =\n  rawMs === undefined ? undefined : Math.min(rawMs / 1000, MAX_TIMEOUT_SECONDS);\nawait bashTool.execute(id, { command, timeout: timeoutSec });","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit the field for unlimited runs; there is no default timeout","Never pass raw millisecond values","Cap human-scale budgets at sane second values such as 3600"],"tags":["bash","timeout","unit-confusion","tool-input"],"backgroundTag":"invalid-timeout-value","analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}