This prompt is for orchestration engineers who need to compress a long conversation history into a dense, lossy summary before passing it to a downstream agent. It is designed for multi-agent pipelines where context window limits force a trade-off between completeness and token cost. Use this prompt when the upstream agent has accumulated more turns than the downstream agent can accept, and you need to preserve key decisions, user corrections, and unresolved questions while discarding filler, repetition, and resolved sub-tasks. The ideal user is an AI platform engineer or agent framework developer who controls the handoff contract between agents and needs a repeatable, testable compression step that fits within a defined token budget.
Prompt
Conversation History Compression Prompt for Handoff

When to Use This Prompt
Defines the precise job-to-be-done, ideal user profile, required context, and explicit boundaries for the conversation compression prompt.
Do not use this prompt for audit-grade records, legal transcripts, or workflows where verbatim conversation fidelity is required. The compression is intentionally lossy—it prioritizes actionable signal over complete reproduction. If your downstream agent needs exact user phrasing, timestamps, or full turn-by-turn attribution, this prompt is the wrong tool. Similarly, avoid this prompt when the conversation contains sensitive decisions that require human review before summarization; compression can mask nuance that a human reviewer would catch. For regulated domains, always insert a human approval step between compression and downstream action, and log both the original conversation and the compressed summary for audit trails.
Before using this prompt, ensure you have defined: the maximum token budget for the compressed output, the list of information categories that must survive compression (e.g., user corrections, tool call results, unresolved questions), and the downstream agent's expected input format. Without these constraints, the model will produce a generic summary that may drop critical context. Wire the prompt into a validation step that checks for missing required fields, token budget violations, and semantic drift from the original conversation. Start with a small set of handoff scenarios and run eval checks comparing downstream agent performance with compressed versus full context before scaling to production.
Use Case Fit
Where this prompt works, where it fails, and the operational preconditions required before putting it into a production agent handoff pipeline.
Good Fit: Long-Running Multi-Turn Sessions
Use when: A user session spans many turns and the full transcript exceeds the downstream agent's context window. Guardrail: Run this compression prompt immediately before handoff, not after the context limit is already exceeded.
Bad Fit: Single-Turn or Stateless Handoffs
Avoid when: The handoff involves a single user utterance with no prior conversation history. Guardrail: Bypass compression entirely and pass the raw input. Adding a summarization step here introduces latency and potential distortion with no benefit.
Required Input: Structured Conversation Log
Risk: Feeding the prompt raw, unstructured text with mixed speaker roles produces garbled summaries. Guardrail: Pre-process the conversation into a structured format with clear role, content, and timestamp fields before invoking compression.
Operational Risk: Silent Decision Omission
Risk: The compressor drops a critical user correction or approval that later agents need to avoid repeating work. Guardrail: Run an eval that checks the compressed output for the presence of explicit user decisions and corrections against a golden set of must-retain facts.
Operational Risk: Token Budget Overrun
Risk: The compression prompt itself plus the input history exceeds the model's context limit, causing truncation before summarization. Guardrail: Implement a pre-flight token count check and chunk the history if it exceeds 80% of the model's context window before calling the compressor.
Bad Fit: Real-Time Streaming Handoffs
Avoid when: The handoff must occur with sub-second latency and the conversation history is large. Guardrail: Use incremental summary updates or a sliding window approach rather than a full-history compression prompt on every turn.
Copy-Ready Prompt Template
A reusable prompt template for compressing conversation history into a structured handoff summary with square-bracket placeholders for your inputs, constraints, and output schema.
This prompt template is designed to be dropped directly into your agent orchestration layer when one agent needs to pass a compressed conversation summary to another agent. It forces the model to extract decisions, user corrections, unresolved questions, and critical context while explicitly marking what was omitted. The square-bracket placeholders let you inject the raw conversation, your specific output schema, risk tolerance, and any domain-specific constraints without rewriting the core instruction.
textYou are a conversation compression engine preparing a handoff summary for a downstream agent. Your output will be the only context the next agent receives about this conversation. You must preserve decision-critical information and explicitly mark what you are omitting. ## INPUT Raw conversation history to compress: [CONVERSATION_HISTORY] ## COMPRESSION RULES 1. Preserve every explicit user decision, preference, or correction. Do not paraphrase these into softer language. 2. Preserve every question the user asked that remains unresolved. Mark each as UNRESOLVED. 3. Preserve every commitment or promise made to the user. Mark each as PENDING_COMMITMENT. 4. Preserve factual claims the user made that affect downstream work (account details, dates, constraints, requirements). 5. Omit small talk, pleasantries, repeated information, and turns that were fully superseded by later corrections. 6. If the conversation contains contradictory information, preserve the most recent statement and note the contradiction. 7. If the conversation exceeds [MAX_OUTPUT_TOKENS] tokens when compressed, prioritize rules 1-4 and drop the lowest-priority items first, noting what was dropped. ## OUTPUT SCHEMA Return valid JSON matching this schema exactly: [OUTPUT_SCHEMA] ## CONSTRAINTS - Risk level for this handoff: [RISK_LEVEL] - Domain context: [DOMAIN] - Maximum output tokens: [MAX_OUTPUT_TOKENS] - If [RISK_LEVEL] is "high", include a confidence score (0.0-1.0) for each preserved item and flag any item below [CONFIDENCE_THRESHOLD] for human review. - Do not invent information not present in the conversation. - Do not resolve unresolved questions by guessing. ## OMISSION DISCLOSURE After the JSON output, include an "omissions" field listing what categories of information were dropped and why.
Adapting this template: Replace [CONVERSATION_HISTORY] with the raw transcript or message array. Define [OUTPUT_SCHEMA] as a concrete JSON Schema object with fields like decisions, unresolved_questions, pending_commitments, key_facts, and contradictions. Set [RISK_LEVEL] to "low", "medium", or "high" to control whether confidence scores and human-review flags are required. Set [DOMAIN] to a short label like "customer_support" or "healthcare_intake" to help the model apply domain-appropriate judgment about what counts as critical. Set [MAX_OUTPUT_TOKENS] based on the downstream agent's context window budget. Set [CONFIDENCE_THRESHOLD] to a float like 0.7 for high-risk workflows. Before deploying, run this prompt against a golden dataset of conversations where you know exactly which items must survive compression, and measure recall of those items in the output.
Prompt Variables
Required and optional inputs for the conversation history compression prompt. Validate each placeholder before assembly to prevent silent context loss during agent handoff.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CONVERSATION_HISTORY] | Full conversation transcript to compress | User: I need the Q3 report. Assistant: Which region? User: North America. Assistant: Here is the summary... User: That revenue number looks wrong. Assistant: Let me recalculate... | Must be a non-empty string. Check for minimum 4 turns. Reject if only system messages present. Truncate to [MAX_INPUT_TOKENS] before processing. |
[MAX_OUTPUT_TOKENS] | Token budget for the compressed summary | 512 | Must be a positive integer. Validate against model context limit. Warn if below 200 tokens for conversations with more than 10 turns. Default to 500 if not specified. |
[RETENTION_PRIORITIES] | Ordered list of information categories to preserve | ["user corrections", "unresolved questions", "key decisions", "numerical values", "entity names"] | Must be a valid JSON array of strings. At least one priority required. Validate each string against allowed enum: user corrections, unresolved questions, key decisions, numerical values, entity names, action items, constraints, preferences, timestamps, tool outputs. |
[COMPRESSION_STRATEGY] | Loss tolerance directive for the compression | lossy-prioritized | Must be one of: lossless-verbatim, lossy-prioritized, lossy-aggressive. Reject unknown values. lossy-aggressive requires explicit approval flag set to true. |
[SOURCE_ATTRIBUTION_REQUIRED] | Whether compressed summary must cite original turn indices | Must be boolean. When true, output must include [TURN_X] references. Validate that attribution format is specified in [OUTPUT_SCHEMA]. | |
[CRITICAL_ENTITIES] | Entities that must never be dropped or paraphrased | ["Q3 revenue", "North America", "Acme Corp"] | Must be a JSON array of strings or null. If provided, eval must check exact string preservation in output. Null allowed when no entity constraints exist. |
[UNRESOLVED_QUESTIONS_FLAG] | Whether to extract and highlight unanswered questions | Must be boolean. When true, output schema must include an unresolved_questions field. Validate that downstream agent handoff contract accepts this field. | |
[PREVIOUS_COMPRESSION_HASH] | Hash of prior compression to detect drift across repeated compressions | "sha256:a1b2c3d4..." | Must be a string matching ^[a-f0-9]{64}$ or null. When provided, compare output hash to detect information loss across compression cycles. Null allowed for first compression. |
Implementation Harness Notes
How to wire the conversation history compression prompt into a multi-agent handoff pipeline with validation, retries, and observability.
This prompt is designed to sit at the boundary between two agents or between an agent and a human reviewer. It should be invoked when the raw conversation history exceeds the downstream agent's context window budget or when you need a structured, lossy summary that preserves decisions, corrections, and unresolved questions. The implementation harness must treat this prompt as a state transformation function: it takes a full conversation transcript and a compression target (token budget, priority schema) and returns a compressed payload that the downstream agent can consume without re-reading the entire history.
Wire the prompt into your orchestration layer as a pre-handoff step. Before calling the prompt, assemble the [FULL_CONVERSATION_HISTORY] with speaker labels, timestamps, and tool-call results inline. Pass [COMPRESSION_TARGET_TOKENS] as a hard budget (e.g., 2000 tokens) and [PRIORITY_SCHEMA] as a structured list of what must be preserved: decisions, user corrections, unresolved questions, action items, and critical context. After the model returns the compressed summary, run two validation passes: (1) a schema check that the output contains the required sections (decisions, corrections, open questions, action items), and (2) a semantic coverage eval using a separate judge prompt that compares the compressed output against the original history for missing critical facts. If either validation fails, retry with a more explicit [PRIORITY_SCHEMA] or escalate to a human reviewer with the raw history attached.
For production reliability, implement idempotency key generation based on a hash of the conversation history and the compression parameters. This prevents duplicate compression calls when handoff retries occur. Log every compression attempt with the input token count, output token count, validation scores, and the idempotency key. If the compression ratio exceeds 10:1, flag the result for human review—extreme compression often indicates information loss. Choose a model with strong instruction-following and long-context handling (e.g., Claude 3.5 Sonnet or GPT-4o) for the compression step, but use a smaller, faster model for the schema validation pass to keep latency low. Never send the compressed summary to the downstream agent without running the coverage eval first; silent information loss in handoff is the most common failure mode in multi-agent pipelines.
Expected Output Contract
Defines the required fields, types, and validation rules for the compressed conversation history output. Use this contract to parse, validate, and route the handoff payload before passing it to a downstream agent.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
compressed_summary | string (<= [MAX_SUMMARY_TOKENS]) | Must be a non-empty string. Token count must not exceed [MAX_SUMMARY_TOKENS]. Must not contain unresolved [PLACEHOLDER] tokens. | |
key_decisions | array of strings | Must be a JSON array. Each element must be a non-empty string describing a single decision. Array must not be empty if decisions were made in the source history. | |
user_corrections | array of objects | Must be a JSON array. Each object must contain 'original' (string) and 'correction' (string) fields. Both fields must be non-empty strings. Array can be empty. | |
unresolved_questions | array of strings | Must be a JSON array. Each element must be a non-empty string ending with a question mark. Array can be empty if no questions remain open. | |
active_constraints | array of strings | Must be a JSON array. Each element must be a non-empty string describing a constraint still in effect. Include only constraints explicitly stated and not yet satisfied or lifted. | |
compression_confidence | number (0.0 to 1.0) | Must be a float between 0.0 and 1.0 inclusive. Represents the model's self-assessed confidence that no critical information was lost. Values below [MIN_CONFIDENCE_THRESHOLD] should trigger human review. | |
lost_context_flags | array of strings | If present, must be a JSON array. Each element must be a non-empty string describing a specific piece of information that may have been lost during compression. Null or empty array is acceptable. | |
source_turn_range | object | Must contain 'first_turn_id' (string) and 'last_turn_id' (string). Both must be non-empty. Used to identify the exact span of the original conversation that was compressed. |
Common Failure Modes
Conversation history compression is inherently lossy. These are the most common production failure modes when compressing context for agent handoff, along with practical detection and mitigation strategies.
Critical Decision Omission
What to watch: The compression prompt drops a user correction, explicit refusal, or constraint that was established mid-conversation. The downstream agent acts on stale or reversed intent. Guardrail: Include a dedicated critical_decisions array in the output schema and eval for exact match of user-stated constraints against the original turns.
Unresolved Question Collapse
What to watch: Open questions the user asked but the agent hasn't answered yet are summarized as resolved or omitted entirely. The downstream agent never addresses them. Guardrail: Require an unresolved_questions field in the compressed output. Run a recall eval checking that every question mark in the original turns has a corresponding entry or explicit resolution note.
Entity and Reference Drift
What to watch: Names, IDs, ticket numbers, dates, or code references are paraphrased, truncated, or hallucinated during compression. The downstream agent acts on wrong identifiers. Guardrail: Extract entities into a structured key_entities map before compression. Validate compressed output against this map with exact string matching for IDs and codes.
Temporal Ordering Corruption
What to watch: The sequence of user corrections, tool calls, and decisions is reordered or flattened. The downstream agent misinterprets which decision was most recent or which version of a request is authoritative. Guardrail: Require a timeline field with ordered, timestamped entries. Eval for pairwise ordering consistency against the original conversation using a position-aware metric.
Negative Signal Erasure
What to watch: User statements like
Confidence and Uncertainty Flattening
What to watch: Hedge language, confidence qualifiers, and explicit uncertainty markers from the upstream agent are stripped during compression. The downstream agent presents tentative findings as confirmed facts. Guardrail: Require a confidence field per summarized finding with explicit levels. Eval for preservation of uncertainty markers by comparing entropy of confidence distributions before and after compression.
Evaluation Rubric
Use this rubric to test whether a compressed conversation summary retains critical information before it is passed to a downstream agent. Each criterion targets a specific failure mode in lossy compression.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Key Decision Retention | All explicit user decisions and agent commitments from the original conversation appear in the summary. | A decision present in the source transcript is missing or altered in the compressed output. | Diff the source decisions list against the summary decisions list. Flag any missing or semantically changed items. |
User Correction Preservation | Every user correction of a prior agent output is captured with the original error and the corrected value. | The summary omits a correction, repeats the pre-correction error, or loses the correction context. | Inject 3 known corrections into a test transcript. Verify all 3 appear in the summary with correct before/after values. |
Unresolved Question Capture | All questions the user asked that remain unanswered are listed in a dedicated Unresolved section. | An open question from the transcript is missing from the summary or is incorrectly marked as resolved. | Tag open questions in the source. Assert the summary Unresolved list contains all tagged items and no resolved items. |
Schema Compliance | The output is valid JSON matching the expected handoff schema with all required fields present. | The output is not parseable JSON, or required fields such as decisions, corrections, or unresolved are absent. | Validate output against the JSON Schema definition. Reject on parse failure or missing required fields. |
Token Budget Adherence | The compressed summary stays within the specified [MAX_OUTPUT_TOKENS] limit. | The summary exceeds the token budget, forcing truncation by the downstream agent. | Count output tokens with the target model's tokenizer. Fail if count exceeds [MAX_OUTPUT_TOKENS]. |
Hallucination Absence | The summary contains no facts, decisions, or corrections not present in the source conversation. | The summary introduces a fabricated decision, invents a user preference, or adds a resolution not in the source. | Perform claim-by-claim grounding check against the source transcript. Flag any unsupported claim. |
Confidence Annotation Accuracy | Low-confidence or ambiguous items are annotated with a confidence label and reasoning. | A speculative or unclear item is presented as a confirmed fact without uncertainty qualification. | Identify ambiguous segments in the source. Assert each has a corresponding confidence annotation in the summary. |
Temporal Sequence Integrity | The chronological order of decisions and corrections is preserved in the summary. | A later correction appears before the original decision it corrects, or event ordering is reversed. | Number events in the source transcript. Assert the summary preserves ascending order for decision and correction lists. |
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 and a simple JSON schema for the summary output. Use a single model call without retries. Define [CONVERSATION_HISTORY] as the raw transcript and [COMPRESSION_RATIO] as a rough target (e.g., "reduce to 30% of original tokens"). Skip eval harness integration initially.
Watch for
- The model dropping user corrections or preference changes in favor of the most recent turn
- Over-compression that removes the specific reason for a handoff (e.g., "I need to escalate this")
- Format drift when the model returns prose instead of the requested JSON structure

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