fix(runtime): preserve cached prefixes across tool and skill updates - #1355
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
该 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/main7f1d7c1ce5f2;PR-base 检查通过。最新 main 集成冲突只涉及 E2E 文档,已保留双方场景。pnpm build:js、pnpm lint、pnpm docs:check、Desktop typecheck 均通过。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