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.

How to use this resource

  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

FAQ

Why does the chunked package make the model reply "Received chunk 1 of 2" before I send more?

To keep the parts in order and unmerged: the DELIVERY INSTRUCTIONS say send each chunk as one message and wait for the acknowledgement ("Received chunk i of 2") before the next. Long Prompt Splitter builds that handshake in; the model holds its answer until the final part announces completion, then the ALL CHUNKS DELIVERED block tells it to reconstruct the structure before responding.

How does chunking avoid cutting a policy section in half?

Documentation Mode prefers section boundaries as break points, so a heading like ## Access Controls starts a chunk rather than being orphaned. The CHUNK STRATEGY reports boundary quality, in the example "1 section break, 0 paragraph breaks, 0 line-level breaks, 0 hard cuts," evidence the split landed on a heading, not mid-clause where meaning depends on the section it sits under.

Do I still need this if my document already fits the context window?

Not then, chunking is for documents too large for one message. If the source fits, adding delimiters and grounding rules is the Long Input Formatter's job instead. Here the CHUNK STRATEGY sized the content into 2 chunks at roughly 8,000 tokens each against Gemini Pro's window; a document under that budget skips the split-and-acknowledge flow.

More resources from Long Prompt Splitter

Resources that pair well

Related tools

Workflows that use this resource

Guides for this resource

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