contextguru plugin: set keepalive.Record.PrefixRewritten, so a client compaction does not switch the 1-hour route off

Aperta
#2,163 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend

Direzione di ricerca

Start with core/plugins/contextguru/keepalive.go and recordFor, then trace how the request's thread.Result reaches apply.Opts.ThreadOf. Compare the prefix rewrite rule in proxy/dashcapture.go with keepalive/onehour.go and check existing tests around those paths. Done means a rewritten prefix releases the 1-hour probe without switching the route off, with prefix_rewritten included in the relevant keeper logs.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

The contextguru plugin never sets keepalive.Record.PrefixRewritten. The keeper then counts a cold return after a client compaction or a fork as a failure of the 1-hour cache. On 2026-11-27 this switched the Opus route off for the life of the process. The context-guru proxy proved the same route on the same litellm gateway.

Found on Cortex main plus fix/2134-gate-untrusted-savings (499c6ddc), with context-guru v0.7.9 and cache.strategy: 1-hour-on-wait.

What we found

  • The log shows:
    • 01:18:54: a 1-hour probe starts on the main thread of one session. The 1-hour ping reads 267,251 tokens.
    • 01:35:16: the main thread returns, 16 m 21 s later. It reads 24,073 of 267,251 tokens.
    • 01:35:27: WARN context-guru: no more 1-hour keep-alive pings on this route ... (a silent downgrade).
    • 01:35:28: in the same second, the session sends a request of 55k tokens. The thread before was 122k tokens. That is the shape of a client compaction or a fork.
  • resolveOneHourProbe (keepalive/onehour.go) does not count a return with prefixRewritten true: "A return on another model, or after the client rewrote the prefix (a compaction, a fork), reads cold whatever the cache tier is: it proves nothing about the grant."
  • The context-guru proxy sets the flag from the engine's thread result (proxy/dashcapture.go, prefixRewritten): a compaction verdict, or a thread that inherits from another one.
  • The plugin does not set it (core/plugins/contextguru/keepalive.go, recordFor), so the flag is always false.
  • I cannot prove that the 01:35:16 return was rewritten, because Cortex does not log it. But the proxy proved the same route and model on the same gateway, so a real downgrade is unlikely.

Why it matters

  • After the switch-off, 1-hour-on-wait runs as auto on that route until the next restart.
  • Any client compaction that follows a probe can cause it again.

Proposal

  1. Set Record.PrefixRewritten from the request's thread.Result, the same one #2129 gives to apply.Opts.ThreadOf:
    • a compaction verdict from the thread tracker;
    • a thread that inherits from another one (Result.InheritsFrom()).
  2. Move the proxy's rule into a library function that both hosts call, so the two hosts cannot drift. That is a context-guru change. Today the rule is in proxy/dashcapture.go.
  3. Log prefix_rewritten on the keeper's WARN and INFO lines for 1-hour probes, so a false downgrade can be seen.

How to check the fix

  • A client compaction right after a 1-hour probe gives 1-hour probe released; it proved nothing, not a switch-off.

Technical notes

  • Related: #2154 (open-task counts, false 1-hour probes), rossoctl/context-guru#1514 (keep a proven route across restarts).
Lingua principale
Go
Stelle
31
Fork
49
Merge medio
9h 43m
PR unite (30g)
367

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rossoctl/cortex

Tutte le issue di rossoctl/cortex

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.