deepseek-ai/deepseek-harness · error · SessionReferenceError

SESSION_REFERENCE_INVALID_REFERENCE

SESSION_REFERENCE_INVALID_REFERENCE

Error message

candidate limit must be a positive safe integer

What it means

Error "candidate limit must be a positive safe integer" thrown in deepseek-ai/deepseek-harness.

Source

Thrown at packages/context/session-reference/src/index.ts:165

    return prepared.flat()
  }

  /**
   * List reference candidates, ranked by working-directory affinity.
   * @param agent - target agent; self is excluded and its cwd drives ranking.
   * @param query - optional case-insensitive session-id/cwd/title substring.
   * @param limit - optional positive result cap.
   * @param signal - optional cancellation boundary for host autocomplete teardown.
   * @returns candidates labeled by latest title or, when absent, session id.
   */
  async listCandidates(
    agent: Agent,
    query: string = '',
    limit: number = this.config.candidateLimit,
    signal?: AbortSignal,
  ): Promise<SessionReferenceCandidate[]> {
    if (!Number.isSafeInteger(limit) || limit <= 0) {
      throw new SessionReferenceError('candidate limit must be a positive safe integer', 'SESSION_REFERENCE_INVALID_REFERENCE')
    }
    const needle = query.toLocaleLowerCase()
    const targetCwd = agent.session.header.cwd
    assertNotCancelled(signal)
    const records = (await settleWithCancellation(this.ctx.sessionQuery.listSessions(signal), signal))
      .filter(record => record.header.id !== agent.id)
      .map((record, index) => ({ record, index }))
    const inspected = needle === ''
      ? records
        .sort((a, b) => candidateRank(a.record.header.cwd, targetCwd) - candidateRank(b.record.header.cwd, targetCwd)
          || a.index - b.index)
        .slice(0, limit)
      : records
    const observations = await settleWithCancellation(
      this.ctx.sessionQuery.readTitleSnapshots(inspected.map(({ record }) => record.header.id), signal),
      signal,
    )
    return inspected.map(({ record, index }, observationIndex) => {

View on GitHub (pinned to b150a551b8)

Solutions

  1. Set the candidate limit to a positive safe integer.

When it happens

Trigger: Thrown at packages/context/session-reference/src/index.ts:165 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/3c34bdcc38f6ab96. Report an issue: GitHub.