Prompt Engineering Context Documents

Chunk Long Documents — Sections Survive the Split

Documentation mode chunks structured documents at heading boundaries, tells the model to reconstruct the section structure, and answers with original headings.

Overview

Structured documents carry their meaning in their structure: a policy clause means something different under a different heading. Documentation mode makes the structure survive the split — section boundaries are preferred break points (the engine breaks early to start a chunk at a heading rather than orphan it), the preamble tells the model the headings mark sections, and the final instructions require answers to reference sections by their original headings. This setup loads a multi-section policy document where heading-aligned chunking is visible in the boundary stats.

Workflow

  1. Let headings drive breaks

    The packer prefers section boundaries — a heading starts a chunk rather than ending one.

  2. Announce the structure

    The preamble declares a structured document; the model reads headings as sections, not decoration.

  3. Answer by section

    Final rules require original-heading references — answers stay auditable against the document.

Why This Works

  • Heading-aligned chunks preserve the hierarchy meaning depends on
  • Declared structure stops sections from blending across chunks
  • Heading-cited answers map straight back to the source document

Best for

  • Policies, contracts, specs, and handbooks
  • Documents whose headings carry legal or technical weight
  • Compliance and review workflows over long documents

Not for

  • Adding delimiters and grounding rules to a document that FITS — that's the Long Input Formatter
  • Generating new documentation — that's the Markdown Output Builder

Use cases

  • Sending policy, spec, and handbook documents in parts
  • Keeping clauses attached to their governing headings
  • Getting answers that cite sections by name

Tip: Save time by exploring related resources and tools that integrate with this workflow.

Explore all resources