{"record":{"id":"b9eaff1f2445e514","repo":"deepseek-ai/deepseek-harness","slug":"basiccompactionconfig-policy-target-provider","errorCode":null,"errorMessage":"BasicCompactionConfig: ${policy.target.provider}/${policy.target.model} retainTokens (${retainTokens}) must be less than threshold tokens ${thresholdTokens}","messagePattern":"BasicCompactionConfig: (.+?)/(.+?) retainTokens \\((.+?)\\) must be less than threshold tokens (.+?)","errorType":"validation","errorClass":"TargetPressureConfigError","httpStatus":null,"severity":"error","filePath":"packages/compaction/compaction-basic/src/config.ts","lineNumber":149,"sourceCode":" * @returns detached immutable pressure and retention budgets.\n */\nexport function resolveCompactSpec(\n  policy: ResolvedTargetPolicy,\n  contextWindow: number,\n): ResolvedCompactSpec {\n  const targetKey = `${policy.target.provider}/${policy.target.model}`\n  if (!Number.isInteger(contextWindow) || contextWindow <= 0) {\n    throw new TargetPressureConfigError(\n      targetKey,\n      `BasicCompactionConfig: contextWindow (${contextWindow}) must be a positive integer`,\n    )\n  }\n  const thresholdTokens = Math.floor(contextWindow * policy.thresholdRatio)\n  const retainTokens = policy.retainTokens === undefined\n    ? Math.floor(contextWindow * policy.retainRatio)\n    : policy.retainTokens\n  if (retainTokens >= thresholdTokens) {\n    throw new TargetPressureConfigError(\n      targetKey,\n      `BasicCompactionConfig: ${policy.target.provider}/${policy.target.model} retainTokens `\n      + `(${retainTokens}) must be less than threshold tokens ${thresholdTokens}`,\n    )\n  }\n  return deepFreeze({\n    target: { ...policy.target },\n    contextWindow,\n    thresholdRatio: policy.thresholdRatio,\n    thresholdTokens,\n    retainTokens,\n    summarizationProvider: policy.summarizationProvider,\n    summarizationModel: policy.summarizationModel,\n    maxTokens: policy.maxTokens,\n    compactionRetries: policy.compactionRetries,\n    maxOverflowRetries: policy.maxOverflowRetries,\n  })\n}","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/deepseek-ai/deepseek-harness/blob/b150a551b8d465e31e418e1b2eaf5e79bbb7d28e/packages/compaction/compaction-basic/src/config.ts#L131-L167","documentation":"resolveCompactSpec computes thresholdTokens = floor(contextWindow × thresholdRatio) and requires the resolved retainTokens (explicit retainTokens, or floor(contextWindow × retainRatio)) to be strictly below it — retention that meets or exceeds the trigger pressure makes compaction self-defeating. Like the contextWindow check it throws TargetPressureConfigError keyed by the exact provider/model.","triggerScenarios":"A policy whose retainTokens is at or above thresholdRatio × contextWindow for the routed model — e.g. retainTokens: 200000 on a 131072-token model at thresholdRatio 0.8 (threshold 104857); or a small-context model inheriting a large absolute retainTokens.","commonSituations":"Copying an absolute retainTokens value tuned on a large-context model onto a smaller model; lowering thresholdRatio without re-checking retention; setting retainTokens close to the model's full window.","solutions":["Compute floor(contextWindow × thresholdRatio) for the failing target and set retainTokens strictly below it — or drop retainTokens and use retainRatio, which scales with the model.","If one config serves several models, add a modelPolicies override for the small-context model with proportionally smaller retention.","Raising thresholdRatio also raises the threshold, but keep it at or below 1."],"exampleFix":"# before — absolute retention tuned on a big model, inherited by a small one\nthresholdRatio: 0.8\nretainTokens: 200000   # 128k model → threshold 104857 → throws\n\n# after — per-target override scaled to the small model\nmodelPolicies:\n  - provider: deepseek\n    model: my-small-model\n    retainTokens: 8192","handlingStrategy":"validation","validationCode":"const thresholdTokens = Math.floor(contextWindow * policy.thresholdRatio)\nconst retainTokens = policy.retainTokens ?? Math.floor(contextWindow * policy.retainRatio)\nif (retainTokens >= thresholdTokens) {\n  // fix before routing: lower retention or raise thresholdRatio for this target\n  throw new Error(`retain ${retainTokens} >= threshold ${thresholdTokens} for ${provider}/${model}`)\n}","typeGuard":null,"tryCatchPattern":"Catch TargetPressureConfigError and branch on targetKey, same as the contextWindow case: repair the policy for targets in use, warn-and-skip otherwise; rethrow any other error.","preventionTips":["Prefer retainRatio over retainTokens in mixed-model fleets — ratios cannot collide with a small window.","Re-run the arithmetic whenever thresholdRatio or model capacity changes.","Validate modelPolicies against the smallest context window that can receive them."],"tags":["compaction","config","validation","token-budgets"],"backgroundTag":"config-validation-failed","analyzedSha":"b150a551b8d465e31e418e1b2eaf5e79bbb7d28e","analyzedAt":"2026-08-24T18:12:29.105Z","schemaVersion":2},"datasetVersion":"2026-08-24T22:17:12.610Z"}