A series start with an unchanged prompt keeps the surviving system node
系列开始时未变化的提示词保留存活系统节点
A surface replacement can invalidate only a later portion of conversation history. Moving unchanged system instructions back to node 0 at that request-series start invalidates the provider prefix from the beginning without changing those instructions.
English
Problem
A surface replacement can invalidate only a later portion of conversation history. Moving unchanged system instructions back to node 0 at that request-series start invalidates the provider prefix from the beginning without changing those instructions.
Decision
Keep unchanged admitted system nodes in place when a new request series starts. The system-prompt service compares canonical committed section text independently of request-series markers. Replacing unrelated user or tool content does not require rebuilding instructions. Compaction is a separate trigger for deferred rebuilding from current sources, not a consequence of the series marker. The section-admission decision owns incremental updates, retirement, complete overrides and adapter representations.
Request-series and tool-declaration handling remain independent. A surface replacement still starts a series and declarations can still rebuild; neither operation alone moves system instructions. An unsupported tool-update route receives the complete active declarations even when unchanged system instructions produce no system event or additional startsSeries marker.
Verification
admission.spec.tsverifies unchanged text produces no delta and compaction alone marks a full rebuild pending.system-prompt-admission.spec.tsverifies unchanged prefixes through explicit series starts, unrelated replacements, tool changes, and resume, plus retry recovery when compaction removes a system node.- The
in-history-series-startrecorded session verifies two retained system messages and no redundant system event after replacement of unrelated history.
Alternatives considered
Consolidate on every series start. Rejected because a tail replacement does not invalidate the entire cached prefix.
Always keep admitted nodes. Rejected because compaction can remove instructions and explicitly adopts current live sources for the next model attempt. Its full rebuild clears retained additions too; the old head alone is not authoritative current state.
Stop treating local replacements as series starts. Rejected because compaction and image-offload still require request-series handling. Prompt admission owns the separate instruction decision.
Compare reconstructed wire requests. Rejected because this duplicates request reconstruction and couples admission to adapter serialization. Canonical Session records already identify the instructions and their conversation positions.
Consequences
Retained system history continues to cost input tokens. Preserving its position enables prefix reuse only when the adapter representation also preserves it; it does not guarantee a cache hit. Retries reuse accepted instructions. Compaction recovery rebuilds them from the same captured sections before another model attempt without admitting the user input twice.
中文
问题
surface 替换可能只使对话历史靠后的部分失效。在该请求序列开始时将未变化的系统指令移回 node 0,会在没有改变指令的情况下从头破坏提供方前缀缓存。
决策
新请求序列开始时,将未变化的已准入系统节点保留在原位。系统提示词服务比较已提交的规范段文本,与请求序列标记独立。替换无关的用户或工具内容不需要重建指令。压缩是延迟从当前来源重建的独立触发条件,而非序列标记的结果。分段准入决策负责增量更新、退役、完整覆盖和适配器表示。
请求序列和工具声明处理保持独立。surface 替换仍会开始新序列,声明也仍可重建;两者本身都不会移动系统指令。不支持工具更新的路由会收到完整的活跃声明,即使未变化的系统指令不产生系统事件或额外的 startsSeries 标记。
验证
admission.spec.ts验证未变文本不产生增量,而压缩独立地标记待执行完整重建。system-prompt-admission.spec.ts验证显式序列开始、无关替换、工具变化和恢复期间的未变前缀,以及压缩移除系统节点后的重试恢复。in-history-series-start录制会话验证替换无关历史后保留两条系统消息,且不产生冗余系统事件。
考虑过的替代方案
每次序列开始都归并。 已拒绝,因为尾部替换不会使整个缓存前缀失效。
始终保留已准入节点。 拒绝,因为压缩可能移除指令,并明确为下一次模型尝试采用当前活跃来源。完整重建也会清除保留的新增内容;旧头节点本身不是当前状态的权威来源。
不再将局部替换视为序列开始。 已拒绝,因为压缩与图像卸载仍需要请求序列处理。提示词准入负责独立的指令决策。
比较重建的线上请求。 已拒绝,因为这会重复请求重建,并将准入与适配器序列化耦合。规范 Session 记录已标识指令及其对话位置。
影响
保留的系统历史仍消耗输入 token。只有适配器表示也保留其位置时,保留位置才有助于前缀复用;这不保证缓存命中。重试复用已接受指令。压缩恢复会在再次模型尝试前根据同一批已捕获段重建指令,而不重复准入用户输入。