Skip to content

ERR_AI_CONTEXT_TOO_LONG β€” AI Context Too Long

HTTP Status: 400 Retryable: No Automatic retry: None. This is a document characteristic that will fail consistently for the same input.

What the User Sees

This document is too complex for a single conversion pass. (ERR_AI_CONTEXT_TOO_LONG)

What Causes This Error

The document page produced HTML output that exceeds the AI model’s context window. For Claude, this limit is 200,000 tokens. This typically happens with extremely dense pages containing massive tables, embedded data, or very long continuous text blocks.

The chunked pipeline normally prevents this by splitting documents into page-range chunks, but individual pages can still exceed limits. A single page with a large data table (hundreds of rows and dozens of columns) can easily generate more than 200k tokens of HTML when all the table markup is included.

The error is detected when the AI provider returns a context_length_exceeded or equivalent error during the conversion API call. Since the same document will produce the same output on retry, this error is not retryable.

Mathematical documents with extensive LaTeX notation and documents with embedded SVG graphics are also common triggers, as these generate verbose markup relative to their visual density.

Resolution Steps

For Users

  1. Use page ranges to convert smaller sections of the document at a time, avoiding the problematic page.
  2. Try the β€œbudget” quality tier, which uses simpler processing that may produce less verbose output.
  3. If the problematic page contains a very large table, consider splitting the table across multiple pages in the source document before re-exporting as PDF.
  4. Try converting with a different quality tier β€” different AI models have different context window sizes.

For Administrators

  1. No immediate admin action is needed β€” this is a document characteristic, not a system issue.
  2. If this error is reported frequently, consider lowering maxTokensPerTurn in the agentic vision converter configuration to produce more concise output per iteration.
  3. Review the conversion logs for the specific file to identify which page caused the overflow. The structured log will include token counts.
  4. Consider implementing automatic page-level chunking for pages that exceed a token threshold (currently the chunking is at the multi-page level).