Reading a Contract Longer Than Any Context Window on One Key: Chunked Reading With Overlap and Re-Assembly
Learn how to process contracts that exceed any model's context window using chunked reading with overlap and re-assembly. This guide covers chunking strategies, overlap sizing, extraction of key clauses, and reassembly of results, all while using a single API key across multiple models.
Why contracts exceed context windows
Contracts are often long and dense. Even models with large context windows have limits, and feeding an entire agreement can be costly and may hit token limits. Chunked reading solves this by breaking the document into smaller segments that fit within any model's context window.
Chunking strategies
- Fixed-size chunks split text into equal token counts. Simple but may cut through clauses.
- Semantic chunks use paragraph or section boundaries (e.g., by headings, articles, or clauses). Better for legal documents where meaning is tied to structure.
- Hybrid chunks combine fixed size with semantic boundaries: split by section, then further split if a section is too long.
Aim for chunks that preserve logical units—avoid splitting mid-clause when possible.
Overlap: why and how much
Overlap means including a portion of the previous chunk at the start of the next. This prevents losing information at boundaries—such as a clause that spans two chunks. A common approach is to overlap by a few sentences or a fixed number of tokens (e.g., 10-20% of chunk size). For contracts, ensure that any clause beginning near the end of a chunk is fully included in the next.
Reading each chunk with the right model
Not all chunks need the same model. You can route simpler sections (e.g., definitions) to a cheaper model like DeepSeek or Qwen, and complex clauses (e.g., indemnity, termination) to a stronger model like Claude or GPT. With one API key, you can switch between models per request based on content.
Extracting key information
For each chunk, ask the model to extract structured information: clause types, parties, obligations, dates, amounts, and any cross-references. Use a consistent prompt template so outputs are comparable across chunks.
Re-assembling results
After processing all chunks, merge the extracted data. Watch for:
- Duplicates from overlap: deduplicate by clause ID or text similarity.
- Cross-references: a clause in one chunk may refer to another; flag these and resolve if needed.
- Order: preserve original sequence when presenting results.
A final pass with a model can help stitch together a coherent summary or check for conflicts.
Cost and credit considerations
All calls go through the same API key and are billed at official price × 1.3. If you contribute keys, you earn credits at official price × 1.1 (or × 1.2 for premium keys) in USDC. This model works well for chunked reading because you control which model handles each chunk, optimizing for cost and quality.
Practical tips
- Preprocess the contract to normalize formatting and remove page headers/footers.
- Log chunk boundaries and model used for auditability.
- Test overlap size on a sample to ensure no critical text is lost.
- Use a final validation step to catch inconsistencies introduced by chunking.
By combining semantic chunking, adequate overlap, and multi-model routing, you can reliably process contracts of any length without hitting context limits.