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

Offen
#2,162 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
go

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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'.
Vorherrschende Sprache
Go
Sterne
31
Forks
49
Ø Merge
9 Std. 43 Min.
Gemergte PRs (30 T.)
367

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus rossoctl/cortex

Alle Issues in rossoctl/cortex

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.