{"record":{"id":"7eb03d2a3e4469bd","repo":"deepseek-ai/deepseek-harness","slug":"agent-maxtokens-must-be-a-positive-safe-integer","errorCode":null,"errorMessage":"agent maxTokens must be a positive safe integer","messagePattern":"agent maxTokens must be a positive safe integer","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/agent-loop/src/index.ts","lineNumber":145,"sourceCode":"    }\n    throw error\n  }\n}\n\n/** Resolve the deployment-wide scheduler cap at the owning config boundary. */\nfunction resolveMaxParallelToolCalls(value: number | undefined): number {\n  const maxParallelToolCalls = value ?? DEFAULT_MAX_PARALLEL_TOOL_CALLS\n  if (!Number.isInteger(maxParallelToolCalls) || maxParallelToolCalls < 1) {\n    throw new Error('maxParallelToolCalls must be a positive integer')\n  }\n  return maxParallelToolCalls\n}\n\n/** Reject an output-token cap that cannot be represented exactly on the request wire. */\nfunction assertAgentOptions(options: AgentOptions): void {\n  if (options.maxTokens !== undefined\n    && (!Number.isSafeInteger(options.maxTokens) || options.maxTokens <= 0)) {\n    throw new TypeError('agent maxTokens must be a positive safe integer')\n  }\n}\n\n/** Prepared-but-unpublished agent resources sharing one memoized teardown. */\ninterface PreparedAgent {\n  agent: ReactLoopAgent\n  /** Aborts when the factory unloads, the caller cancels, or teardown begins — ends any setup await. */\n  signal: AbortSignal\n  /** Enter registries, announce, notify session-start, and start the machine. */\n  publish(source: SessionStartSource): AgentHandle\n  /** Reverse teardown: stop the machine, unregister, unwind the scope. Memoized. */\n  dispose(): Promise<void>\n}\n\ndeclare module '@deepseek-ai/cordis' {\n  interface Context {\n    agentLoop: AgentLoop\n    /**","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/core/agent-loop/src/index.ts#L127-L163","documentation":"Error \"agent maxTokens must be a positive safe integer\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/core/agent-loop/src/index.ts:145 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the agent maxTokens to a positive safe integer."],"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"}