This playbook is for AI engineers and application developers who need to process documents larger than a single context window. The two-stage strategy first summarizes processed sections into a dense state payload, then continues with the remaining content while preserving key entities, relationships, and facts. Use this when a document is too large for one pass and you cannot simply truncate or skip sections. This prompt belongs in document intelligence pipelines, long-form report generation, contract review systems, and any workflow where fact retention across the context boundary is critical.
Prompt
Summarize-Then-Continue Prompt for Long Documents

When to Use This Prompt
Determine if the Summarize-Then-Continue strategy is the right fit for your long-document processing pipeline.
The ideal user is building a production system where document completeness matters. For example, a legal tech platform processing 200-page contracts needs every clause examined, not just the first 50 pages. A financial analyst tool reviewing annual reports must track entity relationships and numeric values across sections. An academic research assistant synthesizing multiple papers needs to preserve citation chains and methodology details. In each case, the Summarize-Then-Continue prompt provides a structured handoff between processing windows, carrying forward a compressed but faithful representation of what was already read. The prompt template expects a [DOCUMENT_SECTION] input, a [PREVIOUS_SUMMARY] state payload, and an [EXTRACTION_SCHEMA] defining what entities, facts, and relationships to preserve. The output is a continuation analysis plus an updated summary ready for the next window.
Do not use this prompt for real-time chat or short-form content where a sliding window summary is more appropriate. If your documents fit comfortably within a single context window, a standard extraction or analysis prompt is simpler and less error-prone. Avoid this strategy when the task requires cross-referencing arbitrary sections that may be far apart—the summary state is lossy by design, and critical connections can be missed. Also avoid it when latency is the primary constraint; the two-stage handoff adds processing overhead. For high-risk domains like healthcare or legal, always include a human review step after the full document is processed, and run eval checks comparing the final output against spot-checked original sections to measure fact retention accuracy. Before implementing, define your retry budget: if the model produces an incomplete summary that breaks the continuation, how many times will you re-prompt before escalating to a human operator or splitting the document differently?
Next, review the prompt template section to copy the base instruction and adapt the placeholders to your document type and extraction requirements. Then move to the implementation harness to wire the two-stage loop into your application with proper validation, logging, and failure recovery.
Use Case Fit
Where the Summarize-Then-Continue prompt works and where it introduces risk. Use these cards to decide if this pattern fits your workflow before wiring it into production.
Good Fit: Long-Form Document Processing
Use when: Processing documents that exceed the context window, such as legal contracts, research papers, or technical manuals. Guardrail: The two-stage design preserves key entities and relationships across the boundary, making it suitable for tasks where fact retention matters more than perfect prose continuity.
Bad Fit: Real-Time Streaming or Low-Latency Workflows
Avoid when: The user expects a single, instantaneous response. Risk: The two-stage prompt doubles latency and compute cost. Guardrail: For streaming use cases, prefer a sliding window summary or context eviction strategy instead of a full stop-and-continue pattern.
Required Inputs: A Stable Document Boundary
What to watch: The prompt requires a clear, predictable split point in the source document. Risk: Arbitrary mid-sentence or mid-table splits cause entity fragmentation and broken references. Guardrail: Pre-process documents to split on natural boundaries (paragraphs, sections) and pass the split metadata into the prompt.
Operational Risk: Silent Fact Drift Across the Boundary
What to watch: The summary stage may omit or distort a critical fact that the continuation stage then builds upon incorrectly. Risk: Compounding errors across stages without detection. Guardrail: Implement a fact-retention eval that checks if named entities, numbers, and key claims from the first section appear in the final output.
Operational Risk: Unbounded Retry Loops
What to watch: If the continuation stage fails validation, a naive retry loop may re-summarize and re-continue indefinitely. Risk: Compute waste and escalating latency. Guardrail: Set a hard retry budget (e.g., 2 attempts) and escalate to a human or fallback model after exhaustion. Log the summary and continuation for debugging.
Variant: When to Use Chunking Instead
What to watch: Summarize-Then-Continue is overkill for documents that can be cleanly chunked and processed independently. Risk: Unnecessary complexity and latency. Guardrail: If the task does not require cross-section synthesis (e.g., per-page extraction), use a map-reduce chunking pattern with a merge step instead.
Copy-Ready Prompt Template
A two-stage prompt template that summarizes processed content, then continues with the next chunk using the summary as preserved state.
This template implements a summarize-then-continue pattern for documents that exceed the model's context window. Stage 1 processes a chunk of content and produces a structured summary capturing key entities, relationships, claims, and the boundary point where processing stopped. Stage 2 receives that summary as preserved state alongside the next chunk, allowing the model to continue analysis without re-reading the original text. The template is designed for sequential processing pipelines where each chunk's output feeds the next chunk's input.
codeSTAGE 1: SUMMARIZE PROCESSED CONTENT You are processing a long document in chunks. Your job is to read the current chunk, extract structured information, and produce a summary that will be passed to the next processing stage. ## INPUT [CHUNK_TEXT] ## PREVIOUS STATE (if any) [PREVIOUS_SUMMARY or "This is the first chunk."] ## INSTRUCTIONS 1. Read the current chunk and identify: - Named entities (people, organizations, locations, products) - Key claims or findings with their supporting evidence - Relationships between entities - Dates, numbers, and metrics - Decisions, action items, or conclusions - The exact boundary text where this chunk ends 2. Produce a structured summary in the following format: ## OUTPUT SCHEMA { "chunk_index": [CHUNK_INDEX], "entities": [ { "name": "string", "type": "person|organization|location|product|other", "mentions": ["relevant context from chunk"], "relationships": ["relationship descriptions"] } ], "claims": [ { "claim": "string", "evidence": "supporting text from chunk", "confidence": "high|medium|low" } ], "metrics": [ { "name": "string", "value": "string or number", "context": "surrounding context" } ], "decisions_and_actions": ["list of decisions or action items"], "boundary_marker": "exact last sentence or phrase processed", "unresolved_questions": ["questions raised but not yet answered"], "narrative_summary": "2-3 sentence prose summary of this chunk" } ## CONSTRAINTS - Preserve exact numbers, dates, and proper nouns without paraphrasing. - Mark claims as low confidence if evidence is ambiguous or incomplete. - Include the boundary marker verbatim to enable exact continuation. - Do not invent entities or claims not present in the chunk. - If this is not the first chunk, integrate new entities with those from the previous summary. --- STAGE 2: CONTINUE WITH NEXT CHUNK You are continuing to process a long document. You have a summary of all previously processed content. Use it to maintain continuity while processing the next chunk. ## PREVIOUS STATE SUMMARY [STAGE_1_OUTPUT] ## NEXT CHUNK [NEXT_CHUNK_TEXT] ## INSTRUCTIONS 1. Review the previous state summary to understand: - All entities, claims, and relationships discovered so far - Unresolved questions that this chunk might answer - The exact boundary where previous processing stopped 2. Process the next chunk, updating the state: - Add new entities and merge with existing ones when the same entity appears - Add new claims and note if they resolve prior unresolved questions - Update relationships as new connections emerge - Track metrics across chunks (cumulative totals, trends) - Record new decisions and actions 3. Produce an updated summary using the same schema as Stage 1, but with cumulative state: ## OUTPUT SCHEMA { "chunk_index": [CHUNK_INDEX], "cumulative_entities": [/* merged entity list */], "cumulative_claims": [/* all claims across chunks */], "cumulative_metrics": [/* all metrics with cross-chunk context */], "cumulative_decisions_and_actions": [/* all decisions and actions */], "boundary_marker": "exact last sentence processed in this chunk", "resolved_questions": ["previously unresolved questions now answered"], "new_unresolved_questions": ["new questions raised in this chunk"], "cross_chunk_narrative": "2-3 sentence summary connecting this chunk to prior content", "processing_complete": false } ## CONSTRAINTS - Do not re-process content from previous chunks; rely on the provided summary. - When the same entity appears across chunks, merge information under one entry. - Flag contradictions between chunks if claims conflict. - Set processing_complete to true only when the final chunk is processed. - If the chunk appears to repeat prior content, note the overlap rather than duplicating entries.
Adapt this template by adjusting the output schema to match your domain's entity types, claim structures, and metric categories. For legal documents, add fields for clauses, obligations, and parties. For clinical documents, add fields for medications, conditions, and procedures. For financial documents, add fields for transactions, accounts, and compliance flags. The boundary marker is critical for resumability—always capture the exact text where processing stopped. If your pipeline processes more than two chunks, repeat Stage 2 for each subsequent chunk, passing the cumulative summary forward each time. Add a final Stage 3 if you need to produce a document-level synthesis from all cumulative summaries.
Before deploying this prompt into a production pipeline, build validation checks that verify the boundary marker matches the actual end of the chunk, entities are not hallucinated by cross-referencing against source text, and cumulative state does not grow unbounded across many chunks. For high-stakes domains like legal or clinical review, require human spot-checking of entity merges and claim confidence scores. Test with documents that contain deliberate cross-chunk references—entities introduced in chunk 1 and referenced again in chunk 3—to verify that the summary preserves enough state for correct resolution. The most common failure mode is entity duplication when the same person or organization appears with slightly different names across chunks; add normalization instructions to your schema if this risk is high.
Prompt Variables
Required inputs for the Summarize-Then-Continue prompt. Each variable must be populated before the first stage executes. Validation checks prevent silent failures when the model receives empty or malformed inputs.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[DOCUMENT_TEXT] | The full source document that exceeds the context window and must be processed in stages | A 50-page contract PDF extracted to plain text via a document loader | Must be a non-empty string. If null or whitespace-only, abort before stage one. Check length against [MAX_TOKENS_PER_STAGE] to confirm overflow condition exists |
[MAX_TOKENS_PER_STAGE] | The token budget allocated for each processing stage, including both input and output tokens | 6000 | Must be a positive integer. Validate that the value is less than the model's total context limit. If [MAX_TOKENS_PER_STAGE] exceeds the model limit, throw a configuration error before execution |
[STAGE_ONE_SUMMARY_INSTRUCTION] | The instruction template that tells the model how to summarize the first chunk, including which entities, relationships, and facts to preserve | Extract all named entities, key claims, numerical data, and decisions from the text below. Preserve exact quotes for critical statements. | Must be a non-empty string. Validate that the instruction explicitly requests entity preservation, fact retention, or quote extraction. Vague instructions like 'summarize this' will cause fact loss across the boundary |
[STAGE_TWO_CONTINUATION_INSTRUCTION] | The instruction template that tells the model how to continue processing the remaining text while incorporating the stage-one summary | Using the summary above as prior context, continue processing the remaining document text below. Maintain the same extraction format and preserve all new entities and facts. | Must reference the summary output from stage one. Validate that the instruction includes a placeholder or reference to [STAGE_ONE_SUMMARY]. Missing this reference causes the model to treat stage two as a fresh start and lose continuity |
[OUTPUT_SCHEMA] | The structured format definition for both stages, ensuring consistent output that can be merged after completion | JSON schema with fields: entities (array of {name, type, mentions}), claims (array of {text, source_section, confidence}), facts (array of {statement, evidence}), and continuation_marker (string indicating last processed position) | Must be a valid JSON Schema or explicit field specification. Validate that both stages use the same schema. Schema mismatch between stages prevents reliable merging. Include a continuation_marker field to track processing position |
[OVERLAP_TOKENS] | The number of tokens to overlap between consecutive chunks to prevent fact loss at chunk boundaries | 500 | Must be a non-negative integer. Validate that [OVERLAP_TOKENS] is less than [MAX_TOKENS_PER_STAGE]. Zero overlap is allowed but increases boundary-loss risk. Recommended minimum: 10% of [MAX_TOKENS_PER_STAGE] |
[FACT_RETENTION_CHECKLIST] | A list of critical fact categories that must survive the summarization boundary, used for post-hoc evaluation | ['dates', 'monetary amounts', 'party names', 'obligation statements', 'deadlines', 'termination conditions'] | Must be a non-empty array of strings. Validate that each category maps to extractable content in the document domain. Generic categories like 'important stuff' produce unreliable eval results |
[CONTINUATION_TRIGGER] | The condition that determines when to invoke stage two, typically based on remaining unprocessed text length or a sentinel token | remaining_text_token_count > 0 OR explicit [CONTINUE] marker in stage one output | Must be a boolean expression or function reference. Validate that the trigger prevents infinite loops. If stage one output contains no continuation_marker and remaining text is empty, the workflow must terminate rather than retry |
Implementation Harness Notes
How to wire the Summarize-Then-Continue prompt into a production application with validation, retries, and state management.
The Summarize-Then-Continue pattern requires a two-stage harness that manages state between the summarization pass and the continuation pass. The application layer—not the model—must track which document sections have been processed, store the intermediate summary, and inject it into the continuation prompt. This is not a single prompt call; it is a stateful pipeline where the output of stage one becomes a critical input to stage two. The harness should treat the summary as a structured artifact with a schema (entities, relationships, key claims, and a section pointer) rather than a free-text blob, because the continuation prompt needs to reference specific facts without ambiguity.
Wire the pipeline as follows: (1) Split the source document into chunks that fit within your model's context window, reserving at least 30% of the window for the summary and continuation instructions. (2) Process chunks sequentially, maintaining a running summary object. After each chunk, call the summarization prompt with the chunk text and the existing summary, producing an updated summary. (3) When the final chunk is processed, call the continuation prompt with the complete summary and the original task instruction. Validate the summary at each step: check that entity counts are non-decreasing, that relationship edges reference entities present in the summary, and that the last_processed_position field advances monotonically. If validation fails, retry the summarization step with a repair instruction before proceeding. Log every summary update with a timestamp and chunk index for auditability.
For model choice, prefer models with large context windows and strong instruction-following for the summarization stage (Claude 3.5 Sonnet or GPT-4o), and use the same or a faster model for the continuation stage depending on output complexity. Set temperature=0 or very low for summarization to maximize factual consistency across chunks. Implement a retry budget: three attempts per chunk for summarization failures, then escalate to a human operator with the partial summary and the failed chunk. For the continuation stage, validate that the final output references only entities and claims present in the summary—any hallucinated addition indicates a summary fidelity problem upstream. Store the full summary artifact alongside the final output for downstream evaluation and debugging. Avoid the common failure mode of letting the summary grow unbounded; if the summary itself approaches the context limit, apply the same compression pattern recursively.
Expected Output Contract
Validation rules for the two-stage Summarize-Then-Continue output. Stage 1 produces a compressed summary; Stage 2 produces the continuation. Each field must pass these checks before the output is accepted by the application harness.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
stage1.summary_text | string | Must be non-empty and contain at least one preserved entity from [SOURCE_DOCUMENT]. Token count must be less than [MAX_SUMMARY_TOKENS]. | |
stage1.preserved_entities | array of strings | Each entry must match a named entity, key term, or numeric value present in [PROCESSED_SECTIONS]. Empty array fails. | |
stage1.preserved_relationships | array of objects | If present, each object must contain 'subject', 'predicate', and 'object' string fields. Null allowed. | |
stage1.section_boundary_marker | string | Must equal the exact section heading or paragraph ID where processing stopped. Used by Stage 2 to resume. | |
stage2.continuation_text | string | Must begin with content immediately following [stage1.section_boundary_marker]. Must not repeat summarized content. | |
stage2.new_entities_introduced | array of strings | If present, each entry must be a named entity or key term not found in [stage1.preserved_entities]. Null allowed. | |
stage2.completion_flag | boolean | Must be true if all remaining content was processed, false if more content exists beyond the current window. Used to trigger additional continuation cycles. | |
stage2.remaining_section_marker | string or null | If stage2.completion_flag is false, must contain the next unprocessed section boundary. If true, must be null. |
Common Failure Modes
What breaks first when using Summarize-Then-Continue prompts and how to guard against it.
Entity and Relationship Drop
What to watch: The summary omits key named entities, numerical values, or critical relationships between concepts, causing the continuation to lose context. Guardrail: Require the summary prompt to explicitly list all named entities, dates, and key-value pairs. Validate with an entity extraction check on the summary before passing it to the continuation stage.
Summary Drift and Hallucination
What to watch: The model introduces facts or interpretations in the summary that were not present in the source text, contaminating the continuation. Guardrail: Add a strict instruction to the summary prompt: 'Only include information explicitly stated in the provided text. Do not infer, generalize, or add external knowledge.' Use a fact-checking eval to compare summary claims against the source.
Continuation Boundary Incoherence
What to watch: The continued output does not logically connect to the point where the summary left off, resulting in a jarring transition, repeated content, or a broken narrative. Guardrail: The continuation prompt must include the last 1-2 sentences of the summary as a 'connection point' and instruct the model to 'continue seamlessly from this exact text.'
Token Budget Miscalculation
What to watch: The summary plus the remaining source text still exceeds the model's context window, causing a second truncation error. Guardrail: Implement a pre-flight token count check. The summary prompt must include a hard token limit (e.g., 'Summarize in no more than 500 tokens'). The harness must verify the summary's token count before assembling the continuation request.
Cascading Failure on Invalid Summary
What to watch: The summary stage fails silently (e.g., produces an empty string or an error message), and this invalid output is fed directly into the continuation prompt, producing garbage. Guardrail: Add a validation gate between the two stages. Check that the summary is non-empty, contains expected keywords or structure, and passes a basic schema check before proceeding. On failure, retry the summary step or escalate.
Loss of Task Instruction Fidelity
What to watch: The continuation prompt focuses so heavily on the summary that it forgets the original task's instructions, output format, or constraints. Guardrail: The continuation prompt must re-state the original task instructions and output schema in full, treating the summary as just another piece of input context. Do not assume the model will inherit the goal from the first stage.
Evaluation Rubric
Criteria for evaluating the quality and correctness of the Summarize-Then-Continue prompt's output, specifically focused on fact retention, entity preservation, and boundary coherence.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Named Entity Retention | All named entities (people, orgs, products, locations) from [ORIGINAL_SOURCE] appear in the combined [SUMMARY] and [CONTINUATION] output. | A named entity present in the source text is missing from the final combined output. | Extract entities from source via NER. Diff against entities extracted from final output. Flag missing entities. |
Numerical Fact Accuracy | All numerical values (dates, amounts, percentages, statistics) in the output match the [ORIGINAL_SOURCE] exactly. | A number is altered, rounded incorrectly, or fabricated in the output. | Parse all numbers from source and output. Perform exact string match comparison. Flag any deviation. |
Relationship Continuity | Causal, temporal, and hierarchical relationships spanning the summary-continuation boundary are preserved and logically consistent. | A relationship stated in the summary is contradicted or broken in the continuation. | Identify cross-boundary relationship triples in source. Verify each triple is represented consistently in the final output. |
Summary Completeness | The [SUMMARY] section captures all key themes, decisions, and entities from the processed portion without introducing new information. | The summary omits a major topic from the processed section or hallucinates details not present in the source. | Compare summary claims against the source segment. Check for unsupported assertions. Calculate topic recall against a human-generated topic list. |
Continuation Cohesion | The [CONTINUATION] section flows naturally from the summary without repeating summarized content or leaving a contextual gap. | The continuation restates summarized information as if new, or references entities without prior introduction. | Human review of the summary-continuation transition. Check for redundant sentences and unresolved references. |
Instruction Adherence | The final output strictly follows the [OUTPUT_SCHEMA] and all [CONSTRAINTS] defined in the prompt template. | Output is missing a required field, includes disallowed content, or violates a formatting rule. | Schema validation against the expected JSON or markdown structure. Constraint check via regex or keyword matching. |
Token Budget Compliance | The combined prompt and output token count does not exceed the defined [MAX_OUTPUT_TOKENS] or cause a new overflow. | The continuation request itself triggers a token limit error, or the final output is truncated again. | Count tokens of the full prompt and response using the target model's tokenizer. Assert total is less than the model's context limit. |
Abstention and Uncertainty | If the source is ambiguous or information is missing, the output uses uncertainty language or abstains rather than fabricating. | The output confidently states a fact that is not clearly supported by the provided source context. | Search output for uncertainty keywords. For factual claims, verify a direct source quote exists. Flag unsupported confident claims. |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Adapt This Prompt
How to adapt
Use the base two-stage prompt with minimal validation. Focus on getting the summarization and continuation flow working end-to-end before adding production harness logic. Keep the summary structure simple: a bullet list of key entities, relationships, and the last processed section marker.
Prompt modification
- Replace [DOCUMENT_CHUNK_1] and [DOCUMENT_CHUNK_2] with raw text splits
- Use a simple delimiter like
---PROCESSED UP TO HERE---as the boundary marker - Skip schema enforcement; accept free-text summaries
- Test with 2-3 document types to confirm the continuation picks up correctly
Watch for
- Summary drift where the model paraphrases instead of preserving exact entity names
- Boundary misalignment causing repeated or skipped content
- Overly verbose summaries that consume too many tokens for the next stage

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us