The Optional section and the context budget: telling agents what they can skip

How to use the proposal’s Optional section convention, how to work out a token budget, and how to read our tokenEstimate, with a practical checklist for allocating the budget.

About 2 min readError codes covered: TOKEN_ESTIMATEFILE_SIZE

Context windows are limited. In the words of the proposal, “every wasted token costs time and money”. This guide shows how to manage the context cost of llms.txt deliberately.

The Optional section convention

By the convention in the proposal, an H2 section named ## Optional holds secondary links; when context is tight, an agent may skip those entries. It is a convention, not a requirement: there is no assurance that every agent follows it, but it gives agents an explicit signal for degrading gracefully.

Rules of thumb:

  • Core documentation (getting started, API, key guides) goes in ordinary sections.
  • Nice-to-haves (example libraries, historical versions, community resources) go in Optional.
  • Put the Optional section at the end of the file: with truncation-style degradation (the agent reads only the first N tokens), the secondary content is the first to be dropped.

Budgeting with our tokenEstimate

The metrics area of a check report gives tokenEstimate (a local estimate with js-tiktoken cl100k_base; the method version is recorded with the report). It is an estimate of how much context this file takes up. A budgeting checklist:

  1. Look at the current estimate in the metrics area of the report.
  2. Set a target: the system prompt and conversation of a typical agent already take several thousand tokens, so we suggest keeping an index file within a few thousand tokens (a rule of thumb, not something the proposal specifies).
  3. When over budget, cut Optional first, then note text, and links only last.
  4. Check again after the change and compare the estimates before and after.

How FILE_SIZE and TOKEN_ESTIMATE divide the work

FILE_SIZE observes volume (transfer bytes and decoded bytes are counted separately); TOKEN_ESTIMATE estimates context cost. Both belong to “practical usability / metrics” rather than proposal clauses: they give a WARN or a number and do not convict on their own. Exceeding the 2 MB decoded limit triggers TOO_LARGE and truncation, and the report states the truncation truthfully (see size and timeouts).

Test environment and results

Environment: Node v24.18.0, the llmstxtdb validator, tested on 2026-10-05. A real index file with 98 links (nextjs.org/docs/llms.txt) tested at tokenEstimate≈10787 and sectionCount=7, which can serve as a reference for what a large file looks like. An empty file tested at an estimate of 0, and the report gave the conclusion “empty file” (a real 0 is not the same as “not counted”).