contextguru plugin: set apply.Opts.CanKeepAlive, so extract_llm_sweep can run (about 4% of baseline at ultrahigh)

Aperta
#2,162 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
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go

Direzione di ricerca

Read the contextguru plugin code that constructs apply.Opts, then compare its fields with proxy/modes.go and the keep-alive checks in components/offload/extract_sweep_ping.go and extract_sweep_warm.go. Set the missing fields using the proxy's rules, and explain any fields Cortex does not need. Done means the sweep can register and reuse answers after a keep-alive ping, with the other relevant options accounted for.

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

Descrizione

Summary

The contextguru plugin does not set apply.Opts.CanKeepAlive. Without it, extract_llm_sweep never registers its question for the keep-alive ping, so it never holds an answer and never drops anything. On the context-guru proxy, the sweep makes almost all of the rewrite saving at ultrahigh (about 4% of baseline). In Cortex it makes $0.

The plugin also leaves other apply.Opts fields unset that the context-guru proxy sets. They are listed below.

Found on Cortex main plus fix/2134-gate-untrusted-savings (499c6ddc), which embeds context-guru v0.7.9.

What we found

The baseline: one laptop on the context-guru proxy

Preset ultrahigh, 2026-11-16 to 2026-11-25, 14,207 requests, context-guru v0.7.7 to v0.7.8, the same litellm gateway:

  • cost $1,101.53 against a baseline of $1,152.49: 4.4% saved by rewriting the context.
Component Requests it acted on Saved (USD)
extract_llm_sweep 5,834 of 12,100 47.91
headttl 576 4.82
extract_llm 1,372 1.39
tooldefer 154 0.98
tailbreakpoint 858 0.42
textclean 5,315 0.37
format 1,798 0.02
extract 1,050 0.01
cache_aware_summarizer 50 0.00
dedup 53 0.00
cachesplit, cmdfilter, toolfilter, toon 0 0.00
expand 11,256 -0.30
adjudicate 11,256 -0.84
searchfold 10,854 -2.84

How the sweep earned it (events of the sweep component):

  • sweep_applied_cold: 160 cold requests applied a held answer. Prompt sizes were 63k to 802k tokens, about 190k on average.
  • reapplied_same_session: 5,883 later requests applied the same drops again. These repeats are most of the $47.91.
The same laptop on Cortex
  • Since 2026-11-25, Cortex logged about 40,000 context-guru compacted request lines. None lists extract_llm_sweep.
  • The summarizer does fire (114 requests since the #2129 fix), so the pipeline and the dispatcher work.
Why
  1. The sweep asks its question at the keep-alive ping, in place of the ping (components/offload/extract_sweep_ping.go). The next cold request applies the held answer. Later requests apply it again.
  2. To be asked at a ping, the request must register a snapshot of the conversation (ExtractSweep.registerPing).
  3. registerPing returns early when c.CanKeepAlive is nil: "No host hook means no keep-alive: keep nothing."
  4. c.CanKeepAlive comes from apply.Opts.CanKeepAlive. The context-guru proxy sets it (proxy/modes.go). The contextguru plugin does not.
  5. The sweep's warm path (extract_sweep_warm.go) checks the same hook.

Proposal

  1. Set apply.Opts.CanKeepAlive. Use the library's rule, as the proxy does: keepalive.CanKeepAlive(policy, ...) for the thread's resolved policy. Do not write a new rule in the plugin.
  2. Set the other fields that the proxy sets and the plugin does not. Check each one, and set it or state why Cortex does not need it:
Field What it does Without it
CompactionPoint, CompactionPointSource where the client's own compaction acts (C) components use the window instead of C
SelfRates, RatesFor the prices a component uses to decide whether its model call pays extract_llm uses default prices
FreePing the time of a free 1-hour ping, by alias the cold check cannot see a free ping
Tracker per-thread cached-prefix boundary, without the read-then-write race the legacy store path
Mode the operating mode sync

How to check the fix

  • After an idle gap, the keep-alive sends the sweep question in place of a ping.
  • A later cold request lists extract_llm_sweep in components=, and the requests after it too.
  • Over a day of the same traffic, Context rewrite on the fleet dashboard rises from about 0.4% toward the proxy's 4%.

Open questions

  • Is the sweep's ping question allowed under Cortex's cost limits per ping? The keeper already caps it (keepalive_max_usd_per_ping).

Technical notes

  • Related: #2130 (threads, fixed by #2129), #2150 (tool deferral: $0.98 in the baseline, so small), #2154 (open-task counts).
  • Baseline data: the proxy's dashboard DB, tables requests and request_components, preset = 'ultrahigh'.
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.