Repository navigation
Open
Labels
enhancementNew feature or request
Description
一句话结论
OpenPI Footer 当前显示整条 branch 的累计 cache 百分比;这个数字能看效率,却很难回答“哪一次模型/工具/system/context 变化打断了已经工作的 prefix cache”。
OMP 已实现一个很窄的 warm → cold detector。建议先在 OpenPI 做 provider-aware 的逐 turn 诊断研究,验证误报率后再决定是否提供 opt-in marker;不要把所有 cacheRead=0 都叫 cache miss。
固定证据
对比固定在:
- OpenPI
main@2a69d3f32994da4123f1312b7fa84ef3d6119be1 - OMP
main@7623b960540518bb1291808bbae28332065e9dba
OMP 当前:
- 只有上一轮实际读回至少 2048 cache tokens、当前轮
cacheRead=0、并且显式 prefix cache 发生 rewrite 时才判定 invalidation:detector contract - 它刻意排除首轮、tiny context、连续冷轮,以及 OpenAI/Google 等 implicit best-effort cache 的传播噪声,避免制造假结论:provider boundary
- marker 默认关闭:setting
OpenPI 当前:
model-info遍历 active branch,把cacheRead / (input + cacheRead + cacheWrite)聚合成一个百分比:aggregate metric- Footer 只渲染
cache N%,没有 turn boundary 或突变信息:footer projection
为什么值得讨论
OpenPI 的核心优势之一是 ordinary turn 的静态面小、工具渐进披露。要持续证明这个优势,需要能定位真实 cache 回退发生在哪个 turn,而不是只看 Session 结束后的平均数。
这可以帮助验证:
- capability group 加载是否导致 prefix 重写;
- tool schema / prompt 文案变动是否破坏 cache;
- compaction、branch move、model/thinking change 的成本;
- 某次 cache 降低是可控 invalidation,还是 provider 的正常 best-effort 波动;
- OpenPI 与 Bare Pi / OMP benchmark 的静态税和动态税分别来自哪里。
OpenPI 应保留的优势
- 这是 operator-facing 诊断,不向模型注入纠偏策略;
- 默认关闭,不增加普通 transcript 噪声;
- 只解释 Pi 已提供的 authoritative usage,不发明 provider 账单事实;
- provider 语义不清楚时显示 unknown,而不是推断“用户导致 miss”;
- 不把 cache 优化变成硬编码 workflow。
建议研究形态
先实现纯函数 + trace report,不急着做 UI:
- 定义上一轮 warm、当前轮 cold、reprocessed tokens 的最小条件;
- 按 provider/cache 类型区分 explicit prefix cache 与 implicit best-effort cache;
- 对 model、thinking、active tools、compaction/branch change 记录可选的本地原因标签,但只能标作 correlation,不能冒充 provider 因果;
- 用真实 Session usage 回放测试误报/漏报;
- 只有结果可信,再加 opt-in transcript marker 或
/model-info明细。
非目标
- 不保证 provider cache 一定命中;
- 不把
cacheRead=0一律当异常; - 不自动切模型、改 thinking 或阻止工具加载;
- 不把 OpenPI 变成 provider adapter;
- 不默认显示每轮 token 详情。
完成条件
- 列出 Pi usage 字段在各 provider 上可支持的结论和 unknown 边界
- detector 覆盖 first turn、warm→cold、cold→cold、partial hit、TTL expiry、compaction、model/tool change
- implicit cache provider 不因普通传播噪声产生高频假 marker
- 输出明确区分 observation、correlation 与 verified cause
- 用至少一组 OpenPI/Bare Pi/OMP trace 验证 detector
- 若加 UI,默认关闭且不改变 Session/model context
- 保留现有累计 cache% 作为趋势指标,不用单次 marker 取代它
与现有 Issue 的关系
- 研究 OMP:模型能力 × Harness 脚手架强度的收益曲线 #45:要求区分 OMP 静态税、动态税与机制触发
- 工具 Schema 不是越短越好:Codex、Maka、OMP 的角色披露、缓存稳定与有界设计 #84:关注 tool schema 的角色披露、缓存稳定和有界设计
- 本 Issue:建立可定位到 turn 的 cache observability,给 研究 OMP:模型能力 × Harness 脚手架强度的收益曲线 #45/工具 Schema 不是越短越好:Codex、Maka、OMP 的角色披露、缓存稳定与有界设计 #84 提供证据层
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
627150795 commentedon Aug 28, 2026
I am taking this issue for a focused first pass: document the provider-aware per-turn cache diagnostic contract and evidence boundaries, without changing runtime behavior or treating every cacheRead=0 as an invalidation. I will report the scope and validation in a follow-up.
627150795 commentedon Aug 28, 2026
Update: the focused design pass is available in PR #256: https://github.com/tt-a1i/openpi/pull/256\n\nIt defines provider-aware per-turn observations, conservative warm-to-cold evidence rules, unknown handling, replay coverage, and the boundary for a future opt-in detector. Validation passed: git diff --check, bun run lint, bun run typecheck. This PR is intentionally docs-only and does not claim runtime observability is implemented.
tt-a1i commentedon Aug 30, 2026
相关设计讨论已展开:Tool lifecycle across compaction #311。#311 定义动态工具跨越 compaction/recovery 的状态边界;本 Issue 继续负责逐 turn 记录 compaction boundary、tool-surface fingerprint、重新物化与 cache read/write 证据。
testikun commentedon Sep 4, 2026
我来认领 #156 尚未落地的运行时代码阶段,不重复此前的 provider-aware 设计文档。
技术方案:实现无副作用的逐 turn cache observation/detector,并从 Pi authoritative usage 构建有界 trace report;first turn、warm→cold、cold→cold、partial hit、TTL/implicit-cache unknown、compaction/model/thinking/tool-surface correlation 会有独立判定。输出严格区分 observation、correlation 与 verified cause,不把
cacheRead=0自动称为失效,也不改变现有累计 cache% 或模型上下文。实现已提交:PR #372。
验证:
bun run check通过;完整bun run test为 Node 1248 passed / 1 skipped、Vitest 30 passed;Node 22.19 定向测试 11/11 通过。实现不修改 UI,因此不适用真实 UI 截图要求。tt-a1i commentedon Sep 8, 2026
本轮社区调研补一项可学的统计口径与展示:
pi-cache-graph明确区分 active branch 和 whole session tree,逐 entry 保留 provider/model/timestamp,让 rewind/切分支后已经发生的调用成本仍可检查。session-data.ts@40c5ae46。这不是“OpenPI 还没有逐 turn 诊断”。当前
ed9dbc1已有 cache-diagnostics tracker,并明确区分 observation/correlation/unknown。可在现有 tracker 上补有界时间线及导出,明确显示 branch、tree 等口径。不能照搬社区包的计算:它仅计 assistant message,OpenPI 现有 session-metrics 已包含 toolResult、compaction、branch_summary 的 usage。新增展示要保留这些事实;whole tree 也不等于所有 child/runtime/account 的完整账单。
这是源码学习建议,未做运行或成本实验。界面应始终说明口径,不因为切换视图造成“费用被清零”的误解,也不从 cache 曲线推断 provider 的确定因果。
研究记录:Pi 社区能力研究与候选清单(2026-09-08)。源码证据、运行验证与采用决策分别记录。
tt-a1i commentedon Sep 9, 2026
2026-09-09 源码对照(未安装、未运行、未
pi install)。强制两棵树:a9b40f0044ee59c360a6077c1c0bdbdbd30da10b(package 0.4.0)没有extensions/model-info/cache-diagnostics.ts。model-info/只有内联getSessionMetrics():沿getBranch()累加cacheRead / (input+cacheRead+cacheWrite),经dashboard:model-info进 Footer 的cache N%(extensions/model-info/index.tsL14–38;footer.tsL190–196)。ed9dbc1018f890fd54375f5371990ddfee8af5df与origin/main0d17f4577fe31315fe6c95370d251bdb4e2413cf(0.8.1)上该文件是同一 blob16648517(220 行)。引入提交是 PR feat(model-info): add per-turn cache diagnostics #372 merge24d740762038b08bd18e0de5e788bb458d6bf5c5(2026-09-05)。24d7407不在本HEAD,在 origin。因此 2026-09-08 评论「这不是 OpenPI 还没有逐 turn 诊断」对 origin 为真,对 本 checkout 为假——和 checkout-vs-tracker 漂移同类。不要把本树的「没有文件」焊成「OpenPI 没有 diagnostics」,也不要把 #372 MERGED 焊成本
HEAD已含修复。新研究记录(本地 draft,未 commit):
docs/research/EXPERIMENT_CACHE_INVALIDATION_156_2026-09-09.md。覆盖猎取见docs/research/EXPERIMENT_UNCOVERED_TRACKERS_2026-09-09.md。两份都还只在写出它们的工作区,不在a9b40f0blob 上。源码对照后的合同差(不是运行收据):
cache N%。 origin 的 diagnostics 走model-info:cache-diagnostics事件总线;生产 UI 没有消费者。PR feat(model-info): add per-turn cache diagnostics #372 自己写:no marker, no model-visible change, Does not close this Issue。7623b960要求本轮cacheWrite > 0(显式 prefix rewrite)。origin OpenPI 用 provider 名把 只有anthropic标成explicit-prefix,不要求cacheWrite,reprocessedTokens = current.input。Pi 0.85.16160683的cache-stats.ts用min(prev.prompt, current.prompt) − cacheRead,compaction 后 重置基线,showCacheMissNotices默认 false,UI 还有 20k /$0.1门槛。本工作区node_modules仍是 Pi 0.84.1,没有cache-stats.ts。pi-ai(归一化Usage);Session JSONL 归 PiSessionManager;tool result 是 JSONL 里的 message,不是第二份 KV。不要 Adoptpi-cache-optimizer/pi-cache-graph/oh-my-pi-plugin-cache-miss,不要新开/cache或 Marketplace / Memory 产品。docs(cache): clarify prompt-cache ownership, identity, accounting, and lifecycle boundaries #191 继续只做所有权文档。#311 只评论,不另写实验文件。#74 / #75 / #90 不在本帖范围。
ooiuuii commentedon Sep 11, 2026
I would like to contribute a narrow provider usage field matrix + synthetic replay regression evidence slice following the latest maintainer clarification.
The diagnostic implementation from #372 already exists on current
main@5bf2fe29e52801d79826c2eb573be403f53285e5; I will not recreate it, change provider classification/arithmetic, or add a/cachecommand/marker. The contribution will freeze the actual Pi 0.85.1 source identity, document normalized usage and unknown boundaries, and exercise the existing tracker/extension with explicitly synthetic multi-turn fixtures.This is not a claim of real provider billing accuracy or a live OpenPI/Bare Pi/OMP comparison. Synthetic fixture replay cannot satisfy the outstanding genuine comparative-trace requirement, and TTL will not be presented as a verified cause without supporting evidence. The PR will use
Refs #156, leave those remaining gates open, and separate source verification, deterministic tests, and unperformed live experiments.