{"record":{"id":"24cdbcfc9337566c","repo":"deepseek-ai/deepseek-harness","slug":"summary-is-not-smaller-than-the-shadowed-content","errorCode":null,"errorMessage":"summary is not smaller than the shadowed content (${framedSummaryTokenCount} estimated framed tokens >= ${prepared.shadowedTokenCount})","messagePattern":"summary is not smaller than the shadowed content \\((.+?) estimated framed tokens >= (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/compaction/compaction-basic/src/region.ts","lineNumber":375,"sourceCode":"}\n\n/** Run the summarizer and frame its replacement checkpoint. */\nasync function summarizeCompaction(\n  dependencies: RegionDependencies,\n  prepared: PreparedCompaction,\n  agent: Agent,\n  compactionId: CompactionResult['compactionId'],\n  sourceCommandId: CommandId | undefined,\n  signal?: AbortSignal,\n): Promise<SummarizedCompaction> {\n  const summaryResult = await dependencies.summarize(prepared.input, agent, signal)\n  const checkpointMessage = createUserMessage({\n    content: frameSummary(summaryResult.summary),\n    source: compactCheckpointSource(compactionId, sourceCommandId),\n  })\n  const framedSummaryTokenCount = dependencies.meter.estimateMessage(checkpointMessage)\n  if (framedSummaryTokenCount >= prepared.shadowedTokenCount) {\n    throw new Error(\n      `summary is not smaller than the shadowed content (${framedSummaryTokenCount} estimated framed tokens >= ${prepared.shadowedTokenCount})`,\n    )\n  }\n  return {\n    ...prepared,\n    ...summaryResult,\n    checkpointMessage,\n  }\n}\n\n/** Reject a summary prepared against any earlier surface generation. */\nfunction assertWholeSurfaceUnchanged(\n  dependencies: RegionDependencies,\n  session: Session,\n  prepared: PreparedCompaction,\n): void {\n  const current = dependencies.meter.measure(session)\n  if (!isDeepStrictEqual(current.nodes, prepared.measurement.nodes)) {","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/compaction/compaction-basic/src/region.ts#L357-L393","documentation":"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.","triggerScenarios":"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.","commonSituations":"Manual compactRegion on a two- or three-node span; summarization routed to an over-detailed model; repeated compaction cycles over short histories.","solutions":["Widen the compacted range so the shadowed token count clearly exceeds summary-plus-framing size","Route summarization to a more concise model via summarizationProvider/summarizationModel","For manual idle compaction, prefer compactNow — it selects a maximal useful range instead of a caller-chosen span","On automatic pressure, lower retainRatio or retainTokens so more head history is compactable"],"exampleFix":"// before: 3-node span — framing alone can rival it\nawait ctx.compaction.compactRegion(nodes[0]!, nodes[2]!, agent)\n\n// after: include enough history that a summary can be strictly smaller\nawait ctx.compaction.compactRegion(nodes[0]!, balancedEndMuchFartherOut, agent)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isShrinkFailure = (error: unknown): error is Error =>\n  error instanceof Error && error.message.startsWith('summary is not smaller than the shadowed content')","tryCatchPattern":"try {\n  return await ctx.compaction.compactRegion(start, end, agent, signal)\n} catch (error) {\n  if (isShrinkFailure(error) && canWiden(end)) {\n    // widen once to a farther balanced end and retry\n    return await ctx.compaction.compactRegion(start, widerBalancedEnd(end), agent, signal)\n  }\n  throw error\n}","preventionTips":["Never compact spans only a few nodes long — checkpoint framing is a fixed cost the summary must beat","Route summarization to a concise model so output stays well under the shadowed size","For idle compaction use compactNow, which selects a maximal useful range for you"],"tags":["compaction","summarization","token-budget"],"backgroundTag":"summary-exceeds-source-size","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}