deepseek-ai/deepseek-harness · error · TargetPressureConfigError

BasicCompactionConfig: ${policy.target.provider}/${policy.ta

Error message

BasicCompactionConfig: ${policy.target.provider}/${policy.target.model} retainTokens (${retainTokens}) must be less than threshold tokens ${thresholdTokens}

What it means

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.

Source

Thrown at packages/compaction/compaction-basic/src/config.ts:149

 * @returns detached immutable pressure and retention budgets.
 */
export function resolveCompactSpec(
  policy: ResolvedTargetPolicy,
  contextWindow: number,
): ResolvedCompactSpec {
  const targetKey = `${policy.target.provider}/${policy.target.model}`
  if (!Number.isInteger(contextWindow) || contextWindow <= 0) {
    throw new TargetPressureConfigError(
      targetKey,
      `BasicCompactionConfig: contextWindow (${contextWindow}) must be a positive integer`,
    )
  }
  const thresholdTokens = Math.floor(contextWindow * policy.thresholdRatio)
  const retainTokens = policy.retainTokens === undefined
    ? Math.floor(contextWindow * policy.retainRatio)
    : policy.retainTokens
  if (retainTokens >= thresholdTokens) {
    throw new TargetPressureConfigError(
      targetKey,
      `BasicCompactionConfig: ${policy.target.provider}/${policy.target.model} retainTokens `
      + `(${retainTokens}) must be less than threshold tokens ${thresholdTokens}`,
    )
  }
  return deepFreeze({
    target: { ...policy.target },
    contextWindow,
    thresholdRatio: policy.thresholdRatio,
    thresholdTokens,
    retainTokens,
    summarizationProvider: policy.summarizationProvider,
    summarizationModel: policy.summarizationModel,
    maxTokens: policy.maxTokens,
    compactionRetries: policy.compactionRetries,
    maxOverflowRetries: policy.maxOverflowRetries,
  })
}

View on GitHub (pinned to b150a551b8)

Solutions

  1. 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.
  2. If one config serves several models, add a modelPolicies override for the small-context model with proportionally smaller retention.
  3. Raising thresholdRatio also raises the threshold, but keep it at or below 1.

Example fix

# before — absolute retention tuned on a big model, inherited by a small one
thresholdRatio: 0.8
retainTokens: 200000   # 128k model → threshold 104857 → throws

# after — per-target override scaled to the small model
modelPolicies:
  - provider: deepseek
    model: my-small-model
    retainTokens: 8192
Defensive patterns

Strategy: validation

Validate before calling

const thresholdTokens = Math.floor(contextWindow * policy.thresholdRatio)
const retainTokens = policy.retainTokens ?? Math.floor(contextWindow * policy.retainRatio)
if (retainTokens >= thresholdTokens) {
  // fix before routing: lower retention or raise thresholdRatio for this target
  throw new Error(`retain ${retainTokens} >= threshold ${thresholdTokens} for ${provider}/${model}`)
}

Try / catch

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.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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