deepseek-ai/deepseek-harness · error · AttachmentError

IMAGE_TOO_LARGE

IMAGE_TOO_LARGE

Error message

Image cannot be encoded within the model-request byte budget.

What it means

Error "Image cannot be encoded within the model-request byte budget." thrown in deepseek-ai/deepseek-harness.

Source

Thrown at packages/attachment/attachment-local/src/request-image.ts:184

      width: attachment.ref.width,
      height: attachment.ref.height,
    }
  }
  const lowColour = await hasLowColourCount(sourcePipeline(attachment))
  for (;;) {
    const encodedVersion = await encodeFirstWithinLimit(
      encodingAttempts(attachment, dimensions.width, dimensions.height, hasAlpha, lowColour),
      policy.maxBytes,
    )
    if (!isExhaustedEncoding(encodedVersion)) return encodedVersion
    if (dimensions.width === 1 && dimensions.height === 1) break
    const scale = Math.min(0.9, Math.sqrt(policy.maxBytes / encodedVersion.smallest.data.byteLength) * 0.95)
    dimensions = {
      width: Math.max(1, Math.floor(dimensions.width * scale)),
      height: Math.max(1, Math.floor(dimensions.height * scale)),
    }
  }
  throw new AttachmentError('Image cannot be encoded within the model-request byte budget.', 'IMAGE_TOO_LARGE')
}

function cachePath(root: string, hash: string): string {
  return join(root, 'request-images', hash.slice(0, 2), hash)
}

async function readCached(
  path: string,
  attachment: StoredImageAttachment,
  policy: ImageRequestPolicy,
  expectedAlpha: boolean,
  signal?: AbortSignal,
): Promise<VerifiedRequestImage | undefined> {
  try {
    const data = new Uint8Array(await readFile(path, { signal }))
    const detected = await probeImage(data)
    const maximum = requestImageDimensions(attachment.ref.width, attachment.ref.height, policy.maxPixels)
    if (data.byteLength > policy.maxBytes || detected.depth !== 'uchar' || detected.space !== 'srgb'

View on GitHub (pinned to b150a551b8)

Solutions

  1. Reduce image size or count so the encoded images fit the model-request byte budget.

When it happens

Trigger: Thrown at packages/attachment/attachment-local/src/request-image.ts:184 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/a316dc58dfed3530. Report an issue: GitHub.