deepseek-ai/deepseek-harness · error · Error

summary is not smaller than the shadowed content (${framedSu

Error message

summary is not smaller than the shadowed content (${framedSummaryTokenCount} estimated framed tokens >= ${prepared.shadowedTokenCount})

What it means

After the summarizer returns, the replacement checkpoint user message (preamble plus <compacted-summary> framing plus the summary) is priced with the token meter. If its estimated framed tokens are greater than or equal to the shadowed span's tokens, the compaction would not free context, so the transaction rejects it. On a manual compactNow this surfaces wrapped in ManualCompactionError code 'summary' with this error as the cause.

Source

Thrown at packages/compaction/compaction-basic/src/region.ts:375

}

/** Run the summarizer and frame its replacement checkpoint. */
async function summarizeCompaction(
  dependencies: RegionDependencies,
  prepared: PreparedCompaction,
  agent: Agent,
  compactionId: CompactionResult['compactionId'],
  sourceCommandId: CommandId | undefined,
  signal?: AbortSignal,
): Promise<SummarizedCompaction> {
  const summaryResult = await dependencies.summarize(prepared.input, agent, signal)
  const checkpointMessage = createUserMessage({
    content: frameSummary(summaryResult.summary),
    source: compactCheckpointSource(compactionId, sourceCommandId),
  })
  const framedSummaryTokenCount = dependencies.meter.estimateMessage(checkpointMessage)
  if (framedSummaryTokenCount >= prepared.shadowedTokenCount) {
    throw new Error(
      `summary is not smaller than the shadowed content (${framedSummaryTokenCount} estimated framed tokens >= ${prepared.shadowedTokenCount})`,
    )
  }
  return {
    ...prepared,
    ...summaryResult,
    checkpointMessage,
  }
}

/** Reject a summary prepared against any earlier surface generation. */
function assertWholeSurfaceUnchanged(
  dependencies: RegionDependencies,
  session: Session,
  prepared: PreparedCompaction,
): void {
  const current = dependencies.meter.measure(session)
  if (!isDeepStrictEqual(current.nodes, prepared.measurement.nodes)) {

View on GitHub (pinned to b150a551b8)

Solutions

  1. Widen the compacted range so the shadowed token count clearly exceeds summary-plus-framing size
  2. Route summarization to a more concise model via summarizationProvider/summarizationModel
  3. For manual idle compaction, prefer compactNow — it selects a maximal useful range instead of a caller-chosen span
  4. On automatic pressure, lower retainRatio or retainTokens so more head history is compactable

Example fix

// before: 3-node span — framing alone can rival it
await ctx.compaction.compactRegion(nodes[0]!, nodes[2]!, agent)

// after: include enough history that a summary can be strictly smaller
await ctx.compaction.compactRegion(nodes[0]!, balancedEndMuchFartherOut, agent)
Defensive patterns

Strategy: try-catch

Type guard

const isShrinkFailure = (error: unknown): error is Error =>
  error instanceof Error && error.message.startsWith('summary is not smaller than the shadowed content')

Try / catch

try {
  return await ctx.compaction.compactRegion(start, end, agent, signal)
} catch (error) {
  if (isShrinkFailure(error) && canWiden(end)) {
    // widen once to a farther balanced end and retry
    return await ctx.compaction.compactRegion(start, widerBalancedEnd(end), agent, signal)
  }
  throw error
}

Prevention

When it happens

Trigger: Compacting a very short span where the fixed framing overhead rivals the shadowed content; a verbose summarization model that restates the transcript; re-compacting a span that is already mostly one prior checkpoint merged forward near-verbatim.

Common situations: Manual compactRegion on a two- or three-node span; summarization routed to an over-detailed model; repeated compaction cycles over short histories.

Related errors


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