AI

AgentOps: validate a semantic response cache before production reuse

A runbook for testing the boundaries, freshness and rollback of an AI response cache before enabling it.

02 Dec 2026 aiagentopsagentscachingsecurityevaluationguardrailsobservabilityrunbookrollbackproduction

An internal assistant answers questions about operating procedures. To reduce latency, the team considers returning an earlier answer when a new question looks similar. Yet “how do I restart the test worker?” and “how do I restart the production worker?” may be close in vector space while requiring different answers. A stale answer, or one returned to the wrong audience, can become an incident.

This fictional case uses an assistant backed by a procedure corpus and an application response cache. Unlike a model provider’s prompt cache, this semantic cache can return an entire answer without running retrieval or generation again. Enable it only when the team can demonstrate the boundaries and freshness of every reused answer.

Decide what is eligible

Start with public content, or content explicitly approved for everyone in the intended scope, and informational answers with no side effects. Keep sensitive or security-related data, personalized answers, tool results, incident state and production change instructions out of the cache. A cached answer is never authorization, approval or evidence that an action occurred.

Microsoft recommends semantic caching only where semantic equivalence is actually acceptable and the data is not private or sensitive. If that cannot be established, keep the normal retrieval and generation path with its access controls. Similarity is neither an authorization decision nor a correctness guarantee.

Separate reading a generic procedure from applying it to a real target. Before an action, retrieve current state, recheck permissions and approval, and apply the usual guardrails. Never replay a tool call from a cached answer.

Establish the reuse contract

Before similarity search, enforce exact filters from trusted context: environment, authorized scope, language and relevant policy, model, prompt and corpus versions. Exclude answers that depend on a user or changing permissions by default; a partitioned key alone does not make sensitive data safe to cache. Do not put raw sensitive questions or tokens in keys or logs.

For each eligible entry, retain at least an opaque identifier, creation time, absolute expiry, context versions, source references and versions, and approved classification. Serve it only when exact filters, current policy, freshness and the similarity threshold all pass. Missing context, revocation or uncertainty means a miss: use the normal authorized path, not the old answer.

A TTL bounds age but does not replace invalidation. Withdrawing a procedure, changing its classification or revoking access must immediately make affected entries ineligible. Version the namespace or invalidate by source reference, and verify that every instance applies the change. If invalidation cannot be confirmed, disable reads from the affected cache. Corpus changes may also affect answers whose recorded source list is incomplete; invalidate the entire version when in doubt.

Build a refusal test set

In an isolated environment, use fictional documents and compare each candidate with the authorized answer and current sources. Include both ordinary and adversarial pairs; do not tune the threshold only on positive examples:

  1. A paraphrase in the same context, with an unchanged public procedure: potentially reusable.
  2. Test versus production, a different region or resource, negation, or a different version: no reuse when operational meaning changes.
  3. The same wording across scopes or after revocation: no answer from another scope; access checks still apply.
  4. A source withdrawn, changed or reclassified before expiry: invalidate the entry, including on warm instances.
  5. A changed policy, model, prompt or index; missing metadata; or an unavailable cache: miss and use the controlled normal path.
  6. An answer containing sensitive data, current state or an action proposal: never insert or reuse it.

Measure dangerous false hits and cross-scope exposure separately from hit rate and latency. Have business and security owners review borderline cases. A high similarity score does not prove equivalence; set acceptance and stop criteria before testing. Retain sanitized examples without copying production data into the evaluation set.

Shadow first, then canary

In shadow mode, calculate candidates but serve only the normal path. For an authorized, sanitized sample, compare results, sources and expected refusals. Record the request ID, hit or miss decision and reason, policy and corpus versions, entry age and latency, without plaintext prompts, answers, secrets or personal identifiers. Restrict trace access and retention.

Before the canary, assign an owner, a low-impact scope, a time window, stop thresholds and enough capacity for the normal path. Enable reads for a small fraction of eligible traffic, keep writes and activation independently controllable, and verify refusals, invalidation and load on misses. Expand only after reviewing false hits and validating answer quality, not on hit rate alone.

Decide and roll back

Cross-scope exposure, a sensitive answer or a stale procedure being served requires immediate suspension of affected reads and writes. Isolate the namespace, preserve sanitized traces, assess recipients and follow the incident process. Invalidate affected entries and verify propagation across instances. Disabling the cache does not retract delivered answers or undo effects: notify affected teams and reconcile any action through the business process.

Return to the normal path only after checking its authorization, capacity and failure behavior. If retrieval or the provider cannot sustain the load, limit traffic or use human review; do not reactivate a suspect cache to hide degradation. Re-enable only after a fix, fresh adversarial tests and explicit owner approval.

References