FreshGauge: a freshness control plane inside the LLM gateway A developer built FreshGauge, a plugin for the Bifrost LLM gateway that extracts factual claims from model completions, verifies them against live web evidence via Tavily, and scores them by authority-weighted recency. The plugin runs in three modes — shadow (post-answer logging), correct (appending dated corrections inside the PostLLMHook at zero Tavily credits by reading a SQLite ledger), and brief (pre-empting stale answers in HTTPTransportPreHook with one search) — exploiting the asymmetry that detection needs the web but enforcement only needs memory of prior detections. Admin routes inherit Bifrost's virtual-key auth because HTTPTransportPreHook runs after gateway authentication. Every LLM answer is a snapshot of the model's training data. Ask for a price, a current model name, a CEO, or a fine cap and you get something that was true — stated with exactly the same confidence as something that still is. Retrieval doesn't fix this on its own: RAG grounds an answer in documents, but nobody checks whether the document the answer leans on is two years old. FreshGauge is a Bifrost gateway plugin that does that check on the way out. Every completion that passes through the gateway gets its factual claims extracted, verified against live web evidence, scored by authority-weighted recency , and then acted on — logged, corrected in flight, or pre-empted with a dated brief before the model is even called. This is a write-up of how it's built, the decisions that mattered, and the traps that cost real debugging time. You could build this as a wrapper around one SDK. It breaks the moment a team uses three providers, streams tokens, or fails over between models. A gateway sees all of that by construction: one process, one config, every request. Bifrost's plugin ABI gives exactly the hooks needed: PostLLMHook — the response, after the provider call. Where the audit is born. HTTPTransportPreHook — every HTTP request to the gateway. Where the audit API lives. Because HTTPTransportPreHook runs after Bifrost's auth, the plugin's admin routes inherit virtual-key auth for free. There is no second auth system to get wrong. ┌──────────────────────────────────────────────┐ client ──POST─────────▶│ Bifrost gateway :8080 │ /v1/chat/completions │ │ │ HTTPTransportPreHook ──▶ /audit, /stats, … │ │ │ auth'd by VK │ │ ▼ │ │ provider call OpenAI / Anthropic / X / … │ │ │ │ │ PostLLMHook │ └────────┬─────────────────────────────────────┘ │ 1. extract claims ≤8 │ 2. correct in flight? ◀── ledger read 0 credits │ 3. dedupe by request/content ▼ ┌──────────────────────┐ │ auditor 2 workers │ │ per claim: │ │ Tavily search ────┼──▶ api.tavily.com 1–2 credits │ fetch + quote │ │ stance: +1 / −1 / 0│ │ vote = auth·e^ −age/τ └──────────┬───────────┘ ▼ ┌──────────────────────┐ │ SQLite ledger │ │ audits · claims · │ │ evidence · metrics │ └──────────┬───────────┘ ▼ GET /audit/{id}.html flat paper report GET /stats corrections, grounded Three modes sit on one engine: | Mode | When | Cost | What the user sees | |---|---|---|---| | shadow | after the answer | Tavily credits | nothing; the ledger only | | correct | inside PostLLMHook | 0 credits ledger read | dated correction block appended | | brief | in HTTPTransportPreHook | 1 Tavily search | answer born current | The cost asymmetry is the point. Detection needs the web. Enforcement does not — it needs the memory of what was already detected. The extractor pulls sentences that make checkable assertions about the world and classifies them: const Pricing Category = "pricing" APIVersion Category = "api version" Leadership Category = "leadership" Regulation Category = "regulation" Limits Category = "limits" Categories are not cosmetic. Each one carries a confidence half-life, τ, that decides how fast evidence decays: func Tau c extract.Category float64 { switch c { case extract.Pricing: // A five-week-old vendor price page is still current. At tau=30 a 39-day-old // page scores 0.27 and fails MinVote, which reports a plainly stale price as // UNVERIFIABLE — abstention where the evidence is good enough to decide is a // worse error than a slightly generous half-life. return 120 case extract.Limits: return 180 case extract.APIVersion: return 90 case extract.Leadership: return 365 case extract.Regulation: return 730 } return 180 } A statute moving on a decade timescale and a price sheet moving on a quarterly one cannot share a decay constant. That table is the whole domain model, and it is the difference between a detector that argues and one that abstains. Most "is this stale?" implementations count sources. Counting is wrong: ten 2023 blog posts should not outvote one vendor pricing page published last month. So each piece of evidence casts a weighted vote: // Recency decays from 1.0 at the publish/fetch date to ~0.37 one tau later. func Recency e Evidence, cat extract.Category, now time.Time float64 { date := e.Published if date.IsZero { date = e.Fetched } if date.IsZero || date.After now { return 1 } ageDays := now.Sub date .Hours / 24 return math.Exp -ageDays / Tau cat } // Vote is the authority-weighted recency used for every decision. func Vote e Evidence, cat extract.Category, now time.Time float64 { if e.Stance == 0 { return 0 } return clamp01 e.Authority Recency e, cat, now } Decisions follow from that single scale: bestCon = MinVote 0.35 bestCon = bestSup → CONTRADICTED bestSup = MinVote → SUPPORTED And the freshness score is not a vibe — it's recomputable by hand from the ledger: f := 100 1 - math.Min 1, bestCon For the recorded demo: the vendor page acme.com/pricing , authority 1.0, published 2026-10-02 says $35 and contradicts; a 2024 Medium post authority 0.4 supports the old $20. The contradiction's vote wins by an order of magnitude, and the score is 28/100 — recent enough to be decisive , old enough that the claim it contradicts is plainly stale. The first live run against anthropic.com flagged $2 / million input tokens as CONTRADICTED . The page did say $15 / million input tokens — for a different model , in a multi-model table. Naive comparison of "a number appeared near the claim" turns every pricing table into a contradiction factory. The fix gates comparison on three cheap invariants before any number is compared: subjectOverlap , sameSubject . Claude Sonnet 5 ≠ Claude Sonnet 4 . per million input tokens ≠ per million output tokens ≠ per month priceKind , taggedPrices . And the scan is line-first: candidate evidence is the single line containing the number, not the whole page. After the fix, the same page and the same single Tavily search produce $15/M input → CONTRADICTED and $2/M input → SUPPORTED. There's a regression test for exactly that pair. response mode: "correct" rewrites the answer before the caller sees it. The correction is drawn entirely from the ledger — the plugin's own memory of contradictions it has already established — so it costs zero Tavily credits. claims := extract.Claims text, p.cfg.MaxClaims // In-flight correction runs before the audit is enqueued, and only ever reads the local // ledger. Order matters: the audit below must never see its own correction block as a // new claim, or every corrected answer would spawn fresh work for text the plugin wrote // itself. if streaming && p.cfg.ResponseMode == "correct" { p.correctInFlight resp.ChatResponse, claims } Two details earn their comments: stripCorrection . Otherwise the block the plugin appended becomes a claim on the next audit and the plugin audits itself forever. normalizeClaim collapses punctuation and casing so the same fact expressed twice hits the same row; priors are capped by correction max age hours 24h default so a correction never cites evidence the operator considers expired. The output is appended under a fixed marker, three lines max by default: --- Freshness check FreshGauge . - Correction: "Acme Pro costs $20 per month" is stale. https://acme.com/pricing says "Pro — $35 per user / month" authority 1.00, published 2026-10-02 . /stats exposes corrections and grounded requests next to audit totals, so "the gateway changed answers" is a measurable event rather than a claim in a README. grounding mode: "brief" runs in HTTPTransportPreHook , only for freshness-sensitive questions looksFreshnessSensitive , inside a time box grounding timeout ms , and injects a short block of dated evidence into the request: Current evidence verified 2026-11-21 : - acme.com/pricing 2026-10-02 : "Pro — $35 per user / month" The model answers from that instead of from its weights. One search, opt-in, and it shows up on /stats as grounded requests . Stream chunks carry a Delta , not a Message . Reaching for Choices 0 .Message dereferences a nil embedded pointer — inside a hook, that surfaces as a recovered panic in the host log and a silently missing audit, which is the worst failure mode: it looks like it works. The hook detects the stream case and assembles deltas per request: switch { case c0.ChatNonStreamResponseChoice = nil: text = stripCorrection messageText resp.ChatResponse case c0.ChatStreamResponseChoice = nil: streaming = true text = p.streamText ctx, c0 // buffers deltas until finish reason } Streams are audited once, at finish, and never mutated — there is no message object to amend, so correct is non-streaming by design. Buffers are reaped on completion, and there's a test that feeds a synthetic SSE sequence through the hook to keep it that way. Deduplication also needs care: the host does not always put a request ID on the context, so the fallback is content-