deepseek-ai/deepseek-harness · error · GoalError

GOAL_STALE_REVISION

GOAL_STALE_REVISION

Error message

stale goal ref "${ref.id}" revision ${ref.revision}; current is "${current.id}" revision ${current.revision}

What it means

Optimistic-concurrency guard in expectCurrent: the caller's GoalRef (id and revision) does not match the projected current goal, so the mutation would build on stale state. The message names both the stale and current revisions.

Solutions

  1. Re-read the goal with get_goal and copy its exact goal_id and revision
  2. Retry the mutation with the fresh ref
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/goal/goal/src/index.ts:405 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/6f322e8790c746d5. Report an issue: GitHub.

Appendix: source

Thrown at packages/goal/goal/src/index.ts:405

    }
    this.commit(agent, cache, change, 'disarmed')
    return { ...tombstone }
  }

  /** Resolve and validate the cache used by a mutation. */
  private prepareMutation(agent: Agent): GoalCache {
    this.assertLive(agent)
    const cache = this.cache(agent.session)
    this.sync(agent.session, cache)
    return cache
  }

  /** Reject stale or missing current-state refs. */
  private expectCurrent(cache: GoalCache, ref: GoalRef): GoalSnapshot {
    const current = cache.state.goal
    if (current === undefined) throw new GoalError('no current goal', 'GOAL_NOT_FOUND')
    if (ref.id !== current.id || ref.revision !== current.revision) {
      throw new GoalError(
        `stale goal ref "${ref.id}" revision ${ref.revision}; current is "${current.id}" revision ${current.revision}`,
        'GOAL_STALE_REVISION',
      )
    }
    return current
  }

  /** Enforce exact live-agent identity rather than trusting a matching id. */
  private assertLive(agent: Agent): void {
    if (this.ctx.agents.get(agent.id) !== agent) {
      throw new GoalError(`agent "${agent.id}" is not live in this registry`, 'GOAL_AGENT_NOT_LIVE')
    }
  }

  /** Return the per-session cache, folding a seed once with activation disarmed. */
  private cache(session: Session): GoalCache {
    let cache = this.caches.get(session)
    if (cache !== undefined) return cache

View on GitHub (pinned to b150a551b8)