Go to file
caoqianming af2ad3cef1 feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本
排查"rust→PPT"task(flash,34 轮)发现累计 tokens_in 69.9 万里 88.6% 是缓存
命中,但 _fallback_chat_cost_cny 把命中段也按 input 全价算,记账虚高 2-3x。

- capabilities: 加 cache_hit_cny_per_mtoken(deepseek flash 0.1 / pro 0.2;
  0=不区分按全价兜底,绝不少记)
- usage: 成本公式拆三段「命中×缓存价 + (input−命中)×input价 + output×output价」;
  loop 把 cache_hit_tokens + 缓存单价透传进 record_chat_usage
- web: 不加 DB 列。app.py 加 _usage_aggregates(单查询 GROUP BY usage_events,
  复用列表 msg_counts 批量范式,无 N+1)on-the-fly 算每 task 真实成本 + 缓存命中,
  _task_dict 带出;dev.html 列表行显 ¥、顶栏 formatTaskUsage 显「tok·缓存命中%·¥」
- scripts: backfill_chat_cost_cache_discount.py 按 units 已存 token 重算历史
  cost_cny(只改成本列,默认 dry-run,--apply 落库)

折价只对新 chat 事件即时生效;历史走 backfill 脚本(部署后跑)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 08:26:09 +08:00
config feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
core feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
db/migrations Stage C 收尾包:资源 yaml + 磁盘配额 + 网络放开 + 容器内源持久化 2026-05-27 08:35:53 +08:00
deploy fix(deploy): npm 默认源改回腾讯 — npmmirror 访问不稳 2026-06-03 11:00:28 +08:00
prompts/system Reduce chat context token usage 2026-06-04 16:41:14 +08:00
scripts feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
skills feat(ppt): quality_check 加内容形状重叠检测 2026-06-04 15:47:52 +08:00
tests feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
tools Reduce chat context token usage 2026-06-04 16:41:14 +08:00
web feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
.gitattributes Add .gitattributes: force LF for shell + Dockerfile 2026-05-26 10:45:17 +08:00
.gitignore skills+core(命名约定): task 级宪法文件 <date>-<short_id>-<name>.spec.md + spec_lock → spec 简化 2026-05-20 14:03:21 +08:00
CLAUDE.md docs(claude): 加 Shell 语法规约 — 别把 PowerShell here-string 喂给 Bash 工具 2026-06-02 12:28:23 +08:00
DESIGN.md perf(context): 压缩旧 assistant tool_call arguments + keep_recent 20→12 2026-06-05 08:25:56 +08:00
DOCUMENT_SEARCH_API.md feat(skill): documents skill 接内部材料学科知识库(document_search API) 2026-05-21 15:31:21 +08:00
EMBED.md feat(web): embed 模式接受 ?task_id=<uuid> URL 参数自动定位 task 2026-05-22 15:27:19 +08:00
PROGRESS.md feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
RUN.md fix(deploy): npm 默认源改回腾讯 — npmmirror 访问不稳 2026-06-03 11:00:28 +08:00
SCIENTIFIC_SKILLS.md skills: 加 pymatgen / stats_ml / plot_pub(建材院无机材料场景) 2026-05-28 11:33:59 +08:00
SKILL_LIST.md feat(tools): documents/pymatgen secret-bearing 能力改 host-side tools,key 不进 sandbox 2026-06-01 09:35:10 +08:00
alembic.ini core(§7 B Step 1): Storage 基建 — SQLAlchemy ORM + alembic + db CLI 2026-05-14 10:41:44 +08:00
main.py Stage C Step 5: main.py sandbox check + lifespan fs quota WARN 2026-05-26 16:41:16 +08:00
requirements.txt skills: 加 pymatgen / stats_ml / plot_pub(建材院无机材料场景) 2026-05-28 11:33:59 +08:00