Skip to content

fix(protocol): cli-hop 出站统一收成官方两段样板 - #641

Merged
dofastted merged 12 commits into
mainfrom
fix/official-cli-template
Oct 20, 2026
Merged

dofastted merged 12 commits into
mainfrom
fix/official-cli-template

Conversation

@dofastted

@dofastted dofastted commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

摘要

  • 所有 cli-hop 请求在前置收成官方两段 system:身份句加调用方正文,标记为 {type: ephemeral},不写 TTL。
  • 缓存标记打在最新一条用户消息;尾随 role=system 保持字符串。
  • 出站去掉 eager_input_streaming、工具 cache_control、temperature 和 context_management。thinking display 默认 summarized。

测试

  • node --test test/unit/cli-hop-body.test.mjs test/unit/eager-tool-streaming.test.mjs
  • 带 1h/5m 工具标记的请求跑过 CLI 最终组包,system 和消息标记保持省略。

Note

Medium Risk
Changes outbound request shaping, cache markers, and tool/thinking fields on the cli-hop path, which can affect upstream acceptance, prompt caching continuity, and streaming behavior for official Claude Code traffic.

Overview
cli-hop outbound requests are normalized to match captured Claude Code wire shape instead of re-stamping persona/cache with configurable TTLs.

Every cli-hop body is rebuilt with a two-block system (official CLI identity plus caller text), both using { type: 'ephemeral' } without ttl, and a single ephemeral marker on the latest user message tail. Caller markers elsewhere are cleared; temperature / top_p / top_k / context_management are dropped; tools lose eager_input_streaming and cache_control. Thinking display follows routing and defaults to summarized when unset.

Official inbound traffic gets preserve_content_shape through conversion/sanitize so string role=system turns and block layout stay closer to the client. eager_tool_streaming is opt-in (failover.eager_tool_streaming === true) rather than on by default. Cache stamping supports TTL-less ephemeral markers when appropriate.

The cli-hop path in handle-protocol no longer runs the extra persona rewrite panel path (panelRewrite is false); tests were updated for the new templates and defaults.

Reviewed by Cursor Bugbot for commit 75c3635. Configure here.

@dofastted dofastted left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

发版侧结论:要改(不合)

无法对本人 PR 点 REQUEST_CHANGES,以评论代替。

阻塞

  1. formatCacheBreak 未实现:本 PR 在 handle-protocol.mjs 新增 import { …, formatCacheBreak } 并调用,但 cache-prefix.mjs 没有该 export。unit 全挂:SyntaxError: The requested module './cache-prefix.mjs' does not provide an export named 'formatCacheBreak'(gateway failed to start)。请补 export,或改回 tip 上的内联 where。
  2. CHANGELOG「未发布」缺 #641:当前仅有 #639 行。

次要

  • outbound-attempt.mjs 仍 import 未使用的 promoteContentToBlocks。

发版建议(修好+五职绿后)

本 PR 会改线上 cli-hop 出站样板 / 缓存 / eager / thinking 默认,按常规则 须主聊单独拍板。拍板通过后建议 merge-no-tip→203,勿 tip-cut 单发。Latest/TG 仍 v1.3.202 / 24107。

cursor Bot pushed a commit that referenced this pull request Oct 20, 2026
- Add formatCacheBreak to cache-prefix.mjs for handle-protocol logging
- Document PR #641 under 未发布 in CHANGELOG
- Remove unused promoteContentToBlocks import from outbound-attempt

Co-authored-by: ted <kuhlmangarry24@gmail.com>
cursor Bot pushed a commit that referenced this pull request Oct 20, 2026
- crs-persona: billing + identity_cli + reporting + agent + continuation (+ leftover)
- official_full vs overwrite harness expectations split by mode
- web persona-template preview ids include reporting and dynamic_boundary

Co-authored-by: ted <kuhlmangarry24@gmail.com>
cursor Bot pushed a commit that referenced this pull request Oct 20, 2026
#641 strips invalid caller cache_control and restamps the last user text;
thinking/redacted-only turns leave no message markers after strip.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
cursor Bot pushed a commit that referenced this pull request Oct 20, 2026
- Add formatCacheBreak to cache-prefix.mjs for handle-protocol logging
- Document PR #641 under 未发布 in CHANGELOG
- Remove unused promoteContentToBlocks import from outbound-attempt

Co-authored-by: ted <kuhlmangarry24@gmail.com>
cursor Bot pushed a commit that referenced this pull request Oct 20, 2026
- crs-persona: billing + identity_cli + reporting + agent + continuation (+ leftover)
- official_full vs overwrite harness expectations split by mode
- web persona-template preview ids include reporting and dynamic_boundary

Co-authored-by: ted <kuhlmangarry24@gmail.com>
cursor Bot pushed a commit that referenced this pull request Oct 20, 2026
#641 strips invalid caller cache_control and restamps the last user text;
thinking/redacted-only turns leave no message markers after strip.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
@cursor
cursor Bot force-pushed the fix/official-cli-template branch from 916be28 to 7dc2da0 Compare October 20, 2026 22:10
dofastted and others added 10 commits October 20, 2026 22:21
所有请求在前置收成身份句加调用方正文,标记不写 TTL,并去掉 eager、工具缓存标记、temperature 和 context_management。缓存标记跟到最新用户消息,尾随 role=system 保持字符串。
- Add formatCacheBreak to cache-prefix.mjs for handle-protocol logging
- Document PR #641 under 未发布 in CHANGELOG
- Remove unused promoteContentToBlocks import from outbound-attempt

Co-authored-by: ted <kuhlmangarry24@gmail.com>
没有粘性绑定时不再用每次请求的时间戳重算出站 session。入站 device id 在剥离前写入日志,并在详情页显示。
preserveSystem 已无调用方。非法缓存标记收成官方样板,不再返回 400。
Co-authored-by: ted <kuhlmangarry24@gmail.com>
- crs-persona: billing + identity_cli + reporting + agent + continuation (+ leftover)
- official_full vs overwrite harness expectations split by mode
- web persona-template preview ids include reporting and dynamic_boundary

Co-authored-by: ted <kuhlmangarry24@gmail.com>
#641 strips invalid caller cache_control and restamps the last user text;
thinking/redacted-only turns leave no message markers after strip.

Co-authored-by: ted <kuhlmangarry24@gmail.com>
Co-authored-by: ted <kuhlmangarry24@gmail.com>
第一处在 system,最后一条 user 只带 ephemeral,不再要求 ttl。
@cursor
cursor Bot force-pushed the fix/official-cli-template branch from db10bba to 1ed89d2 Compare October 20, 2026 22:21
@dofastted
dofastted merged commit 79b76fb into main Oct 20, 2026
7 checks passed
dofastted added a commit that referenced this pull request Oct 20, 2026
云端 #641 在这些提交之后合入。重放时保留本地最终形态,只留下入站 device 日志。
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.

2 participants