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

Ouverte
#2,162 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
go

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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'.
Langage dominant
Go
Étoiles
31
Forks
49
Merge moyen
9 h 43 min
PR mergées (30 j)
367

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de rossoctl/cortex

Toutes les issues de rossoctl/cortex

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.