rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:hongcha-dsh/dsh-cache-keepalive
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
Host-only Harness bundle + a settings-page card. While a user-visible main session is idle, it
replays the last real model request (same provider/model/messages/tools/toolHistory/config, only
maxTokens lowered) through ctx.llm.stream(), so the provider prompt cache stays warm and the
next real turn is billed at the cache-hit price instead of a full re-prefill.
Kimi bills cache hits at 1/10 of the miss price. Measured on this machine (2026-11-11, direct API, 10k-token unique prefixes):
| idle gap (no touch) | kimi-coding (kimi-k3.1-pro) |
huosan |
|---|---|---|
| 10 / 20 / 30 min | 100% cache hit | — |
| 8 min | — | 0% (miss) |
| 45 min | 0% (needs a touch before then) | — |
Replaying with max_tokens: 16 still hits (verified; max_tokens: 1 can fail an "empty
response" check). Cost per touch at a 252k context ≈ ¥0.33; one expired re-prefill ≈ ¥3.28 in
input alone, plus a ¥3.28 5-minute cache write (official billing charges the write too) ≈ ¥6.56
cold. Break-even is therefore up to ~18 touches per idle gap
(C × hit × (20 − k) > 0); the default maxTouches: 8 stays deliberately conservative.
Interval must stay below the measured TTL: 20 min for kimi-coding, 4.5 min for huosan.
On subscription routes that do not discount cache reads (e.g. Ark Agent Plan /api/plan,
whose AFP formula has no cache term), keep-alive saves nothing and only burns quota —
leave those routes out of config.routes.
[● 缓存保活 本窗口开/关]): switches keep-alive for that conversation only.
Each window keeps its own switch; toggling one never changes another. The pill reads/writes
config.sessionEnabled[<sessionId>] through POST /plugins/cache-keepalive/session.keepalive.jsonl (append-only).A cold re-prefill costs the prompt at the input price plus a 5-minute cache write of the same
tokens (official billing counts both); keeping it warm costs one cache read per touch. For one
idle gap with k touches and C prompt tokens:
net = C × hit_price × (R − k) R = (input_price + write_5m_price) / hit_price = 20 for kimi-k3.1-pro
A gap that only produced misses/errors saved nothing and is counted negative. Task rows and the top-line "估算净省" both use this net figure, so the number already has the keepalive spend subtracted. Prices are kimi-k3.1-pro list prices (hit ¥1.3 / input ¥13 / output ¥68 / 5m write ¥13 per MTok).
config.sessionEnabled[<sessionId>] is the authoritative choice for that
conversation; config.enabled is only the default used by a session that never chose explicitly.
A disabled window captures nothing and replays nothing; enabling arms on the next real request.llm/stream request per session and
replays with that request's own provider/model. config.routes: [] means "any route"; fill it to
restrict. Per-route pacing lives in config.routeIntervals (kimi-coding 20 min, huosan 5 min),
falling back to config.intervalMinutes.cacheRead >= 1024 and >= 20% of the prompt). Real hits are
observed from the live stream; replays never self-certify.llm/stream request per session (skips subagent/fork sessions,
requests with a purpose, and its own replays).scanSeconds, for the most recent maxSessions eligible session: when
now - lastRealAt >= interval, replay once, consume the stream fully, drop output.cacheRead === 0 stops that session immediately; also stops at
maxTouches / maxIdleMinutes; one replay in flight at a time.| method + path | purpose |
|---|---|
GET /plugins/cache-keepalive/state |
config, counters, tracked sessions (with their switch), per-task records, and windows (numbers since that window was switched on; only windows that are currently on are listed) |
POST /plugins/cache-keepalive/config |
merge a JSON patch into config.json and apply it (enabled = default) |
POST /plugins/cache-keepalive/session |
{"session":"<id>","enabled":true\|false}: one window's switch |
GET /plugins/cache-keepalive/task?session=<id> |
one task record plus its per-touch detail |
POST /plugins/cache-keepalive/task/delete |
{"session":"<id>"}: forget that task record |
These serve the card. They expose only token counts, task titles and config — never prompt text.
| file | purpose |
|---|---|
config.json |
live config, including the per-window sessionEnabled map; hot-reloaded every 2 s |
keepalive.jsonl |
append-only log: start, capture, keepalive, stop, config, session-switch, record-deleted |
会话 <short id>.keepalive lines from keepalive.jsonl and stops the current idle
gap for that session (it re-arms on the next real request); it does not toggle the keepalive.config.json (hot-reloaded) for routes / routeIntervals.session-switch lines in keepalive.jsonl); a window that inherits the config default without
ever switching explicitly counts from the plugin start instead.session-switch: true line whose session is no longer enabled reports nothing: an epoch only
exists for a window that is currently on (v0.6.1).CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: llm、deepseek-harness。