contextguru plugin: set apply.Opts.CanKeepAlive, so extract_llm_sweep can run (about 4% of baseline at ultrahigh)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- go
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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 requestlines. None listsextract_llm_sweep. - The summarizer does fire (114 requests since the #2129 fix), so the pipeline and the dispatcher work.
Why
- 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. - To be asked at a ping, the request must register a snapshot of the conversation (
ExtractSweep.registerPing). registerPingreturns early whenc.CanKeepAliveis nil: "No host hook means no keep-alive: keep nothing."c.CanKeepAlivecomes fromapply.Opts.CanKeepAlive. The context-guru proxy sets it (proxy/modes.go). The contextguru plugin does not.- The sweep's warm path (
extract_sweep_warm.go) checks the same hook.
Proposal
- 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. - 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_sweepincomponents=, 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
requestsandrequest_components,preset = 'ultrahigh'.
- 主要语言
- Go
- 星标
- 31
- 派生
- 49
- 平均合并
- 9 小时 43 分钟
- 30 天内合并 PR
- 367
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rossoctl/cortex 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug laptop
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
相似的 Issue
-
taskmanager: a failed v1alpha1 backup leaves the partial backup behind可能已有人在做 @arshil42 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 80/100
ether/etherpad-go#571 ·
维护者通常 1 天内回复
-
labeler: read a limit above math.MaxInt as math.MaxInt in nonNegative (CodeQL alerts #20 and #21)未关闭cost:approved factory:queued factory:tracking priority:p2 rank:12 ready-for-doing task:approved tokens:50k
难度 2/5 1-3 小时 新手友好度 88/100
sisaku-security/sisakulint#860 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100