This prompt is designed for a specific job: converting a long, multi-turn conversation transcript into a dense, structured summary that can replace the raw history in subsequent model calls. The primary user is a chat application developer or AI engineer managing a stateful session where the accumulated turns threaten to exceed the model's context window. Instead of relying on naive truncation—which silently drops the oldest messages and often discards critical early context—this prompt instructs the model to perform a semantic compression. It preserves key facts, user-stated preferences, decisions made, action items, and any questions that remain unresolved. The output is a memory artifact that acts as a drop-in replacement for the raw transcript, dramatically reducing token consumption while maintaining the illusion of a continuous, informed conversation.
Prompt
Conversation History Summarization Prompt for Token Savings

When to Use This Prompt
Identify the right conditions for compressing conversation history to reclaim context window space without breaking conversational continuity.
The ideal trigger for this workflow is a pre-flight token check. Implement a counter in your application layer that sums the tokens of your system prompt, the raw conversation history, any retrieved context, and the expected output tokens. When this total exceeds a defined safety threshold—typically 80-90% of the model's context limit—you should invoke this summarization prompt before assembling the final request. The summary it produces becomes the new [CONVERSATION_HISTORY] variable in your prompt template. This is not a one-time operation; in very long sessions, you may need to summarize the history, then later summarize the combination of the old summary and new turns. This recursive summarization pattern is a standard technique for unbounded conversational agents, but it requires careful fidelity checks to prevent error propagation.
There are clear situations where this prompt is the wrong tool. Do not use it when the raw conversation easily fits within the context budget; the summarization step itself consumes tokens and introduces a small but non-zero risk of information distortion. Do not use it when the downstream task requires verbatim recall of specific user or assistant phrasing, such as in legal depositions, customer complaints requiring exact wording for a regulatory filing, or debugging sessions where precise error messages matter more than semantic gist. In these cases, you need a different memory strategy, such as a vector database for exact string matching or a longer-context model. Finally, do not use this prompt as a substitute for a proper persistence layer; the summary is a transient memory artifact for the model's context window, not a durable record of the conversation for audit or analytics. Always store the full transcript in your application database separately.
Use Case Fit
Where this prompt works and where it does not. Understand the operational boundaries before embedding summarization into a production pipeline.
Good Fit: Long-Running Chat Sessions
Use when: sessions exceed 20+ turns and the full history would overflow the context window or cause latency spikes. Guardrail: Run the summarization prompt every N turns and replace the raw history with the compressed summary plus the last K turns for recency.
Bad Fit: Single-Turn or Stateless Requests
Avoid when: each request is independent with no conversational history to compress. Guardrail: Skip the summarization step entirely. Adding it introduces latency and cost with zero token savings.
Required Inputs
What you need: the raw conversation transcript, a list of entities or topics to preserve, and a target token budget for the summary. Guardrail: Validate that the transcript is non-empty and the token budget is realistic before calling the model. Reject requests where the summary budget exceeds the original history length.
Operational Risk: Information Loss
What to watch: the summary may drop decisions, corrections, or nuanced user preferences that later turns depend on. Guardrail: Implement a fidelity check that compares key facts extracted from the summary against the original history. If recall drops below a defined threshold, escalate for human review or retain more raw turns.
Operational Risk: Token Savings Miscalculation
What to watch: the summarization prompt itself consumes tokens, and a poor summary may require frequent re-expansion. Guardrail: Measure net token savings (original history tokens minus summary tokens minus summarization prompt tokens). Only enable summarization when net savings exceed a minimum threshold, such as 30%.
Variant: Progressive Summarization
Use when: sessions are extremely long and a single summary pass is insufficient. Guardrail: Apply hierarchical summarization—summarize chunks of turns first, then summarize the summaries. Validate that each compression layer preserves the required entities and decisions before feeding into the next layer.
Copy-Ready Prompt Template
A copy-ready prompt template that instructs the model to produce a structured JSON summary of a conversation, designed for machine consumption in downstream prompt assembly.
The following prompt template is the core instruction set for compressing a long conversation history into a dense, structured summary. Its primary job is to preserve critical facts, decisions, and open questions while discarding conversational filler, all to save tokens in subsequent LLM calls. The output is designed to be a drop-in replacement for the raw history in a new prompt, making it ideal for long-running chat applications, copilots, and agentic loops where the context window is a scarce resource.
textSystem: You are a conversation summarizer. Your task is to compress the provided conversation history into a structured JSON summary. The summary must preserve all key facts, decisions, user preferences, and unresolved questions. Discard pleasantries, repetition, and conversational filler. The output will be used by another AI system to continue the conversation, so it must be self-contained and factually accurate. User: Compress the following conversation history into a JSON summary. <conversation_history> [CONVERSATION_HISTORY] </conversation_history> <output_schema> { "summary": "A dense, one-paragraph narrative summary of the entire conversation, capturing the user's primary goal and the progress made.", "key_facts": ["A list of specific, factual statements extracted from the conversation. E.g., 'User's budget is $500', 'Target launch date is Q3 2024'."], "decisions": ["A list of decisions made by the user or agreed upon by both parties. E.g., 'Decided to use PostgreSQL for the database', 'User chose the annual billing plan'."], "unresolved_questions": ["A list of explicit questions asked by either party that have not yet been answered."], "user_preferences": ["A list of stated user likes, dislikes, or stylistic preferences. E.g., 'Prefers concise answers', 'Dislikes technical jargon'."], "action_items": ["A list of tasks that need to be done next, either by the user or the assistant. E.g., 'Assistant to provide a code example', 'User to share API key'."] } </output_schema> <constraints> - Do not invent any information not present in the original conversation. - If a section has no items, return an empty list. - The output must be a single, valid JSON object and nothing else. </constraints>
To adapt this template, replace the [CONVERSATION_HISTORY] placeholder with your raw conversation data, typically formatted as a sequence of user and assistant turns. The output_schema is a strong suggestion; you should modify the fields to match the specific information your downstream application needs. For instance, a customer support bot might need a "ticket_id" and "issue_category" field, while a coding agent might need "current_branch" and "files_modified". The key is to be explicit about the structure you need for the next step in your pipeline. After generating the summary, always validate the JSON structure before using it to replace the full history, and consider a fidelity check where you ask the model if the summary is consistent with the original text.
Prompt Variables
Inputs required to assemble a reliable conversation history summarization prompt. Validate each placeholder before prompt construction to prevent fidelity loss, token waste, or missing context.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CONVERSATION_HISTORY] | Full transcript of turns to summarize, including speaker roles and timestamps | [{"role": "user", "content": "I need to reset my MFA device", "timestamp": "2025-01-15T10:23:00Z"}, {"role": "assistant", "content": "I can help with that. First, are you locked out completely or do you still have access?"}] | Must be a valid JSON array of turn objects. Each object requires role, content, and timestamp fields. Reject if empty or missing required fields. Check for PII before assembly. |
[SUMMARY_LENGTH_TARGET] | Target token count or word count for the compressed summary | 500 tokens | Must be a positive integer. If null, default to 300 tokens. Validate that target is less than 80% of [CONVERSATION_HISTORY] token count to ensure actual compression. Reject targets exceeding available context budget. |
[FIDELITY_PRIORITIES] | Ordered list of information categories that must survive compression | ["unresolved questions", "user decisions", "action items", "user contact details", "error codes"] | Must be a non-empty array of strings. Each category must be a recognized label from the fidelity taxonomy. Reject if duplicate categories exist. Default priority order is: decisions, action items, unresolved questions, facts, sentiment. |
[OUTPUT_SCHEMA] | JSON schema defining the structure of the summary output | {"type": "object", "properties": {"summary": {"type": "string"}, "key_facts": {"type": "array", "items": {"type": "string"}}, "unresolved_items": {"type": "array", "items": {"type": "string"}}, "decisions_made": {"type": "array", "items": {"type": "string"}}, "token_count_original": {"type": "integer"}, "token_count_summary": {"type": "integer"}}, "required": ["summary", "key_facts", "unresolved_items", "decisions_made"]} | Must be a valid JSON Schema draft-07 object. Required fields must include summary, key_facts, unresolved_items, and decisions_made. Schema parse check required before assembly. Reject schemas that allow unbounded arrays without maxItems. |
[COMPRESSION_RULES] | Specific instructions for what to drop, merge, or preserve during summarization | "Drop greetings and pleasantries. Merge repeated questions into single entries. Preserve exact error codes and URLs. Replace long code blocks with functional descriptions." | Must be a non-empty string. Validate that rules do not contradict [FIDELITY_PRIORITIES]. Check for ambiguous directives like 'summarize appropriately' and require concrete action verbs. Null allowed if using default rules. |
[TOKEN_BUDGET_TOTAL] | Maximum total tokens allowed for the assembled prompt including instructions and history | 8000 | Must be a positive integer. Validate that [TOKEN_BUDGET_TOTAL] exceeds sum of instruction tokens plus [SUMMARY_LENGTH_TARGET]. Reject if budget is less than 2x [SUMMARY_LENGTH_TARGET]. Use tokenizer matching target model for accurate count. |
[MODEL_IDENTIFIER] | Target model name for tokenizer selection and behavior adaptation | "claude-sonnet-4-20250514" | Must match a known model identifier from the model registry. Validate against supported models list. Determines tokenizer, context window limit, and any model-specific formatting rules. Reject unknown or deprecated model IDs. |
[FIDELITY_CHECK_SAMPLE_SIZE] | Number of original turns to spot-check against summary for fidelity validation | 5 | Must be a positive integer between 1 and 20. If null, default to 3. Controls how many random turns are extracted for the fidelity eval prompt. Higher values increase eval cost. Validate that sample size does not exceed total turn count in [CONVERSATION_HISTORY]. |
Implementation Harness Notes
How to wire the summarization prompt into a production chat application or agent loop with validation, retries, and observability.
The summarization prompt should be called as a side-effect step, not inline with the user's request. In a typical chat application, you maintain a full conversation history in your session store. When the accumulated token count of that history exceeds a configured threshold (e.g., 80% of the model's context limit), you trigger the summarization prompt as a background or pre-turn operation. The prompt receives the raw conversation array as [CONVERSATION_HISTORY] and the current [SUMMARY] if one already exists. The output is a new compressed summary that replaces the previous one, and the raw history can be truncated to only the most recent turns that fit alongside the summary. This keeps the working context window small while preserving long-running session state.
The implementation harness must validate the summary before it replaces the existing state. After the model returns a summary, run a fidelity check: extract all claimed facts, decisions, and unresolved questions from the summary, then verify each against the original conversation turns using a secondary verification prompt or a lightweight NLI model. If the fidelity score drops below a configured threshold (e.g., 95% factual recall), discard the summary and retry with a lower temperature or a more explicit instruction to preserve detail. Log the token counts before and after summarization to track compression ratio. A typical implementation stores the summary in the session object alongside a summary_generated_at timestamp and the compression_ratio metric for observability dashboards.
For retry logic, implement a maximum of two retries with exponential backoff. If both attempts fail fidelity checks, fall back to truncating the conversation history by dropping the oldest turns and log a warning for manual review. Never silently accept a summary that fails validation—a degraded summary can cause the assistant to forget critical user context, leading to repeated questions or incorrect answers. In agent loops, call summarization before planning steps to ensure the planner operates on a compressed but accurate session state. Wire the summarization call into your existing prompt observability pipeline so every summary generation is traceable with the input token count, output token count, fidelity score, and retry count attached to the trace.
Expected Output Contract
Fields, format, and validation rules for the compressed conversation summary. Use this contract to validate model output before replacing history in the context window.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
summary_text | string | Must be non-empty. Length must be less than [MAX_SUMMARY_TOKENS] when tokenized with the target model's tokenizer. Must not contain unresolved placeholder tokens from the original conversation. | |
key_facts | array of strings | Each entry must be a single declarative sentence. Array length must be between 1 and [MAX_KEY_FACTS]. Each fact must be verifiable against the original conversation history. Null entries not allowed. | |
decisions_made | array of objects | Each object must contain 'decision' (string), 'decided_by' (string, role from conversation), and 'timestamp_ref' (string or null). Array may be empty if no decisions were made. No fabricated decisions allowed. | |
unresolved_questions | array of strings | Each entry must be a question explicitly left unanswered in the original history. Array may be empty. Questions must not be answered or resolved in the summary. Null entries not allowed. | |
participants | array of strings | Must list all unique participant roles or identifiers from the original conversation. Array must not be empty. No duplicate entries. Must match participant extraction from source turns. | |
token_reduction_estimate | object | Must contain 'original_token_count' (integer), 'summary_token_count' (integer), and 'reduction_ratio' (float between 0.0 and 1.0). original_token_count must match pre-summarization token count. summary_token_count must be verified by tokenizer. | |
fidelity_notes | array of strings or null | If present, each entry must describe a known information gap or uncertainty introduced by compression. Entries must be specific (e.g., 'Omitted detailed pricing discussion from turns 4-7'). Null allowed if no fidelity concerns. | |
compression_timestamp | ISO 8601 string | Must be a valid ISO 8601 datetime string in UTC. Must be later than the last message timestamp in the original conversation. Parse check required before storage. |
Common Failure Modes
Conversation summarization prompts often fail in predictable ways that erode trust and break downstream tasks. These are the most common failure modes and the specific guardrails that prevent them.
Critical Decision Omission
What to watch: The summary drops a binding decision, approval, or rejection that downstream agents or human reviewers must act on. The compressed text reads smoothly but silently removes the one fact that matters most. Guardrail: Require the prompt to extract decisions into a dedicated decisions array before generating prose. Validate that every decision in the original history appears in the summary by running a separate extraction pass on both.
Pronoun and Entity Drift
What to watch: Compression rewrites entity references so 'the Q3 budget' becomes 'it' and 'Alice from compliance' becomes 'the reviewer.' Downstream retrieval and reasoning lose track of who did what. Guardrail: Add an entity-preservation constraint to the prompt: 'Retain full proper names, document titles, and numeric identifiers exactly as they appear. Never replace a named entity with a pronoun in the summary.' Validate with an entity overlap check between original and summary.
False Closure of Open Questions
What to watch: The summary rewrites an unresolved question as a settled fact. 'We still need to confirm the SLA terms' becomes 'SLA terms were confirmed.' This poisons downstream planning and creates phantom progress. Guardrail: Require the prompt to output an explicit unresolved_items list. After generation, diff this list against the original history's open questions. Flag any summary that resolves an item without corresponding evidence in the source turns.
Temporal Reordering and Causality Break
What to watch: The summary reorders events for narrative flow but breaks causal chains. A bug report that was filed after a deployment is summarized before the deployment, implying the bug caused the rollout. Guardrail: Instruct the prompt to preserve chronological order and mark explicit cause-effect relationships with 'because' or 'after' rather than implying them through adjacency. Validate with a temporal-consistency check that compares event ordering in the summary against turn timestamps.
Token Budget Overrun on Edge Cases
What to watch: The summarization prompt works perfectly on 20-turn conversations but silently truncates or degrades when the history exceeds the model's effective summarization range. Long sessions produce summaries that are themselves too long or incoherent. Guardrail: Implement a preflight token check. If the conversation exceeds a threshold, chunk it into segments, summarize each, then run a meta-summary pass. Validate that the final summary stays under the target token budget and passes the same fidelity checks as single-pass summaries.
Loss of Negative or Refusal Information
What to watch: The summary drops statements where the user or system said 'no,' 'not yet,' 'blocked,' or 'cannot proceed.' The compressed version reads as if everything is on track. Guardrail: Add a constraint: 'Explicitly preserve all refusals, blockers, rejections, and negative outcomes. Use the original negation language rather than softening it.' Validate with a negation-presence check that counts negation markers in both original and summary and flags significant drops.
Evaluation Rubric
Run these checks on a golden dataset of 20-50 conversations with known key facts and decisions. Each row defines a pass/fail criterion for the conversation summarization prompt before production deployment.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Key Fact Retention | All known key facts from the golden dataset appear in the summary | A known key fact is missing or altered in the summary | Automated fact-matching against golden fact list; flag any unmatched required facts |
Decision Preservation | All recorded decisions from the conversation are captured with correct attribution | A decision is omitted, misattributed, or its outcome is reversed | Parse summary for decision markers; cross-reference against golden decision log |
Unresolved Question Capture | All open questions tagged in the golden dataset appear in the summary with unresolved status | An open question is missing or incorrectly marked as resolved | Extract question entities from summary; compare status labels to golden annotations |
Token Reduction Threshold | Summary token count is 40% or less of the original conversation token count | Summary exceeds 40% of original token count or is longer than original | Calculate token counts for original conversation and summary; compute reduction ratio |
Entity Fidelity | Named entities (people, products, dates, amounts) match golden annotations exactly | Entity value is changed, truncated, or hallucinated in the summary | Named entity recognition on summary; exact-match comparison against golden entity list |
Temporal Ordering | Events and decisions appear in chronological order matching the original conversation | Event sequence is reordered in a way that changes causal relationships | Extract timestamped events from summary; verify monotonic ordering against golden timeline |
Neutral Tone Preservation | Summary does not introduce sentiment, judgment, or interpretation not present in the original | Summary adds evaluative language, bias markers, or subjective framing | Sentiment analysis comparison between original and summary; flag divergence beyond threshold |
No Hallucinated Content | Zero statements in the summary that cannot be grounded in the original conversation | Summary contains a claim, fact, or detail not present in the source | Human review or NLI model check: each summary sentence must be entailed by original text |
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 summarization prompt with a simple instruction and a target compression ratio. Start with a single-turn summary request that includes the full conversation history and a [TARGET_TOKEN_COUNT] placeholder. Skip strict schema enforcement initially; accept a free-text summary paragraph.
codeSummarize the following conversation history into no more than [TARGET_TOKEN_COUNT] tokens. Preserve key facts, decisions, and unresolved questions. [CONVERSATION_HISTORY]
Watch for
- Lost entity names or dates when compression is aggressive
- Unresolved questions being dropped entirely
- Summary length exceeding the target budget by a wide margin
- No way to measure fidelity without a comparison step

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