deepseek-ai/deepseek-harness · error · Error

tool/result surface replacement may change only content

Error message

tool/result surface replacement may change only content

What it means

Content-only check in assertToolResultRewrite: comparing the original and replacement tool/result events with the content field nulled shows differences beyond content. Tool/result surface replacement may alter only the message content; any change to other fields (tool name, metadata, etc.) is rejected by deep comparison.

Solutions

  1. Change only the content of the tool result in the replacement
  2. Copy all other fields verbatim from the original event
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core/session/src/surface.ts:315 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/d510bb042dae441e. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/session/src/surface.ts:315

  for (const originalSeq of shadowedSeqs) {
    const original = events[originalSeq - baseSeq]
    if (original?.type !== 'tool/result') {
      throw new Error('tool/result surface replacement must target a current tool/result')
    }
    const originalRest = { ...original.data } as Record<string, unknown>
    const replacementRest = { ...event.data } as Record<string, unknown>
    const originalResult = original.data.message.content[0]
    const replacementResult = event.data.message.content[0]
    originalRest['message'] = {
      ...original.data.message,
      content: [{ ...originalResult, content: null }],
    }
    replacementRest['message'] = {
      ...event.data.message,
      content: [{ ...replacementResult, content: null }],
    }
    if (!isDeepEqualJson(originalRest, replacementRest)) {
      throw new Error('tool/result surface replacement may change only content')
    }
  }
}

/** Validate one event at its replay boundary and prepare its atomic fold transition. */
function planSurfaceEvent(
  state: SurfaceFoldState,
  event: SessionEvent,
  expectedSeq: number,
  events: readonly SessionEvent[],
  baseSeq: number,
): SurfacePlan | undefined {
  if (event.seq !== expectedSeq) {
    throw new Error(`session event seq ${event.seq} is not contiguous; expected ${expectedSeq}`)
  }
  const surfaceOp = surfaceOpOf(event)
  if (surfaceOp === undefined) return
  if (surfaceOp === 'append') {

View on GitHub (pinned to b150a551b8)