{"record":{"id":"95cba1b7ebfa35e5","repo":"deepseek-ai/deepseek-harness","slug":"tool-terminal-maxresultbytes-must-be-a-safe-integ","errorCode":null,"errorMessage":"tool-terminal: maxResultBytes must be a safe integer of at least ${MIN_MAX_RESULT_BYTES}","messagePattern":"tool-terminal: maxResultBytes must be a safe integer of at least (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/terminal/tool-terminal/src/index.ts","lineNumber":150,"sourceCode":"\nfunction rawContentText(content: readonly ContentBlock[]): string | undefined {\n  if (content.length !== 1) return undefined\n  const block = content[0]\n  return block?.type === 'text' ? block.text : undefined\n}\n\nfunction sendDetail(result: TerminalSendResult): string {\n  return result.sessionStatus.kind === 'running'\n    ? `wait: ${result.waitReason}`\n    : `session exited: ${result.sessionStatus.exitCode ?? result.sessionStatus.signal ?? 'unknown'}`\n}\n\n/** Register all terminal tools and the minimal usage guidance. */\nexport function apply(ctx: Context, config: Config = {}): void {\n  const enableRunInBackground = config.enableRunInBackground ?? true\n  const maxResultBytes = config.maxResultBytes ?? DEFAULT_MAX_RESULT_BYTES\n  if (!Number.isSafeInteger(maxResultBytes) || maxResultBytes < MIN_MAX_RESULT_BYTES) {\n    throw new Error(`tool-terminal: maxResultBytes must be a safe integer of at least ${MIN_MAX_RESULT_BYTES}`)\n  }\n  const finalizeContent: NonNullable<ToolDefinition['finalizeContent']> = (_exec, result) => {\n    const raw = rawContentText(result.content)\n    return raw === undefined ? undefined : textResult(raw, maxResultBytes)\n  }\n  ctx.systemPrompt.section({\n    name: 'tool:pty',\n    order: 106,\n    text: 'Use a terminal session only when work needs persistent terminal state or interactive stdin; prefer shell/read/write/edit for bounded one-shot operations. Track every terminal session id and close sessions that no longer matter. An inferred_idle or timeout result does not prove the foreground command exited.',\n  })\n\n  ctx.tools.register(defineTool({\n    name: 'terminal_open',\n    description: 'Create a persistent, owner-isolated terminal session from a registered backend type. Use this for shell or REPL state that must survive across tool calls.',\n    parameters: {\n      type: { type: 'string', required: true, description: 'Registered terminal backend type, usually \"shell\".' },\n      name: { type: 'string', description: 'Optional owner-local display name such as \"main\" or \"gdb\".' },\n      cwd: { type: 'string', description: 'Initial working directory. Defaults to the deployment workspace root.' },","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/terminal/tool-terminal/src/index.ts#L132-L168","documentation":"Error \"tool-terminal: maxResultBytes must be a safe integer of at least ${MIN_MAX_RESULT_BYTES}\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/terminal/tool-terminal/src/index.ts:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set maxResultBytes to a safe integer at or above the documented minimum."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}