{"record":{"id":"898edeb87f039f82","repo":"deepseek-ai/deepseek-harness","slug":"invalid-replay-state","errorCode":"INVALID_REPLAY_STATE","errorMessage":"invalid pi-ai replay state: ${message}","messagePattern":"invalid pi-ai replay state: (.+?)","errorType":"exception","errorClass":"LlmError","httpStatus":null,"severity":"error","filePath":"packages/llm/llm-pi-ai/src/replay.ts","lineNumber":106,"sourceCode":"          type: 'text',\n          ...block.textSignature === undefined ? {} : { textSignature: block.textSignature },\n        }\n        case 'thinking': return {\n          type: 'reasoning',\n          ...block.thinkingSignature === undefined ? {} : { thinkingSignature: block.thinkingSignature },\n          ...block.redacted === undefined ? {} : { redacted: block.redacted },\n        }\n        case 'toolCall': return {\n          type: 'tool-call',\n          ...block.thoughtSignature === undefined ? {} : { thoughtSignature: block.thoughtSignature },\n        }\n      }\n    }),\n  }\n}\n\nfunction invalidReplay(message: string): never {\n  throw new LlmError(`invalid pi-ai replay state: ${message}`, 'INVALID_REPLAY_STATE')\n}\n\n/** Validate the durable adapter-private envelope before it reaches pi-ai. */\nfunction readReplayState(value: unknown): PiAiReplayState {\n  if (typeof value !== 'object' || value === null || Array.isArray(value)) return invalidReplay('expected a replay envelope')\n  const envelope = value as Record<string, unknown>\n  const rawResponse = envelope['response']\n  if (typeof rawResponse !== 'object' || rawResponse === null || Array.isArray(rawResponse)) return invalidReplay('expected a response object')\n  const response = rawResponse as Record<string, unknown>\n  if (response['kind'] !== 'pi-ai') return invalidReplay('unknown state kind')\n  if (response['version'] !== 2) return invalidReplay(`unsupported version ${String(response['version'])}`)\n  for (const key of ['api', 'provider', 'model'] as const) {\n    if (typeof response[key] !== 'string' || response[key].length === 0) return invalidReplay(`${key} must be a non-empty string`)\n  }\n  if (!['stop', 'length', 'toolUse', 'error', 'aborted'].includes(String(response['stopReason']))) {\n    return invalidReplay('unknown stopReason')\n  }\n  if (response['responseModel'] !== undefined && typeof response['responseModel'] !== 'string') return invalidReplay('responseModel must be a string')","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/llm/llm-pi-ai/src/replay.ts#L88-L124","documentation":"Error \"invalid pi-ai replay state: ${message}\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/llm/llm-pi-ai/src/replay.ts:106 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the replay state per the included message; regenerate or repair the corrupted session segment."],"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"}