This prompt is designed for AI engineers and platform teams operating long-running chat assistants, copilots, or multi-turn agent workflows where session history routinely exceeds the model's context window. The core job-to-be-done is converting a verbose, multi-turn transcript into a dense, information-preserving summary that fits within a strict token budget. You should reach for this prompt when your session state surpasses 80% of the available context window, when latency begins to degrade due to prompt length, or when you need a portable session payload for handoff to another agent, storage in a session database, or pause-and-resume functionality. The ideal user is a developer integrating this prompt into an automated context management pipeline, not an end-user manually summarizing a chat.
Prompt
Conversation History Compression Prompt for Long Sessions

When to Use This Prompt
Defines the production scenarios, user profiles, and failure modes that justify deploying a conversation compression prompt instead of retaining full turn history.
Do not use this prompt for short, single-turn interactions or sessions that comfortably fit within the context window with all instructions and tool outputs intact. It is also the wrong tool when you need a human-readable narrative for a support ticket or a meeting notes summary; those workflows require different output schemas and salience criteria. This prompt is specifically tuned for machine-to-machine state compression where the primary consumer is another model or a structured session store. Using it for general-purpose summarization will produce overly dense, salience-scored payloads that omit the narrative flow a human reader expects.
Before deploying this prompt, you must have a clear token budget defined and a mechanism for triggering compression (e.g., a context window utilization threshold). The prompt includes salience scoring instructions that rank each turn by decision relevance, factual content, and future utility. This ranking enables deterministic pruning when the summary itself approaches the budget limit. The output is a structured compression payload, not free-text prose, so your downstream consumer must expect that schema. If your application cannot consume structured summaries, adapt the output format before integrating this prompt into your pipeline.
The most common production failure occurs when critical facts are dropped during compression without detection. This prompt includes a faithfulness verification harness that compares the compressed summary against the original transcript to flag hallucinations, incorrect attributions, and missing binding decisions. In high-stakes domains such as healthcare, legal, or financial services, you must route flagged summaries for human review before the compressed state replaces the full history. Never treat compression as lossless; always preserve the original transcript in cold storage for audit and recovery purposes.
Use Case Fit
Where the Conversation History Compression Prompt delivers value and where it introduces unacceptable risk.
Good Fit: Long-Running Support Sessions
Use when: sessions exceed 20 turns and the context window is at risk of truncating the earliest instructions. Guardrail: compress only after a topic shift or resolution milestone to avoid losing active troubleshooting state.
Bad Fit: Real-Time Safety-Critical Dialogue
Avoid when: every word matters for legal or clinical accuracy, such as live clinical note-taking or emergency dispatch. Guardrail: never compress turns that contain dosages, allergies, or safety directives; route to a full-transcript archive instead.
Required Input: Salience Scoring Rubric
Risk: without a defined rubric, the model compresses based on linguistic prominence rather than operational importance. Guardrail: provide a domain-specific salience schema that weights decisions, action items, and corrections above social filler.
Required Input: Token Budget Ceiling
Risk: an unbounded compression prompt produces summaries that still exceed the target window. Guardrail: pass an explicit max_tokens parameter and validate output length before replacing the history buffer.
Operational Risk: Silent Fact Omission
Risk: the summary drops a critical constraint or decision without any error signal. Guardrail: run a faithfulness verification prompt that compares the compressed summary against the original turns and flags missing commitments.
Operational Risk: Premature Compression
Risk: compressing while the user is mid-correction or mid-decision loses the resolution context. Guardrail: use a trigger decision prompt to gate compression behind explicit confirmation that the current sub-task is resolved.
Copy-Ready Prompt Template
A reusable prompt template for compressing verbose conversation history into a dense, information-preserving summary that fits within a strict token budget.
The following prompt template is designed to be dropped directly into your application's context management layer. It instructs the model to act as a conversation archivist, transforming a long, multi-turn dialogue into a structured summary. The core mechanism is a salience-scoring instruction that forces the model to prioritize decision-critical facts, pending actions, and unresolved questions over social niceties or redundant information. The template uses square-bracket placeholders for all dynamic inputs, allowing you to inject the raw transcript, your specific token budget, and any domain-specific constraints before each call.
textYou are a precise conversation archivist. Your task is to compress the provided [CONVERSATION_HISTORY] into a dense, structured summary that fits within a strict token budget of [MAX_OUTPUT_TOKENS]. Follow these rules: 1. **Salience Scoring:** Mentally score each turn for its long-term utility. Prioritize: explicit user decisions, confirmed facts, unresolved questions, action items with owners, and critical corrections. Discard: greetings, small talk, redundant confirmations, and information explicitly superseded by a later correction. 2. **Structured Output:** Generate the summary in the following JSON schema: { "session_objective": "A single sentence describing the user's primary goal.", "key_decisions": ["A list of final, confirmed decisions made."], "critical_facts": ["A list of verified facts provided by the user or confirmed from tools."], "pending_actions": [{"action": "...", "owner": "user or assistant", "status": "open"}], "unresolved_questions": ["Questions the user asked that were not answered."], "corrections_log": [{"superseded_claim": "...", "correction": "...", "turn_id": "..."}] } 3. **Faithfulness Constraint:** Do not invent any facts, decisions, or questions not explicitly present in [CONVERSATION_HISTORY]. If a field has no valid entries, return an empty list `[]`. 4. **Budget Compliance:** If the JSON output exceeds [MAX_OUTPUT_TOKENS], iteratively prune the least salient items from the `critical_facts` and `key_decisions` lists until the budget is met. Do not truncate mid-JSON. [CONVERSATION_HISTORY]: """ [RAW_TRANSCRIPT] """ [DOMAIN_TERMINOLOGY]: """ [OPTIONAL_GLOSSARY] """
To adapt this template, start by replacing [RAW_TRANSCRIPT] with your actual conversation log, ideally with turn IDs and speaker roles (user, assistant, tool) clearly labeled. The [MAX_OUTPUT_TOKENS] placeholder should be set dynamically based on your context window budget—a common starting point is 15-25% of the total context limit. The [OPTIONAL_GLOSSARY] field is a powerful lever for domain-specific compression; providing a list of acronyms and entity definitions here prevents the summary from wasting tokens on verbose explanations. For high-stakes applications, you must pair this prompt with a faithfulness verification harness that programmatically compares the generated summary against the original transcript to detect dropped critical facts or hallucinated entries before the summary replaces the full history.
Prompt Variables
Required and optional placeholders for the conversation history compression prompt. Each variable must be validated before the prompt is assembled to prevent runtime failures, token budget violations, or silent information loss.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CONVERSATION_HISTORY] | Full transcript of turns to compress, including speaker labels and timestamps | USER [2025-01-15 14:02]: I need to change my billing address. ASSISTANT [2025-01-15 14:02]: I can help with that. What is the new address? | Must be non-empty string. Validate that speaker labels are consistent and timestamps are present if salience scoring uses recency. Reject if only one turn is provided. |
[TOKEN_BUDGET] | Maximum tokens allowed for the compressed output summary | 500 | Must be a positive integer. Validate that budget is at least 50 tokens to allow meaningful compression. Reject if budget exceeds model context limit minus system prompt tokens. |
[SALIENCE_RUBRIC] | Criteria for ranking which turns, facts, decisions, and actions to preserve versus drop | Prioritize: (1) binding decisions, (2) unresolved questions, (3) user-provided facts still in scope, (4) action items with owners. Deprioritize: small talk, repeated information, superseded facts. | Must be a non-empty string with explicit prioritization rules. Validate that rubric includes both inclusion and exclusion criteria. Test with a known transcript to confirm rubric produces deterministic rankings. |
[OUTPUT_SCHEMA] | Expected JSON structure for the compressed summary | {"session_id": "string", "compressed_summary": "string", "key_decisions": [{"decision": "string", "timestamp": "string"}], "open_questions": ["string"], "pending_actions": [{"action": "string", "owner": "string|null"}], "dropped_topics": ["string"], "token_count": "integer"} | Must be a valid JSON Schema or example structure. Validate that required fields include compressed_summary, key_decisions, open_questions, and pending_actions. Reject schemas missing token_count for budget compliance verification. |
[FAITHFULNESS_CONSTRAINT] | Instruction prohibiting hallucination, fabrication, or addition of facts not present in the source transcript | Do not invent any fact, decision, name, date, or action not explicitly stated in the conversation history. If a field has no evidence, use null or an empty array. Mark any inferred information with [INFERRED] and confidence LOW. | Must be a non-empty string. Validate that constraint explicitly forbids fabrication and requires null for absent evidence. Test with a transcript containing known gaps to confirm the model does not fill them. |
[COMPRESSION_RATIO_TARGET] | Target ratio of input tokens to output tokens, used to guide summarization aggressiveness | 0.15 | Must be a float between 0.05 and 0.50. Validate that ratio is achievable given TOKEN_BUDGET and input length. Reject if input token count times ratio exceeds TOKEN_BUDGET. |
[DOMAIN_TERMINOLOGY_MAP] | Optional mapping of domain-specific terms, acronyms, or entity types that must be preserved exactly in the summary | {"SKU": "Stock Keeping Unit", "MRR": "Monthly Recurring Revenue", "P0": "Priority Zero incident"} | Optional. If provided, must be a valid JSON object with string keys and string values. Validate that terms in the map appear in the conversation history to avoid unnecessary token spend. Null allowed. |
[DROPPED_TOPICS_THRESHOLD] | Confidence threshold below which a topic is classified as dropped rather than summarized | 0.3 | Must be a float between 0.0 and 1.0. Validate that threshold is not set to 0.0 (drops nothing) or 1.0 (drops everything). Default to 0.3 if not specified. Test with edge cases where topics are partially mentioned. |
Implementation Harness Notes
How to wire the Conversation History Compression Prompt into a production application with validation, retries, and monitoring.
This prompt is designed to sit inside a context window management middleware that triggers compression when the accumulated conversation history approaches a configurable token threshold (e.g., 80% of the model's context limit). The harness should intercept the raw turn list, inject the prompt template with the conversation history, token budget, and salience rubric, and then replace the verbose history with the compressed summary in subsequent requests. Do not call this prompt on every turn—trigger it only when the token counter signals that headroom is running out. The compression output becomes the new system or context preamble for the next request, with the most recent 2-3 turns retained in full to preserve immediate coherence.
Validation and retry logic is critical because a corrupted or hallucinated summary will poison every subsequent turn. After the model returns a compressed summary, run a faithfulness verification prompt (see sibling topic: Summary Faithfulness Verification Prompt) that compares the summary against the original transcript and flags any hallucinated facts or dropped critical information. If the verification fails—defined as any hallucinated claim or a completeness score below your threshold—retry the compression prompt once with the verification errors appended as [CONSTRAINTS]. If the retry also fails, log the full transcript and alert a human operator; do not silently proceed with a degraded summary. For high-stakes domains (healthcare, legal, finance), require human review of the compressed summary before it replaces the live context.
Model choice and cost considerations matter here. Use a fast, cheaper model (e.g., GPT-4o-mini, Claude Haiku) for the compression step itself, reserving your primary high-capability model for the actual user-facing turns. The compression prompt's output should be a structured JSON object with compressed_summary, salience_scores, and dropped_turn_ids fields. Parse this JSON in your application layer, validate the schema, and store the dropped_turn_ids in your session metadata for auditability. Log every compression event with: session ID, token count before/after, compression ratio, verification pass/fail, and latency. This telemetry is essential for tuning your trigger thresholds and detecting silent degradation over long sessions.
Wiring into a stateful session store is the final integration step. The compressed summary should be persisted alongside the session record so that if the user disconnects and resumes later, the restart flow can load the summary rather than replaying the full history. Use the compressed_summary field as the [CONTEXT] input for the Session Restart Summary Prompt. Avoid the common failure mode of double-compression: if a session has already been compressed once, do not feed the compressed output back into the compression prompt as if it were raw history. Track a compression_count in session metadata and cap it at one or two levels before forcing a full context reset with a user-facing message.
Expected Output Contract
Fields, types, and validation rules for the compressed conversation history output. Use this contract to build a post-processing validator that rejects summaries before they enter downstream context windows.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
compressed_summary | string | Must be non-empty and ≤ [MAX_OUTPUT_TOKENS] tokens. Parse check: reject if token count exceeds budget. | |
salience_scores | array of objects | Each object must contain turn_id (string) and score (float 0.0-1.0). Array length must equal the number of input turns. Reject if any turn is unscored. | |
salience_scores[].turn_id | string | Must match a turn_id present in the input [TURN_HISTORY]. Reject on orphaned or fabricated IDs. | |
salience_scores[].score | float | Must be a number between 0.0 and 1.0 inclusive. Reject on null, non-numeric, or out-of-range values. | |
dropped_turns | array of strings | List of turn_ids excluded from the summary. Reject if any listed turn_id is not present in [TURN_HISTORY]. | |
critical_facts_retained | array of strings | Each entry must be a verbatim or near-verbatim fact from [TURN_HISTORY]. Run a faithfulness check: reject if any fact cannot be grounded in the source turns. | |
hallucination_flags | array of objects | If present, each object must contain claim (string) and evidence_turn_id (null or string). Reject if claim is unsupported and evidence_turn_id is not null. | |
compression_ratio | float | Calculated as output_tokens / input_tokens. Must be ≤ [TARGET_COMPRESSION_RATIO]. Reject if ratio exceeds target, indicating insufficient compression. |
Common Failure Modes
Compressing conversation history is a high-stakes operation. Information loss is silent and catastrophic. These are the most common failure modes observed in production compression pipelines and how to guard against them.
Silent Fact Omission
What to watch: The model drops a critical user-provided fact (e.g., an account number, a specific constraint) because it deemed it low-salience. The summary reads fluently but is now dangerously incomplete. Guardrail: Implement a faithfulness verification pass that extracts all key entities and constraints from the original transcript and checks for their presence in the summary. Flag any summary missing a source-grounded fact for human review.
Temporal Reordering and Causality Reversal
What to watch: The model reorders events to make the narrative flow better, inadvertently reversing cause and effect (e.g., 'The user fixed the bug, then reported the error'). Guardrail: Instruct the model to preserve the original chronological order of events and decisions. Add a specific eval check that verifies the sequence of key actions in the summary matches the source transcript's timeline.
Unresolved Question Collapse
What to watch: The model treats a user's open question as a resolved topic because the assistant acknowledged it. The question disappears from the summary, and the user never gets an answer. Guardrail: Require a dedicated 'Open Questions' section in the summary output schema. The verification harness must explicitly check that every question mark in the source is accounted for in either the resolved or unresolved section of the summary.
Pronoun and Reference Ambiguity
What to watch: The summary replaces specific nouns with pronouns ('he,' 'it,' 'that feature') without their antecedents, making the compressed context useless for a future model turn. Guardrail: Add a coreference resolution check to the compression prompt: 'Replace all ambiguous pronouns with their specific noun referents. A reader with no access to the original transcript must understand every reference.'
Over-Compression of Negative or Corrective Feedback
What to watch: The model summarizes a user correction ('No, use the v2 API') as a simple preference, losing the critical information that the v1 API is invalid. The assistant repeats the same mistake in the next session. Guardrail: Instruct the model to explicitly tag and preserve corrections as high-salience events. The summary must include a 'Superseded Facts' section that records what was invalidated and why.
Token Budget Exceeded by the Summary Itself
What to watch: The compression prompt, original history, and verbose summary together exceed the model's context window, causing a truncated or failed generation. Guardrail: Implement a strict token budget validator before the compression call. The prompt must specify a hard output token limit (e.g., 'Your summary must be under 500 tokens'). If the output exceeds this, trigger a recursive compression with a tighter budget.
Evaluation Rubric
Use this rubric to test the quality of compressed conversation summaries before deploying the prompt to production. Each criterion targets a specific failure mode common in history compression.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Faithfulness to Source | All facts in the summary are directly supported by the original transcript. No hallucinated details, names, or events. | Summary contains a claim not present in the source turns. Attribution is incorrect or fabricated. | Human or LLM-as-judge pairwise comparison of summary claims against source transcript. Flag any unsupported assertion. |
Critical Fact Retention | All decisions, action items, and user-provided constraints from the source are present in the summary. | A binding decision, assigned task, or explicit user constraint from the original history is missing from the compressed output. | Checklist-based audit: extract key entities from source, verify presence in summary. Automate with a structured extraction diff. |
Token Budget Compliance | The compressed output fits within the specified [MAX_OUTPUT_TOKENS] limit. | Output token count exceeds the budget. Summary is truncated mid-sentence or omits the closing structure. | Programmatic token count check using the target model's tokenizer. Fail if count > [MAX_OUTPUT_TOKENS]. |
Salience Ordering | The most critical information (decisions, blockers, P0 actions) appears first. Low-priority context is deprioritized or omitted. | A trivial detail is prominently featured while a blocking issue or key decision is buried or dropped. | Rank correlation test: compare the summary's ordering of facts against a pre-labeled salience ranking from a human evaluator. |
Stale Fact Handling | Facts explicitly corrected or superseded by the user are excluded or marked as 'superseded' in the summary. | The summary includes an outdated fact that the user later corrected, without noting the correction. | Inject a correction turn into a test transcript. Verify the summary excludes the original error or explicitly marks it as corrected. |
Action Item Completeness | All explicit and strongly implied action items are captured with owner, description, and status. | An action item assigned in the transcript is missing from the summary's action item list. | Parse the summary's action items. Cross-reference with a manually labeled list from the source. Fail if recall < 100%. |
Structural Validity | Output is valid JSON matching the [OUTPUT_SCHEMA] without parsing errors. | Response is not parseable JSON, contains trailing commas, or is missing required fields like 'summary' or 'open_questions'. | Automated schema validation and JSON parse test. Fail on any exception or missing required field. |
Ambiguity Resolution | Pronouns and implicit references are resolved to specific entities. No 'he said' or 'the document' without a clear antecedent. | Summary contains an unresolved pronoun or vague reference that requires reading the original transcript to understand. | Spot-check: search summary for common pronouns. For each, verify the antecedent is explicitly named in the same sentence or prior sentence. |
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
Start with the base compression prompt but relax the strict token budget and schema enforcement. Use a simple instruction like: "Compress the following conversation into a dense summary under [SOFT_TOKEN_LIMIT] tokens. Preserve key decisions, action items, and open questions." Test with 3-5 long sessions manually.
Watch for
- Summary dropping critical facts that were only mentioned once
- Over-compression turning nuanced decisions into vague statements
- No mechanism to verify faithfulness against the original transcript

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