1.5 KiB
1.5 KiB
title, created, updated, type, tags, sources
| title | created | updated | type | tags | sources | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Global Context Hash Tree (全局上下文哈希树) | 2026-05-29 | 2026-05-29 | concept |
|
|
Global Context Hash Tree (全局上下文哈希树)
Global Context Hash Tree 是 distributed-prompt-caching 中的核心标识机制:将 Prompt 按层级结构(Global → Project → Session → Message)组织成树,每层独立计算 SHA-256,组合成 128 字节的复合键作为会话的分布式唯一标识符(UID)。
结构
[Global Layer SHA] → [Project Layer SHA] → [Session Layer SHA] → [Current Turn SHA]
四层哈希组合成 128 字节的二进制复合键(Composite Key)。
设计优势
- 确定性:相同的上下文产生相同的哈希,可重复定位
- 分层性:符合 LLM Prompt 的自然组织方式
- 紧凑性:128 字节即可标识任意大小的上下文
- 跨服务商兼容:不依赖特定 LLM 提供商的缓存句柄格式
在路由中的作用
复合键作为 distributed-cache-routing 的主键,使任何节点都能通过本地哈希计算瞬间查询某前缀在各物理节点和服务商端的"热态"分布。
相关
- distributed-prompt-caching — 分布式缓存体系
- distributed-cache-routing — 基于哈希树的路由
- distributed-agent-cache-sync-2026 — 原始文章