Skip to content

fix(runtime): preserve cached prefixes across tool and skill updates - #1355

Merged
vastsa merged 11 commits into
mainfrom
codex/review-pr1325
Oct 3, 2026
Merged

vastsa merged 11 commits into
mainfrom
codex/review-pr1325

Conversation

@vastsa

@vastsa vastsa commented Oct 3, 2026

Copy link
Copy Markdown
Owner

该 PR 取代仍为 draft 的 #1325。保留原 PR 的贡献提交,并在最新 main 上验证;没有改写作者分支。

问题与修复

ToolSearch 激活工具会让部分 Pi 协议在后续请求中增加顶层工具声明,改变历史请求前缀。#1285 的故障真实存在;仅保持 system/Skill 顺序并不能修复它。

本修复按真实传输能力选择工具声明策略:OpenAI/Codex Responses 和已验证支持增量的 Kimi Chat Completions 保留 Pi 原生增量;Claude、普通 Chat Completions、其他 Responses/Codex、Gemini 和兼容中转固定完整工具清单,搜索只改变激活状态;Pi Messages 保留原 transcript 增量传输。

工具声明不授予执行权限。未激活调用在扩展/Host 前被拒绝,激活后仍经过现有模式、审批和 Host 检查。激活状态独立持久化,重启和压缩后可恢复;目录/schema、账户、模型或接口身份变化会建立新状态,删除工具立即撤销执行。固定清单受 128 工具和上下文预算约束;超限回退按需加载,不截断工具,也不承诺此场景前缀稳定。

system/Skill 更新按时间顺序投影;不支持中途 system 更新的接口仍可能因真实 system/Skill 变化失去缓存。首轮固定完整工具目录更大,短会话可能更贵。此前 DeepSeek Flash 对照数据仅来自原 PR 记录的提交和该模型路径,本轮未重复调用付费服务,也不外推到其他服务端。

验证

候选包含当前 origin/main 7f1d7c1ce5f2;PR-base 检查通过。最新 main 集成冲突只涉及 E2E 文档,已保留双方场景。

  • pnpm build:js、pnpm lint、pnpm docs:check、Desktop typecheck 均通过。
  • Agent Runtime:1,233 项通过;相关 Desktop 回归:194 项通过;Host Core:750 项通过;cargo fmt --check 与 cargo clippy --all-targets 通过。
  • node scripts/e2e-fixed-tool-declarations.mjs:4 个 Host/sidecar/HTTP-SSE 场景通过,覆盖声明稳定性、未激活拒绝、重启/压缩恢复及目录变更撤销。
  • node scripts/e2e-system-transcript.mjs:5 个 Host/sidecar/HTTP-SSE 场景通过,覆盖 Skill 更新、执行、重启和压缩。
  • node scripts/e2e-file-ref-line-scroll.mjs:最新 main 的隔离 Electron E2E 通过。

离线适配器和 E2E 验证请求构造、权限与持久化流程,不证明各服务端的实际缓存命中率或费用收益。

Related to #1285

zszz3 and others added 10 commits October 3, 2026 02:04
Persist provider-neutral instruction and tool updates before dispatch so
skill refresh, session restoration, and compaction preserve their order.
Keep execution permissions authoritative and gate native updates on the
original model, API, and endpoint binding.

Related to #1285
Keep Pi's exact transport capabilities independent of models.dev-owned
limits and prices so catalog enrichment cannot silently disable updates.
Normalize compaction checkpoints to the durable journal shape, including
extension-provided text blocks, and cover recovery cleanup boundaries.

Related to #1285
Register the system transcript decision in the ADR index so the
documentation integrity check no longer aborts the workspace test run.
The reminder now travels in a replaceable transcript section so it can
expire after compaction. Update the old source guard and assert that
Pi folds the actual reminder content into the current system state.
Incorporate the current upstream main without rewriting the shared PR.
Move journal entry types to the Desktop-owned projection introduced by
the Pi 1.0 migration, while preserving chronological transcript state.
Declare the verified Flash catalog once per account and schema epoch so
ToolSearch activation does not invalidate the earlier request prefix.
Persist activation independently and reject inactive tools before Host
execution, preserving existing mode and approval restrictions.

Cover HTTP payloads, recovery, compaction, revoked tools and fallback
limits, with paired live Flash measurements documenting the larger cold
request and the short-conversation cost tradeoff.

refs #1285
Preserve the upstream single-bubble recovery lifecycle while removing failed
assistant messages behind chronological system deltas. Cover both message
orders so recovery keeps system state without replaying the failed response.
Include the latest MCP timeout changes in the PR integration candidate so validation and review use the current target branch.
Bring the PR candidate up to date before final validation. Preserve the contributor's branch history and combine the E2E documentation from both sides.
Integrate the latest merged fixes before validating the preserved tool and skill activation change. Retain both the contributor's E2E coverage and the current main scenarios.
Copilot AI balanced review requested due to automatic review settings October 3, 2026 15:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@vastsa
vastsa merged commit 3b036cc into main Oct 3, 2026
4 checks passed
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.

3 participants