zcbot/core
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
..
sandbox sandbox: host 侧 resolv.conf bind mount 覆盖容器 ro 2026-05-27 12:21:05 +08:00
storage feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
__init__.py Initial import: zcbot personal task agent 2026-05-06 11:02:59 +08:00
agent_builder.py fix(sandbox): docker 下 system prompt / SKILL 文档统一用容器路径 2026-06-03 16:33:59 +08:00
ark_client.py feat(media): 接入豆包 Seedream 5.0 图像生成 tool + 0007 cost_usd→cost_cny 全表统一币种 2026-05-20 15:20:34 +08:00
bocha_client.py Add web_search and web_fetch tools via Bocha AI search API 2026-05-25 11:37:33 +08:00
capabilities.py feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
context.py perf(context): 压缩旧 assistant tool_call arguments + keep_recent 20→12 2026-06-05 08:25:56 +08:00
executor.py Stage C Step 1: Executor 接口骨架 + HostExecutor in-process backend 2026-05-26 10:07:55 +08:00
executor_docker.py Reduce chat context token usage 2026-06-04 16:41:14 +08:00
executor_host.py Stage C Step 1: Executor 接口骨架 + HostExecutor in-process backend 2026-05-26 10:07:55 +08:00
export_docx.py core(0003): name + working_dir + skill schema 重构 + per-user .memory 2026-05-17 19:15:37 +08:00
llm.py fix(usage): 顶栏 token 累计修 — sync_task_tokens 改走 messages SUM,删 LLM.TokenCounter 2026-05-21 13:39:57 +08:00
loop.py feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
memory.py auth(dev SPA): 邀请码登录(invites 表 0005) + SENTINEL user 彻底撤 2026-05-19 13:14:31 +08:00
paths.py refactor(paths): 砍 ROOT 外路径分支 — 写入入口只接 simple name join workspace 2026-05-20 22:05:32 +08:00
probe.py Phase 4 + 6: capability probe + task 概念 / state.json 2026-05-06 16:21:17 +08:00
session.py skills+core(命名约定): task 级宪法文件 <date>-<short_id>-<name>.spec.md + spec_lock → spec 简化 2026-05-20 14:03:21 +08:00
sinks.py fix(usage): 顶栏 token 累计修 — sync_task_tokens 改走 messages SUM,删 LLM.TokenCounter 2026-05-21 13:39:57 +08:00
skills.py Initial import: zcbot personal task agent 2026-05-06 11:02:59 +08:00
task.py feat(media): 接入豆包 Seedream 5.0 图像生成 tool + 0007 cost_usd→cost_cny 全表统一币种 2026-05-20 15:20:34 +08:00
ui.py core/ui: 抽出语义化 console 主题, 调用方去硬编码颜色 2026-05-07 16:10:11 +08:00