zcbot/tests
caoqianming fb214de960 fix(context): 窗口体量估算实测校准——50%压缩/85%折叠/占用环换 token 实测口径(bump 0.58.52)
diag 实测(scripts/diag_context_pressure.py 留仓):折叠机制有效、零撞硬上限,
但静态 CHARS_PER_TOKEN=2.5 对中文密集窗口低估近一倍——名义 85% 折叠线实际
~155% reliable 才触发(task 9a863424 冲到 40.7 万 tokens);代码密集反向虚高
(fe2d8b73 估 1.2M 实际 616k)。

修法是信号校准、不加新机制:
- context.py: estimate_window_tokens(provider 实报 usage 覆盖窗口主体,仅实测
  点后尾巴按 2.5 估)+ calibrated_chars_per_token(比值夹 [1.0,4.0] 带宽)
- session.py: last_measured_usage() 取窗口内最后一条实报 usage 的 assistant 行
  (best-effort 绝不抛;idx→内存 pos 映射校验 role)
- context_fold.py: maybe_fold 触发判定换 token 实测口径
- loop.py: 压缩门槛与 context_limit_chars(前端环)用校准比值,逐轮以
  sent_chars/prompt_tokens 刷新;校准态挪类属性兜默认,任何异常回退 2.5

已知残余:折叠后 run 在首次 chat 完成前崩掉会多折一次(摘要偏保守,原文全在
DB),不为此加持久化状态。run 中途折叠/超限自愈按 §5 无信号不实施继续搁置。

真实生产 task 只读验证映射与校准(drift 0.95x/0.51x/0.86x),286 测试全绿。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 12:49:02 +08:00
..
frontend_task_progress.test.mjs fix(web): 进度条自愈——回放层强制单调完成(d1285247 复盘,bump 0.36.2) 2026-07-03 11:16:34 +08:00
test_broker_redis.py feat(broker): 外置 Redis pub/sub——蓝绿跨实例 SSE/cancel 可达(bump 0.42.0) 2026-07-06 14:51:39 +08:00
test_changelog.py feat(changelog): 用户版更新日志 CHANGELOG.md + /v1/changelog + 点版本号弹层(bump 0.55.0) 2026-07-09 16:49:26 +08:00
test_context_compaction.py fix(context): 窗口体量估算实测校准——50%压缩/85%折叠/占用环换 token 实测口径(bump 0.58.52) 2026-07-21 12:49:02 +08:00
test_context_fold.py fix(context): 窗口体量估算实测校准——50%压缩/85%折叠/占用环换 token 实测口径(bump 0.58.52) 2026-07-21 12:49:02 +08:00
test_disk_quota.py Stage C 收尾包:资源 yaml + 磁盘配额 + 网络放开 + 容器内源持久化 2026-05-27 08:35:53 +08:00
test_executor_docker.py fix(run_python): 超时返回超时前的部分输出 + 无缓冲(-u),模型据此续跑不整批重来(bump 0.58.36) 2026-07-17 10:53:14 +08:00
test_load_skill.py feat(skills): 用户私有 skill(.skills)+ 创作工具 + skill-creator + Web 查看页 2026-06-11 09:46:39 +08:00
test_loop_empty_response.py fix(llm,loop): glm.pro52 空响应治本——禁 thinking 免推理烧穿输出上限 + loop 区分截断(bump 0.58.49) 2026-07-21 08:16:54 +08:00
test_loop_malformed_retry.py feat(loop): 空响应防御——provider 吐空自动重试 + warn 自停不静默 done + 面板留痕(bump 0.58.32) 2026-07-15 15:29:49 +08:00
test_loop_repeat_guard.py fix(loop): 堵失败聚集两裂缝——必填key被吞畸形走非流式重试 + RepeatGuard连续同错streak拦(bump 0.58.33) 2026-07-17 08:22:42 +08:00
test_pptx_guard.py fix(guard): ppt 伪导出根治三层——平台机检门 + 禁令去菜谱 + 脚本 hint 纪律(bump 0.40.0) 2026-07-06 13:40:54 +08:00
test_pptx_render.py feat(preview): pptx 在线预览 —— LibreOffice→PDF + 复用 PDF iframe(DESIGN §8.3 Stage 1) 2026-06-09 13:04:02 +08:00
test_pysyntax.py feat(run_python): 宿主语法预检——中文正文硬拼进源码的语法坏码提前拦下+锐化诊断(bump 0.58.34) 2026-07-17 08:55:55 +08:00
test_rendering.py feat(rendering): 通用报告走平台渲染器 report profile + 基座引导,少让模型手撸 python-docx(bump 0.58.35) 2026-07-17 09:32:02 +08:00
test_run_python_script_path.py fix(exec): run_python script_path 宿主预检+前缀容错+code 落盘回退(bump 0.58.22) 2026-07-13 16:41:43 +08:00
test_salvage.py feat(loop): 畸形 tool_call arguments 就地抢救(salvage)省一次非流式重试(bump 0.58.24) 2026-07-15 09:20:38 +08:00
test_sandbox_check.py Stage C Step 5: main.py sandbox check + lifespan fs quota WARN 2026-05-26 16:41:16 +08:00
test_secret_host_tools.py feat(mp): mp_search_summary 批量入参 formulas[] 定点解检索烧 token(bump 0.58.28) 2026-07-15 10:49:35 +08:00
test_shortcuts.py feat(shortcuts): 加快捷指令(触发词→完整指令,入口层确定性展开)(bump 0.35.0) 2026-07-01 14:58:55 +08:00
test_skill_model_pinning.py feat(skill): skill 定向模型——ppt 触发自动热切 GLM-5.2(bump 0.39.0) 2026-07-06 08:57:32 +08:00
test_static_vendor.py Disable static asset caching 2026-06-08 09:16:31 +08:00
test_svg_alignment_check.py fix(ppt,tools): svg 质量门末尾出 [GATE FAIL] 汇总行——失败签名从误标"Font issues"变诚实(bump 0.58.47) 2026-07-20 15:59:09 +08:00
test_system_prompt_paths.py test(prompt): 锁住 docker 下 system prompt 不漏宿主路径(药3 复核收口) 2026-06-09 11:30:32 +08:00
test_task_progress_tool.py Add task progress tool 2026-06-08 08:44:16 +08:00
test_timeout_partial.py fix(run_python): 超时返回超时前的部分输出 + 无缓冲(-u),模型据此续跑不整批重来(bump 0.58.36) 2026-07-17 10:53:14 +08:00
test_tool_output_compaction.py Reduce chat context token usage 2026-06-04 16:41:14 +08:00
test_toolfail_malformed.py feat(loop): 空响应防御——provider 吐空自动重试 + warn 自停不静默 done + 面板留痕(bump 0.58.32) 2026-07-15 15:29:49 +08:00
test_usage_accounting.py feat(usage): 记账给前缀缓存命中折价 + 前端体现缓存命中/真实成本 2026-06-05 08:26:09 +08:00
test_user_skills.py feat(skills): 用户私有 skill(.skills)+ 创作工具 + skill-creator + Web 查看页 2026-06-11 09:46:39 +08:00