{"record":{"id":"f23bc2fbabeaae5d","repo":"deepseek-ai/deepseek-harness","slug":"session-reference-self-reference","errorCode":"SESSION_REFERENCE_SELF_REFERENCE","errorMessage":"session ${JSON.stringify(targetId)} cannot reference itself","messagePattern":"session (.+?) cannot reference itself","errorType":"validation","errorClass":"SessionReferenceError","httpStatus":null,"severity":"error","filePath":"packages/context/session-reference/src/index.ts","lineNumber":320,"sourceCode":"}\n\nfunction normalizeReferences(\n  targetId: SessionId,\n  references: readonly SessionReferenceInput[],\n  maxReferences: number,\n): Required<SessionReferenceInput>[] {\n  const seen = new Set<SessionId>()\n  const normalized: Required<SessionReferenceInput>[] = []\n  for (const candidate of references as readonly unknown[]) {\n    if (typeof candidate !== 'object' || candidate === null) {\n      throw new SessionReferenceError('session reference must be an object', 'SESSION_REFERENCE_INVALID_REFERENCE')\n    }\n    const reference = candidate as SessionReferenceInput\n    if (typeof reference.sessionId !== 'string' || (reference.label !== undefined && typeof reference.label !== 'string')) {\n      throw new SessionReferenceError('session reference must contain a string sessionId and optional string label', 'SESSION_REFERENCE_INVALID_REFERENCE')\n    }\n    if (reference.sessionId === targetId) {\n      throw new SessionReferenceError(`session ${JSON.stringify(targetId)} cannot reference itself`, 'SESSION_REFERENCE_SELF_REFERENCE')\n    }\n    if (seen.has(reference.sessionId)) continue\n    seen.add(reference.sessionId)\n    normalized.push({ sessionId: reference.sessionId, label: reference.label ?? reference.sessionId })\n  }\n  if (normalized.length > maxReferences) {\n    throw new SessionReferenceError(\n      `a message may reference at most ${maxReferences} sessions`,\n      'SESSION_REFERENCE_TOO_MANY',\n    )\n  }\n  return normalized\n}\n\nfunction renderPrompt(data: readonly ReferencedSessionData[]): string {\n  return `${PROMPT_PREFIX}${stringifyTagSafeJson(data)}${PROMPT_SUFFIX}`\n}\n","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/context/session-reference/src/index.ts#L302-L338","documentation":"Error \"session ${JSON.stringify(targetId)} cannot reference itself\" thrown in deepseek-ai/deepseek-harness.","triggerScenarios":"Thrown at packages/context/session-reference/src/index.ts:320 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reference a different session; a session cannot reference itself."],"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"}