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

Abierto
#2,163 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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).
Lenguaje dominante
Go
Estrellas
31
Forks
49
Merge medio
9 h 43 min
PR fusionados (30 d)
367

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rossoctl/cortex

Todos los issues de rossoctl/cortex

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.