This prompt is designed for context window managers and AI engineers who need to programmatically estimate how quickly prior conversation turns lose relevance to the current task. The core job-to-be-done is assigning a quantitative decay score and a recommended retention window to each piece of context (turns, retrieved documents, tool outputs) before a context budget is exceeded. This is not a prompt for end-users; it is an infrastructure component that sits between a conversation state tracker and a context assembly step, deciding what to keep, compress, or drop.
Prompt
Context Relevance Decay Scoring Prompt

When to Use This Prompt
Define the job, the ideal user, required inputs, and the boundaries where this prompt should not be applied.
The ideal user is a production AI engineer building a multi-turn assistant, copilot, or agent where context windows are a constrained resource. You should use this prompt when you have structured conversation history, a clear definition of the current user goal, and a need to make automated pruning decisions at scale. Required inputs include a structured list of context elements with timestamps or turn indices, a description of the current task or user intent, and a defined output schema for decay scores. Do not use this prompt for real-time, low-latency chat where the overhead of scoring exceeds the cost of simply retaining all context, or in single-turn workflows where there is no history to manage.
This prompt is a decision-support tool, not a final authority. Its output should feed into a deterministic pruning or summarization step in your application code. In high-stakes domains—such as healthcare, legal, or financial advice—a human must review the retention decisions before context is permanently dropped, because an incorrectly pruned fact can lead to harmful omissions. After reading this section, proceed to the prompt template to copy the exact instructions, then review the implementation harness for wiring this into a production context management pipeline.
Use Case Fit
Where the Context Relevance Decay Scoring Prompt works, where it fails, and the operational prerequisites for production use.
Good Fit: Long-Running Agent Sessions
Use when: Autonomous agents or copilots maintain sessions exceeding 20+ turns where context pollution degrades planning accuracy. Why: The decay scores provide a quantitative signal for pruning irrelevant history before it corrupts tool selection and task decomposition.
Bad Fit: Stateless Single-Turn Requests
Avoid when: The system processes isolated Q&A with no session history. Why: Decay scoring adds latency and token cost with zero benefit when there is no prior context to evaluate. Use a simple RAG prompt instead.
Required Input: Structured Turn History
Risk: Free-text conversation logs produce unreliable decay scores because the model cannot reliably segment turns or identify dependencies. Guardrail: Input must be pre-segmented into timestamped, speaker-labeled turns with resolved references before scoring.
Operational Risk: Premature Context Eviction
Risk: Aggressive pruning based on decay scores can drop turns that become relevant again after a topic return. Guardrail: Always pair decay scoring with a topic return detection prompt that can restore pruned context when users circle back to prior subjects.
Operational Risk: Decay Model Drift
Risk: Decay score calibration shifts when the underlying model is updated, causing over-retention or over-pruning. Guardrail: Maintain a golden dataset of annotated sessions with known relevance windows and run regression tests on every model version change before deploying updated decay thresholds.
Required Input: Task-Specific Relevance Rubric
Risk: Generic relevance scoring produces decay curves that don't align with actual downstream task performance. Guardrail: Provide a rubric defining what 'relevant' means for your specific use case—planning accuracy, answer faithfulness, or tool-call correctness—and validate decay scores against that metric.
Copy-Ready Prompt Template
A reusable prompt template for scoring the relevance decay of conversation context elements, with placeholders for your specific inputs, constraints, and output schema.
This prompt template is the core of the Context Relevance Decay Scoring workflow. It instructs the model to act as a context window manager, analyzing each provided context element (a prior turn, a retrieved fact, a tool output) and assigning a decay score that estimates how quickly its relevance will diminish. The output is a structured list of decisions that can be consumed by your application's context pruning or retention logic. Before copying this template, ensure you have a clear definition of your conversation phases and a list of context elements you want to evaluate.
markdownYou are a context window manager for an AI assistant. Your task is to analyze a list of context elements from an ongoing conversation and assign a relevance decay score to each one. This score will be used to decide which elements to retain, compress, or drop as the conversation progresses and the context budget tightens. **Conversation Phase:** [CURRENT_PHASE] **User's Latest Utterance:** [USER_INPUT] **Context Elements to Score:** [CONTEXT_ELEMENTS] **Scoring Rubric:** - **1 (Critical):** Essential for understanding the current turn or immediate next steps. Do not drop. - **2 (High):** Directly relevant to the active topic but not the immediate focus. Retain if possible. - **3 (Medium):** Related to the broader session but not the current topic. Candidate for compression. - **4 (Low):** Resolved, completed, or from a clearly abandoned topic. Safe to drop. - **5 (Expired):** Factually invalidated by new information or a user correction. Must be dropped or overwritten. **Output Schema:** Return a JSON object with a single key "scored_elements" containing an array of objects. Each object must have the following fields: - "element_id": (string) The identifier of the context element from the input. - "decay_score": (integer) A score from 1 to 5 based on the rubric. - "rationale": (string) A brief, specific justification for the score, referencing the conversation phase and user input. - "recommended_action": (string) One of: "retain", "compress", "drop", "overwrite". **Constraints:** - Score every element in the provided list. - If the user's latest utterance signals a clear topic shift, scores for elements from the prior topic should trend toward 4 or 5. - A user correction that contradicts a prior element must result in a score of 5 (Expired) for that element. - Do not drop elements that contain unresolved questions or pending actions, even if the topic appears to have shifted.
To adapt this template, replace the square-bracket placeholders with your application's data. [CURRENT_PHASE] should be a string label from your conversation phase classifier. [USER_INPUT] is the raw text of the latest user message. [CONTEXT_ELEMENTS] is the most critical part: it should be a pre-formatted list of objects, each with an element_id and the content to be scored. The output schema is designed for direct parsing; your application should validate that every input element_id is present in the output and that the decay_score is an integer within the 1-5 range. For high-stakes applications, log the rationale field for human auditability.
Prompt Variables
Required inputs for the Context Relevance Decay Scoring Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model. Validation notes describe how to programmatically verify the input before execution.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[CONVERSATION_HISTORY] | The sequence of prior turns to evaluate for relevance decay. Must include turn indices, speaker roles, and timestamps. | {"turns": [{"index": 1, "role": "user", "content": "How do I reset my password?", "timestamp": "2024-01-15T10:03:00Z"}, {"index": 2, "role": "assistant", "content": "You can reset it by clicking...", "timestamp": "2024-01-15T10:03:05Z"}]} | Schema check: must be a valid JSON array of turn objects. Each turn requires index (integer), role (enum: user, assistant, system, tool), content (non-empty string), and timestamp (ISO 8601). Reject if turns are missing or content is empty. |
[CURRENT_TOPIC] | The active topic or intent label for the most recent user turn. Used as the reference point for measuring decay of prior turns. | "account_recovery" | Non-empty string required. Must match a value from the allowed topic taxonomy if one is enforced. Null allowed only if no topic classifier is upstream; in that case, the prompt must infer the current topic from the last user turn. |
[TOPIC_TAXONOMY] | The set of valid topic labels the system recognizes. Constrains the decay scoring to known categories and prevents hallucinated topic names. | ["account_recovery", "billing_inquiry", "technical_support", "feature_request", "complaint"] | Must be a non-empty array of unique strings. If empty or null, the prompt must be configured to operate in open-topic mode, which increases the risk of inconsistent topic labeling across evaluations. |
[DECAY_THRESHOLD] | The relevance score below which a context element is considered stale and should be pruned or compressed. Expressed as a float between 0.0 and 1.0. | 0.3 | Must be a float in range [0.0, 1.0]. Values outside this range should be clamped or rejected. Default to 0.5 if not specified. Lower values retain more context; higher values prune more aggressively. |
[RETENTION_WINDOW_HINT] | An optional maximum number of turns to retain regardless of relevance scores. Prevents the decay scorer from pruning everything in very long sessions. | 20 | Integer or null. If provided, must be >= 1. If null, no hard cap is applied and the decay scorer relies entirely on relevance scores. Warn if set below 5, as this may drop essential context in multi-turn workflows. |
[OUTPUT_SCHEMA] | The expected JSON schema for the decay scoring output. Defines the structure the model must produce so downstream context managers can parse it reliably. | {"type": "object", "properties": {"decay_scores": {"type": "array", "items": {"type": "object", "properties": {"turn_index": {"type": "integer"}, "relevance_score": {"type": "number"}, "retention_recommendation": {"type": "string", "enum": ["keep", "compress", "drop"]}, "rationale": {"type": "string"}}, "required": ["turn_index", "relevance_score", "retention_recommendation"]}}}, "required": ["decay_scores"]} | Must be a valid JSON Schema object. Reject if schema is missing required fields or if enum values for retention_recommendation are not exactly keep, compress, drop. Validate that the schema can be parsed by a standard JSON Schema validator before prompt assembly. |
[SESSION_METADATA] | Optional metadata about the session, including session duration, total turn count, and any known phase labels. Provides additional signal for decay estimation. | {"session_duration_seconds": 1240, "total_turns": 34, "current_phase": "troubleshooting"} | If provided, must be a valid JSON object. All fields are optional. If session_duration_seconds is present, must be a positive number. If total_turns is present, must be a positive integer and should match the length of CONVERSATION_HISTORY. Mismatch triggers a warning but does not block execution. |
Implementation Harness Notes
How to wire the Context Relevance Decay Scoring Prompt into a production context window manager.
This prompt is designed to be called as a background evaluation step, not as a synchronous user-facing interaction. The primary integration point is inside a context assembly pipeline that runs before each model call. After new user input arrives, the harness should collect all current context elements (prior turns, retrieved documents, tool outputs, session summaries) and pass them to this prompt to receive decay scores and retention recommendations. The output is consumed programmatically—users never see the raw scores. Instead, the scores drive automated decisions about which context to keep, compress, or drop before assembling the final prompt payload for the primary task model.
Validation and Schema Enforcement: The prompt output must be validated against a strict schema before any context is modified. Require a JSON object with a decay_scores array where each element contains context_id (string), decay_score (float 0-1), recommended_retention (enum: keep_full, summarize, drop), and rationale (string). Implement a post-processing validator that checks: (1) every input context element has exactly one corresponding output entry, (2) all scores are within 0-1, (3) retention recommendations are valid enum values, and (4) the total token count of keep_full items does not exceed your budgeted allocation. If validation fails, retry once with the validation errors appended to the prompt as feedback. If the retry also fails, fall back to a conservative policy: keep the last N turns and the most recent retrieval results, drop everything else, and log the failure for review.
Model Selection and Latency Budget: This scoring task benefits from models with strong instruction-following and structured output capabilities. Use a fast, cost-efficient model (e.g., GPT-4o-mini, Claude 3.5 Haiku, or a fine-tuned small model) rather than your primary high-capability model. The decay scoring step adds latency to every turn, so target sub-500ms response times. If your primary model call already has a 2-second budget, allocate no more than 500ms for decay scoring. Implement a timeout: if the scoring call exceeds 800ms, abort it and apply the default retention policy. Log timeouts separately from validation failures—they indicate a need for model downgrade or prompt compression, not a logic error.
Integration with Context Budgeting: The decay scores should feed directly into your context window budget allocator. A typical pattern: set a decay_threshold (e.g., 0.7) above which items are candidates for summarization, and a drop_threshold (e.g., 0.9) above which items are dropped entirely. Items scoring below 0.3 should be preserved in full. The summarization step itself can use a separate summarizer prompt or a lightweight model call, but only trigger it for items marked summarize—do not summarize everything preemptively. Store the decay scores alongside each context element in your session state so that subsequent turns can track decay trajectories and detect acceleration (e.g., a score jumping from 0.4 to 0.8 in one turn may signal a topic shift that requires broader context reset).
Observability and Evaluation: Log every decay scoring call with: input context count, output score distribution, validation pass/fail, latency, and the final retention decisions. Build a dashboard panel showing the average decay score per turn and the percentage of context dropped versus retained. For offline evaluation, create a golden dataset of conversation transcripts with human-annotated relevance judgments at each turn. Measure whether your decay scores correlate with human judgments and, more importantly, whether downstream task performance (answer quality, retrieval precision) degrades when context is pruned according to your scores versus a full-context baseline. If pruning causes a statistically significant quality drop, raise your retention thresholds or increase your context budget before shipping the optimization.
Failure Modes to Monitor: The most common production failure is premature context dropping—the scorer assigns high decay scores to turns that are actually relevant to a later user question, causing the primary model to answer without necessary history. Mitigate this by implementing a safety net: never drop the most recent 3 turns regardless of score, and never drop turns containing explicit user commitments or unresolved questions (detect these with a separate classifier if needed). A second failure mode is score inflation on long sessions, where the model assigns uniformly high decay scores to everything beyond a certain age, effectively reverting to a recency-only policy. Monitor for this by tracking the correlation between turn age and decay score—if the correlation exceeds 0.9, your prompt is not discriminating based on content relevance and needs adjustment. A third failure mode is context ID mismatch, where the model hallucinates context IDs that don't match your input. Your validator must catch this and trigger a retry or fallback.
Expected Output Contract
Defines the fields, types, and validation rules for the context relevance decay scoring output. Use this contract to parse and validate the model response before downstream consumption.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
context_element_id | string | Must match an input context element identifier exactly. Parse check: non-empty, no whitespace-only values. | |
decay_score | float | Must be a number between 0.0 and 1.0 inclusive. 0.0 means fully relevant, 1.0 means fully decayed. Schema check: numeric type, range enforcement. | |
retention_window_turns | integer | Must be a positive integer representing the recommended number of future turns to retain this element. Null allowed only if decay_score is 1.0. Parse check: integer type, minimum value 0. | |
decay_confidence | float | Must be a number between 0.0 and 1.0 inclusive representing the model's confidence in the decay assessment. Schema check: numeric type, range enforcement. | |
decay_rationale | string | Must be a non-empty string explaining why the decay score was assigned. Should reference specific evidence from the conversation. Parse check: minimum 10 characters. | |
recommended_action | string | Must be one of: retain, compress, drop, re-verify. Enum check: exact string match required. drop requires decay_score >= 0.8. re-verify requires decay_confidence < 0.7. | |
cross_topic_dependency | boolean | Must be true if this context element is referenced by or depends on elements from other topics. False otherwise. Type check: boolean only. | |
dependent_element_ids | array of strings | If cross_topic_dependency is true, must contain at least one valid context_element_id. If false, must be an empty array. Null not allowed. Schema check: array type, element reference validation. |
Common Failure Modes
Context relevance decay scoring fails silently in production. These are the most common failure patterns and how to prevent them before they corrupt downstream responses.
Uniform Decay for All Context
What to watch: The model assigns identical decay scores to every context element, treating a user's name the same as a three-turn-old clarification. This produces useless retention windows. Guardrail: Add a calibration check that flags output when the standard deviation of decay scores falls below a minimum threshold. Require the prompt to justify differentiation between at least two context elements.
Recency Bias Overwhelms Relevance
What to watch: The model scores recent but irrelevant turns higher than older but critical context, such as a constraint set five turns ago. This causes the context manager to drop binding instructions. Guardrail: Include explicit examples in the prompt where older constraint-bearing turns outrank recent filler. Validate that high-importance markers survive recency-weighted scoring in your eval set.
Decay Score Drift on Long Sessions
What to watch: As the context window fills, the model compresses its reasoning and starts producing noisier, less reliable decay scores. Scores become arbitrary after 30+ turns. Guardrail: Implement a sliding evaluation window. If the variance of decay scores increases beyond a threshold in the second half of a session, trigger a full context summarization instead of per-element decay scoring.
Retention Window Mismatch with Downstream Task
What to watch: The prompt recommends retaining context for N turns, but the downstream task actually needs it for N+3 turns. The context is dropped before the task completes. Guardrail: Do not rely solely on the prompt's retention recommendation. Instrument your application to measure task completion rates against actual retention windows. Use this data to set minimum retention overrides per context type.
Implicit Context Dependencies Missed
What to watch: The model scores a clarification turn as low relevance and marks it for pruning, but a later answer depends on that clarification. Dropping it causes hallucination or contradiction. Guardrail: Extend the prompt to require explicit dependency mapping before scoring. A context element cannot be pruned if another active element references it. Validate this with multi-hop reasoning test cases.
Over-Aggressive Pruning on Topic Shift
What to watch: A topic shift is detected and the decay scorer drops all prior context, including unresolved commitments and user preferences that span topics. The assistant forgets a promise made before the shift. Guardrail: Add a protected context category for unresolved questions and persistent user constraints. These items bypass decay scoring and are only removed on explicit resolution or user override.
Evaluation Rubric
Use this rubric to test whether the Context Relevance Decay Scoring Prompt produces reliable, actionable decay scores before integrating it into a production context window manager.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Decay Score Range | Every context element receives a numeric score between 0.0 and 1.0. | Scores outside 0.0-1.0, missing scores, or non-numeric values. | Parse output and assert all scores are floats in [0.0, 1.0]. |
Retention Window Recommendation | Each element includes a recommended retention window in turns with a non-negative integer value. | Missing retention window, negative values, or non-integer types. | Schema validation: check field presence, type, and value >= 0. |
Temporal Ordering Sensitivity | Older turns receive lower relevance scores than semantically equivalent recent turns in a controlled test. | Recent turns scored lower than older turns with identical semantic content. | Submit a synthetic transcript with repeated topics at known turn distances; assert monotonic score decrease with age. |
Topic Shift Detection | Elements from a prior topic receive scores below 0.3 after a clear, explicit topic shift. | Prior-topic elements retain scores above 0.5 after an unambiguous shift. | Use a two-topic transcript with a hard boundary; assert mean prior-topic score < 0.3. |
Cross-Turn Dependency Preservation | An unresolved question from an older turn retains a score above 0.7 if never addressed. | Unresolved commitment scored below 0.5 despite no resolution in subsequent turns. | Inject an explicit pending action early in a transcript; assert its score remains high at session end. |
Output Schema Compliance | Output is valid JSON matching the defined [OUTPUT_SCHEMA] with all required fields present. | Missing fields, extra fields, or malformed JSON that fails parsing. | Validate output against the JSON Schema using a standard validator; reject on any schema violation. |
Confidence Alignment | Low-confidence decay scores (below 0.6) correlate with downstream task errors when using those context elements. | High-confidence scores on elements that cause retrieval or reasoning errors in a downstream eval. | Run a downstream QA task with and without low-scored context; measure error rate delta. |
Staleness vs. Relevance Distinction | Stale factual context (outdated information) is scored low even if semantically related to the current topic. | Outdated facts retain high relevance scores due to topical similarity. | Provide a transcript where a fact is later contradicted; assert the original fact's score drops below 0.4 after the correction turn. |
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 prompt with a simple JSON output expectation. Drop the strict schema validation and focus on getting decay scores and retention windows that look directionally correct. Run a small set of hand-annotated conversation turns through the prompt and spot-check whether older, off-topic turns get higher decay scores than recent, on-topic turns.
Prompt modification
Remove the [OUTPUT_SCHEMA] placeholder and replace it with a loose instruction: Return a JSON array of objects, each with "element_id", "decay_score" (0-1), and "recommended_retention_turns" (integer).
Watch for
- Scores clustering around 0.5 because the model is hedging
- Retention windows that are too generous, keeping irrelevant context alive
- No differentiation between factual staleness and topic irrelevance

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