This prompt is for agent and copilot builders whose systems cache or carry forward API responses across conversation turns. Its job is to evaluate a previously fetched API response against the current user intent and conversation state to determine if the data is still valid. The ideal user is a product engineer or AI operator who needs a structured, programmatic freshness assessment—not a generic summary—that can be wired directly into a tool-use loop. You need this when your agent relies on time-sensitive data from external services (pricing, inventory, status, weather, flight times) and a stale response would produce a confident wrong answer.
Prompt
Stale API Response Handling Prompt

When to Use This Prompt
Define the job, the user, and the boundaries for the Stale API Response Handling Prompt.
Use this prompt when you have a concrete API response payload, a timestamp for when it was fetched, and the current conversation context that might invalidate it. The prompt expects you to provide the original API response, its age, the user's latest query, and any domain-specific volatility rules. It is not designed for detecting staleness in retrieved documents, session summaries, or model-generated text—use the sibling prompts for those cases. It also does not decide whether to re-call the API; it produces a structured assessment that your application code should act on, including recommended re-call parameters and a fallback response if the API is unavailable.
Do not use this prompt when the API response is static reference data that does not expire, or when your application already has a deterministic cache-invalidation strategy based on HTTP headers or TTLs. The prompt adds latency and cost, so reserve it for cases where staleness depends on semantic context—for example, a flight status fetched 10 minutes ago might still be valid for a 'check my flight' query but stale for a 'has my flight been delayed in the last 5 minutes?' query. Before deploying, test against a labeled dataset of API responses with known staleness states, and always pair this prompt with a validation step that compares the freshness assessment against ground truth. If the API response contains regulated or safety-critical data, require human review before acting on the staleness decision.
Use Case Fit
Where the Stale API Response Handling Prompt delivers value and where it introduces risk. Use these cards to decide if this prompt fits your architecture before wiring it into a production agent loop.
Good Fit: Time-Sensitive Tool Outputs
Use when: your agent calls APIs that return data with a known shelf life—stock prices, weather, flight status, inventory counts, or CI/CD pipeline states. The prompt evaluates a cached response against the current conversation context to decide if it's still valid. Guardrail: always include a cached_at timestamp and the API endpoint's documented volatility profile in the prompt input.
Good Fit: Cost-Conscious Agent Loops
Use when: you want to avoid re-calling expensive or rate-limited APIs if the prior response is likely still fresh. The prompt's freshness assessment and recommended re-call parameters let you skip unnecessary calls. Guardrail: set a maximum staleness threshold in your application layer—if the prompt's confidence is below it, re-call regardless of the recommendation.
Bad Fit: Real-Time Safety-Critical Systems
Avoid when: the API response controls a physical actuator, medical device, or safety interlock where any stale data could cause harm. The prompt's probabilistic freshness assessment is not a safety guarantee. Guardrail: for safety-critical paths, bypass the prompt entirely and enforce a hard real-time re-query with a circuit breaker on failure.
Required Inputs: Timestamps and Volatility Metadata
What to watch: the prompt cannot assess freshness without knowing when the data was fetched and how quickly the underlying domain changes. Missing metadata produces garbage freshness scores. Guardrail: your tool wrapper must attach cached_at (ISO 8601), ttl_seconds (if known), and a volatility label (low/medium/high) to every cached response before it reaches this prompt.
Operational Risk: Silent Staleness Propagation
What to watch: if the prompt incorrectly classifies a stale response as fresh, the agent will use bad data in downstream actions—booking a flight with an old price, or approving a deploy on a stale pipeline status. Guardrail: log every freshness assessment with the cached response age, the prompt's confidence, and the final action taken. Alert on any case where a 'fresh' classification is older than the domain's known half-life.
Operational Risk: Unnecessary Re-Call Storms
What to watch: a prompt that is too aggressive about flagging staleness will trigger re-calls on every turn, defeating the cost-saving purpose and potentially hitting rate limits. Guardrail: tune the prompt's staleness sensitivity with a few-shot example that demonstrates when slightly-aged data is acceptable. Monitor the re-call-to-cache-hit ratio in production and adjust examples if it drifts above 50%.
Copy-Ready Prompt Template
A reusable prompt template for evaluating cached API responses against the current conversation context to determine data freshness and recommend actions.
This prompt template is the core engine for detecting stale API data in agent and copilot workflows. It takes a previously cached API response, the original query that produced it, and the current conversation context, then outputs a structured freshness assessment. The template is designed to be dropped into a larger application harness that manages API call history, caching logic, and tool execution. Use square-bracket placeholders to inject the specific data, context, and constraints relevant to your use case before sending the prompt to the model.
textYou are an API response freshness evaluator for an AI assistant. Your job is to determine whether a cached API response is still valid given the current conversation context, or whether the data should be re-fetched. ## INPUTS ### Cached API Response - Endpoint: [API_ENDPOINT] - Called at: [CALL_TIMESTAMP] - Parameters: [ORIGINAL_PARAMETERS] - Response body: [CACHED_RESPONSE_BODY] - Cache TTL (seconds): [CACHE_TTL] ### Current Conversation Context - Current user query: [CURRENT_USER_QUERY] - Recent conversation turns (last 5): [RECENT_TURNS] - Current session state: [SESSION_STATE] - Time elapsed since API call (seconds): [ELAPSED_SECONDS] ### Data Volatility Profile - Data type: [DATA_TYPE] (e.g., stock price, weather, user profile, inventory count) - Expected update frequency: [UPDATE_FREQUENCY] - Known volatility indicators: [VOLATILITY_INDICATORS] ## OUTPUT SCHEMA Return a JSON object with exactly these fields: { "freshness_status": "fresh" | "stale" | "uncertain" | "expired", "confidence": 0.0-1.0, "stale_factors": ["list of specific reasons the data may be stale"], "recommended_action": "use_cached" | "re_fetch" | "ask_user" | "use_with_caveat", "re_fetch_parameters": { "endpoint": "string or null", "parameters": {}, "reason": "string explaining what changed" }, "fallback_response": "string to use if re-fetch fails", "user_facing_caveat": "string explaining staleness risk to user, or null if fresh", "cache_update_recommendation": "extend" | "invalidate" | "shorten_ttl" | "no_change" } ## CONSTRAINTS - If the data type is highly volatile (e.g., live stock prices) and elapsed time exceeds 30 seconds, mark as stale. - If the current user query references a time or state that postdates the API call timestamp, mark as stale. - If the conversation context shows the user has contradicted or updated information in the cached response, mark as stale. - If the cache TTL has expired, mark as expired regardless of content. - If you are uncertain, prefer "ask_user" over silently using potentially stale data. - Never fabricate re-fetch parameters. If you cannot determine what to re-fetch, set re_fetch_parameters to null and recommend "ask_user". - The user_facing_caveat must be concise, honest, and actionable. Do not alarm the user unnecessarily. ## EXAMPLES [EXAMPLES] ## RISK LEVEL [RISK_LEVEL] Evaluate the cached API response against the current context and return only the JSON object.
To adapt this template for your system, start by replacing the [DATA_TYPE], [UPDATE_FREQUENCY], and [VOLATILITY_INDICATORS] placeholders with domain-specific values that match the APIs your agents call. For high-risk domains such as financial transactions or healthcare data, set [RISK_LEVEL] to "high" and add constraints that require human review before acting on stale data. The [EXAMPLES] placeholder should be populated with 2-4 few-shot examples showing correct freshness assessments for your specific API types—include at least one example where the data is fresh, one where it is stale, and one edge case where the model should express uncertainty. If your application already has a defined output schema, replace the JSON structure with your own, but preserve the core decision fields: freshness status, confidence, recommended action, and user-facing caveat.
Prompt Variables
Inputs required by the Stale API Response Handling Prompt. Each placeholder must be populated before the prompt is assembled. Validation notes describe how to check that the input is well-formed and safe.
| Placeholder | Purpose | Example | Validation Notes |
|---|---|---|---|
[API_RESPONSE_PAYLOAD] | The full JSON or XML body from the cached or prior-turn API call to evaluate for staleness. | {"price": 142.33, "timestamp": "2025-03-21T14:22:00Z"} | Must be valid JSON or XML. Parse check required. Null allowed if the prior call failed; prompt will handle the missing-data path. |
[API_RESPONSE_TIMESTAMP] | The ISO-8601 timestamp of when the API response was originally received. | 2025-03-21T14:22:00Z | Must parse as a valid ISO-8601 datetime. Must not be in the future relative to system clock. Required; null triggers a pre-prompt rejection. |
[CURRENT_USER_QUERY] | The user's latest message or the current turn text that may depend on the API data. | What is the current price of AAPL? | Must be a non-empty string. Length should be reasonable for the model's context window. No PII allowed unless redacted upstream. |
[DATA_VOLATILITY_PROFILE] | A structured description of how quickly this API's data becomes stale, including expected TTL and known volatility patterns. | Stock price: real-time, TTL 60s. FX rate: 5-min refresh. Account balance: intra-day. | Must be a non-empty string or structured object. Should be sourced from API documentation or SLO definitions. Human review required if the profile is manually authored. |
[PRIOR_CONVERSATION_CONTEXT] | The last N turns of conversation or a session summary that provides the context in which the API response was originally used. | [{"role": "assistant", "content": "AAPL is at $142.33."}, {"role": "user", "content": "Has it changed?"}] | Must be a valid JSON array of turn objects or a string summary. Null allowed for first-turn evaluations. If present, must not exceed the context budget allocated for history. |
[FALLBACK_RESPONSE_TEMPLATE] | A pre-approved message or action to use if the API is unreachable during a re-call attempt. | Unable to fetch the latest price right now. The last known price was $142.33 at 14:22 UTC. | Must be a non-empty string. Should be reviewed for tone and accuracy. Must not make promises about data freshness that the system cannot keep. |
[RE_CALL_PARAMETERS] | The exact endpoint, method, headers, and query parameters needed to re-call the API for fresh data. | GET /v1/quotes/AAPL?fields=price,timestamp | Must be a valid URL or a structured object with method, path, and params. Security check required: no internal-only endpoints exposed to the model without guardrails. Retry logic should be defined in the harness, not the prompt. |
Implementation Harness Notes
How to wire the Stale API Response Handling Prompt into a production agent loop with validation, retries, and fallback logic.
This prompt is designed to sit inside an agent's tool-use loop, not as a standalone chat interaction. The typical wiring point is immediately before the agent acts on a cached API response or after a user turn that references data from a prior tool call. The harness should call this prompt with the original API response payload, the timestamp of that response, the current conversation context, and any known volatility metadata for the endpoint. The output is a structured freshness assessment that your application code reads to decide whether to re-call the API, use the cached value with a caveat, or fall back to a degraded response.
The implementation should treat the prompt's output as a machine-readable decision, not just text. Parse the freshness_status field (valid, stale, uncertain) and the recommended_action field (use_as_is, re_call, fallback) into your agent's control flow. For re_call, extract the re_call_parameters object and pass it to your API client—these should include the endpoint, query parameters, and any updated filters derived from the new conversation context. For fallback, surface the fallback_response to the user and log the staleness event. Always validate the output schema before acting: if the JSON is malformed or missing required fields, treat it as freshness_status: uncertain and either re-call the API or escalate to a human reviewer depending on the risk level of the decision.
Retry logic should be layered. If the freshness assessment recommends a re-call but the API is unavailable, implement an exponential backoff with a maximum of two retries before falling back to the cached value with a staleness caveat appended to the user-facing response. Log every staleness detection event with the original response timestamp, the freshness score, the action taken, and whether the re-call returned different data. These logs become your evaluation dataset for tuning the prompt's staleness thresholds. For high-risk domains—financial data, healthcare information, safety-critical system state—add a human approval gate when freshness_status is uncertain and the confidence score is below 0.7. The approval UI should display the cached response, the freshness reasoning, and a one-click option to re-call the API or approve the fallback.
Model choice matters for this prompt. Use a model with strong structured output capabilities and low latency, since this check runs on the critical path of every tool-use turn. GPT-4o or Claude 3.5 Sonnet are appropriate for production; avoid smaller models that may hallucinate freshness assessments or fail to follow the output schema under time pressure. If latency is a concern, consider caching the prompt's system instructions as a prompt prefix and batching staleness checks for multiple cached responses in a single call. Do not use this prompt for endpoints with sub-second cache invalidation—at that scale, the freshness check costs more than simply re-calling the API. The prompt is best suited for data with volatility measured in minutes to hours, where the cost of an unnecessary API call exceeds the cost of the staleness check.
Expected Output Contract
Defines the structured JSON output that the Stale API Response Handling Prompt must produce. Use this contract to validate model responses before they reach application logic.
| Field or Element | Type or Format | Required | Validation Rule |
|---|---|---|---|
freshness_assessment | object | Must contain status, confidence, and reasoning fields. Top-level object required. | |
freshness_assessment.status | enum: fresh | stale | uncertain | Must be exactly one of the three allowed values. Reject any other string. | |
freshness_assessment.confidence | number (0.0-1.0) | Must be a float between 0.0 and 1.0 inclusive. Reject if outside range or non-numeric. | |
freshness_assessment.reasoning | string | Must be non-empty. Must reference at least one specific data field or timestamp from [API_RESPONSE]. | |
stale_fields | array of strings | Must be an array. If status is fresh, array must be empty. Each element must match a top-level key in [API_RESPONSE]. | |
recommended_action | enum: use_as_is | re_call | fallback | ask_user | Must be exactly one of the four allowed values. Reject if missing or invalid. | |
re_call_parameters | object | null | Required if recommended_action is re_call. Must contain endpoint and params. If null, no other action types may reference it. | |
fallback_response | string | null | Required if recommended_action is fallback. Must be a user-facing message explaining data unavailability. If null, no fallback is provided. |
Common Failure Modes
Stale API responses produce confident, wrong answers that erode user trust. These are the most common failure modes when evaluating cached or prior-turn API data against the current conversation context, and how to prevent them in production.
Temporal Blindness to Real-Time Data
What to watch: The model treats a cached API response as current despite the user asking about a time-sensitive value (e.g., stock price, deployment status, incident state). The freshness assessment misses the gap between response_timestamp and query_time_now. Guardrail: Always inject explicit timestamps for both the cached response and the current request. Require the prompt to compute the age delta in seconds and compare it against a declared max_age_seconds threshold before assessing freshness.
False Freshness from Volatile Endpoints
What to watch: A response is technically recent but the underlying data source is highly volatile (e.g., live metrics, auction bids, queue depth). The model declares the data fresh because the timestamp is within bounds, ignoring the endpoint's known volatility profile. Guardrail: Include a volatility_tier field in the prompt context (low/medium/high) with explicit half-life guidance. For high-volatility endpoints, require re-call regardless of timestamp unless the response is under 5 seconds old.
Context-Insensitive Freshness Assessment
What to watch: The model evaluates freshness against generic age rules but ignores the user's specific question. A 10-minute-old weather response is stale for 'what's the temperature right now?' but fresh for 'what was the forecast this morning?'. Guardrail: Require the prompt to extract the temporal intent from the user's query before assessing staleness. The freshness decision must reference both the response timestamp and the temporal precision demanded by the question.
Silent Fallback to Stale Data on API Failure
What to watch: The re-call fails (timeout, rate limit, auth error) and the model silently returns the stale cached response without indicating it may be outdated. The user receives confident but potentially wrong information. Guardrail: Require the prompt to output a fallback_disclaimer string whenever the re-call fails and stale data is used. The disclaimer must state the age of the data and that a live refresh was attempted but unavailable. Never allow silent stale-data fallback.
Over-Refresh on Low-Stakes Queries
What to watch: The model triggers a re-call for every query regardless of staleness risk, wasting API budget and increasing latency. A user asking 'remind me what that API returned earlier' doesn't need a live refresh. Guardrail: Include a refresh_priority scoring rubric in the prompt that weighs query criticality, data volatility, and user intent. Only trigger re-calls when the priority score exceeds a configurable threshold. Log refresh decisions for cost observability.
Stale Parameters in Re-Call Construction
What to watch: The model correctly identifies staleness but constructs the re-call with outdated parameters from the original request, missing new user constraints or conversation context that should narrow the refresh. Guardrail: Require the prompt to merge original request parameters with any new constraints from the current conversation turn before generating the re-call payload. Validate that the re-call parameters differ from the original when user context has shifted.
Evaluation Rubric
Use this rubric to evaluate the Stale API Response Handling Prompt before deployment. Each criterion targets a specific failure mode observed in production. Run these tests against a golden dataset of API responses with known age, volatility, and correctness.
| Criterion | Pass Standard | Failure Signal | Test Method |
|---|---|---|---|
Freshness Assessment Accuracy | Correctly labels responses older than their domain-specific TTL as 'stale' and responses within TTL as 'fresh' for 95% of test cases. | Fresh data flagged as stale (false positive) or stale data marked fresh (false negative). | Run against 50 labeled API response pairs with known timestamps and domain half-lives. Measure precision and recall. |
Re-call Parameter Correctness | When a re-call is recommended, the generated query parameters match the original request parameters with only the necessary time-range or version adjustments. | Re-call parameters drop required fields, change the endpoint, or widen the scope unnecessarily. | Compare generated re-call parameters to a ground-truth re-call spec. Check for missing required fields and schema validity. |
Fallback Response Safety | When the API is unavailable, the fallback response clearly states the data may be outdated, cites the last-known timestamp, and avoids confident assertions. | Fallback response presents stale data as current or omits the staleness caveat entirely. | Inject simulated API unavailability. Check output for presence of a staleness disclaimer and absence of unqualified claims. |
Volatility Handling | Correctly shortens the acceptable freshness window for highly volatile data (e.g., stock prices) and lengthens it for stable data (e.g., legal entity names). | Applies a uniform freshness threshold regardless of data volatility class. | Test with pairs of high-volatility and low-volatility API responses of the same age. Verify the staleness verdict differs appropriately. |
Context Relevance Check | Does not flag an API response as stale solely based on age if the user's current question does not depend on the time-sensitive fields within that response. | Flags a response as stale when the user's follow-up question only uses time-invariant fields from the cached data. | Provide a cached response with mixed time-sensitive and time-invariant fields. Ask a question using only the time-invariant fields. Verify the output is 'fresh'. |
Output Schema Compliance | Output is valid JSON matching the [OUTPUT_SCHEMA] exactly, including all required fields and correct enum values for freshness assessment. | Output is missing required fields, uses undefined enum values, or wraps valid JSON in a markdown code fence. | Validate output against the [OUTPUT_SCHEMA] using a JSON Schema validator. Reject on any validation errors. |
Confidence Calibration | The staleness confidence score correlates with actual data incorrectness. High-confidence stale predictions are more likely to be truly stale. | High confidence scores assigned to incorrect staleness predictions, or low confidence to correct ones. | Plot a calibration curve using 100 test cases with known ground-truth staleness. Brier score should be below 0.2. |
Latency Budget Adherence | The prompt's reasoning and output generation do not add more than 2 seconds of latency on top of the base model response time for a standard context size. | Prompt causes excessive reasoning loops or verbose output that consistently exceeds the latency budget. | Measure end-to-end response time over 50 runs. Calculate P95 latency. Flag if P95 exceeds the base model P95 by more than 2 seconds. |
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 prompt and a simple freshness check. Use a single [API_RESPONSE] and [CONVERSATION_CONTEXT] placeholder. Define [STALENESS_THRESHOLD_MINUTES] as a hardcoded value. Skip structured output initially—just ask for a freshness label and a one-sentence reason.
codeYou are evaluating whether a cached API response is still valid for the current conversation. API Response (cached at [CACHE_TIMESTAMP]): [API_RESPONSE] Current Conversation Context: [CONVERSATION_CONTEXT] Determine if the cached response is still fresh. Consider: - How much time has passed since caching - Whether the conversation topic has shifted - Whether the user has introduced contradictory information Return: FRESH or STALE, plus a one-sentence reason.
Watch for
- Overly sensitive staleness flags on data that's stable by nature
- No distinction between "data expired" and "user changed the subject"
- Missing timezone handling in timestamp comparisons

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