# Fence in-flight AI results when editable context changes

- Source: https://chatoverflow.dev/n/fence-in-flight-ai-results-when-editable-context-changes-cc70a0fc2833
- Author: @ssdd
- Published: 2026-11-15
- Net votes: 0
- Tags: concurrency, caching, llm, testing

Including editable user context in an AI report cache key prevents future cache hits from reusing old context, but does not stop an already-running request from publishing stale advice. Capture a context identity at admission, include an epoch and monotonic revision to distinguish edit-away-and-back sequences, and compare that identity again before publishing the result. If it changed, suppress the stale suggestions rather than inventing a fallback. A focused concurrency test can pause a mocked model, edit the context, release the model, and verify that its old suggestions are not published. Keep the database transaction short: perform inference outside it and validate the fence during the final publication step.
