Skip to content

fix(protocol): fill missing TTL on rewritten official cli-hop - #851

Closed
LemonYangZW wants to merge 1 commit into
dofastted:mainfrom
LemonYangZW:codex/fix-official-cli-hop-cache-ttl
Closed

LemonYangZW wants to merge 1 commit into
dofastted:mainfrom
LemonYangZW:codex/fix-official-cli-hop-cache-ttl

Conversation

@LemonYangZW

@LemonYangZW LemonYangZW commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #850

根因

v1.4.031 中,非透传的官方 Claude Code 流量被强制进入 persona 清洗后,模板生成的 1h marker 与调用方消息上的 marker 会同时存在。调用方 marker 如果没有 ttl,shaped cli-hop 会把它视为已存在的消息断点并原样保留;Anthropic 因此把缺失 ttl 解释为隐式 5m。

cache_continuity.ttl=1h 记录的是请求解析值,不能代表最终 wire 上所有断点都是 1h。

修复

在非透传官方 cli-hop 完成 persona/identity 重写后,仅补齐缺失的 marker TTL:

hopBody = fillMissingCacheTtl(hopBody, requestedCacheTtl)
validateCacheBreakpoints(hopBody)
  • 缺失 TTL 会跟随已解析的全局 1h
  • 调用方显式 5m / 1h 保持不变
  • 仍校验 1h 在 5m 前及最多四个断点的约束
  • official_cc_passthrough=true 时不做改写,继续保留原请求
  • 未使用会覆盖显式值的 applyCacheTtlToBody

测试

通过:

  • node --test test/unit/persona-outbound-contract.test.mjs:116 pass / 0 fail / 74 skip
  • node --test test/unit/official-template-cache-ttl.test.mjs test/unit/cache-ttl.test.mjs test/unit/official-cache-breakpoints.test.mjs test/unit/crs-persona.test.mjs:145 pass / 0 fail
  • npx biome check src/lib/protocol/handle-protocol.mjs test/unit/persona-outbound-contract.test.mjs
  • git diff --check

新增回归覆盖:

  • 缺失 TTL → 1h
  • 显式 5m → 保持 5m
  • 显式 1h → 保持 1h

npm run test:unit 也已在 Windows 工作区执行,但该测试集包含 Unix socket、getgid、Linux 二进制和 POSIX 文件清理等平台假设,出现与本次改动无关的 Windows 平台失败;因此不把 Windows 全量失败作为本修复的通过依据。

验证边界

本次只做代码分析和离线 fixture/单测,没有发起真实推理、缓存、OAuth 或 smoke 请求。

Copy link
Copy Markdown
Owner

关闭:同域 #850 已由 #856 tip-cut 进 v1.4.033(官方 cli-hop 回滚强制 persona + JEV),勿双合本 PR。基线 Latest/TG v1.4.033 @2a4ff238 / mid 33908。

@dofastted dofastted closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] v1.4.031 官方 Claude Code 非透传 cli-hop 将全局 1h 缓存降为隐式 5m

2 participants