You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
conversation_id:
Target bili conversation id.
Defaults to the current conversation.
May reference another historical pfa-* session for read-only search.
我觉得最小实现只需要保证三点:
search_context 可以显式指定其他历史 pfa-* session
目标 session 即使当前不是 live/resident,也可以从持久化数据中加载后查询
跨 session 查询只读,不修改目标 session 的 compression state
这样新会话可以保持干净,需要旧信息时再按需查询;完整 handoff 或需要大量原始内容时,继续使用现有的 bili export / bili export --full 即可,不需要额外设计一套 session migration 机制。
参数说明按 issue 建议调整为:"Target bili conversation id. Defaults to the current conversation. May reference another historical pfa-* session for read-only search."
Activity
ranxianglei commentedon Sep 16, 2026
这里有一个问题就是,billion-context可能根本不知道session是啥,这个问题需要解决
ranxianglei commentedon Sep 16, 2026
[bot] 🏷 确认,这正是我分析代码后卡住的点。先把层次分清楚:加载不是难点,发现(discovery)才是。
层次判断
加载层(已具备):持久化是完整的——每个 session 的
CompressionState(含全部 block summaries)都落盘;kernel 的 StateStore 在boot()/loadAll()之后维护 id→文件路径的 discovered map,所以任何历史 session(哪怕已被 LRU 逐出内存)都能按 id 直接从磁盘加载。加一条专用只读路径(读 envelope → mergeState,完全不调度写)即可满足"不修改目标 session 状态"——连loadSync现在可能触发的 代理压缩不上报改写量,宿主上下文会计塌缩至 ~0(omps recordAnchoredHistoryRewrite 零调用);且持久化 lastInputTokens 恢复无钳制,旧版负值升级后复活 #408 clamp 重写副作用都能避开。发现层(真正的缺口):模型在对话里没有任何渠道知道有哪些 session id——
acp_status只报当前会话的上下文状态);所以只加
conversation_id参数,值没人填得出来——你说的"billion-context 不知道 session 是啥"指的就是这个:session 概念从未在对话面暴露过。已有的资产:
bili export(CLI)已经能列出所有 persisted session(id / label / protocol / blocks / title),这是人侧的发现通道;且每条持久化记录里恰好带着做索引需要的元数据(title、label、protocol、upstream、savedAt、blocks)。推荐方案(全部收敛在
search_context一个工具里,不加新工具,不需要发 acp-kernel):search_context增加conversation_id参数:"*"= 列表模式:返回按最近活动排序的 persisted session 紧凑索引(限条数,如 20 行):id | title | protocol/upstream | blocks | last activity,并标记哪一个是当前 session。这给模型自助发现能力——先*列一遍,再按 id 查。decompress只作用于当前 session;要大量原始内容用bili export <id> [--full])——避免模型拿到别的 session 的b3在当前会话 decompress 撞到同号块。compress-tool.ts里派生带新参数的工具常量,wire 三个 injector(anthropic/openai/responses)和 plugin manifest 同时消费。plugin 模式的 agent(pi/omp/opencode)本来就从/__bili/plugin/manifest拉 schema,自动同步生效。acp-kernel 保持 host-agnostic 不动——它没有持久化概念,这个参数天然是 host 侧的事,进 kernel 反而污染边界。decompress不动(与你定的最小范围一致)。安全说明会写进文档:同一实例内任意 session 互相可见,单用户自托管前提下可接受。方案没问题的话我就开分支实现(实现 + 测试 + PR)。如果你倾向列表做成独立入口(比如扩展
acp_status而不是"*"sentinel),说一声我再调;否则按上面做。kuviki commentedon Sep 16, 2026
另外目前实测
bili export <session>主要导出 persisted folded snapshot,--full会追加 block original messages,但没有看到独立的 T1/T2/T3 block summary 正文;如果这是预期之外的行为,希望同时确认/修复,使bili export可作为跨会话完整 handoff 的兜底。kuviki commentedon Sep 16, 2026
bili export在存在 persisted folded snapshot 时没有保证导出 active block summaries;当 snapshot 被BILI_PERSIST_TAIL_TOKENS截断且 active blocks 位于更早历史时,handoff 会完全丢失这些压缩摘要。ranxianglei commentedon Sep 16, 2026
[bot] 🏷 已确认并复现,你的判断准确。最小复现(
BILI_PERSIST_TAIL_TOKENS=40,一个覆盖早期对话的 T1 block,其 summary 被预算截断出快照之外):层次结论
state.blocks[].summary和blockContents都完整落盘了(--full能恢复 originals 就是证明——数据在)。renderHandoff(node_modules/acp-kernel/dist/index.js:3739-3780),它只输出三样东西——头部统计、conversation view、(--full && folded)block originals——从不输出state.blocks[].summary。summary 只有在写入时恰好落在BILI_PERSIST_TAIL_TOKENS(默认 16K tokens)保留窗口内才会出现(prune 在落盘时把 summary 内嵌进快照消息里);更早的 block 的 summary 随尾部截断一起消失,handoff 就此丢失。lastMessages(走 fallback 路径);persist-tail.test.ts 的 summary 恰好留在快照窗口内——没有测试覆盖"旧 block + 截断尾部"的组合。修复方案(正在实现,独立 PR):
## Compressed block summaries段:每个 active block 输出 tier / topic / ~tokens / 时间 + summary 正文;--full时同一 block 下附 original messages(替代 kernel 分散的 originals 段,summary+originals 归拢到同一 block 条目下)。会单独提一个 issue 记录这个缺陷(来源标记为本线程),修完贴 PR 链接。
ranxianglei commentedon Sep 16, 2026
[bot] 🏷 修复完成,已提 PR:
改动(仅 src/export.ts + 新测试文件,不需要发 acp-kernel):
## Compressed block summaries段(snapshot 主路径与 v2 fallback 路径共用一个渲染器):每个 active block 输出 tier / topic / ~tokens / 时间 + summary 正文;--full时同一 block 条目下附 original messages(替代 kernel 分散的 originals 段,summary 和它的原文归拢在一起)。tests/export-summaries.test.ts三个场景:截断尾部(plain / --full 都能拿到 summary,--full 还能恢复 originals)、未截断快照不重复、live session prune 内联 summary 保持单份且不产生多余段落。Pre-flight:typecheck 干净;
npm test1514 pass / 0 fail / 2 skipped(ACP_TEST_E2E 门控,未跑);build 成功。修了什么问题/为什么修/是否可以合并:修复了 export 渲染层丢失被尾部截断的 block summaries(数据在盘上、渲染从不输出),补上统一 summary 段并保证至少出现一次,可以合并。另:
search_context跨 session 查询的设计方案(上一条回复里的 5 点)仍在等你拍板,拍板后我开分支实现。kuviki commentedon Sep 16, 2026
回到最初的需求,只需改下 conversation_id 参数说明,跨会话由用户告知模型历史会话的 conversation_id 是哪个。
ranxianglei commentedon Sep 16, 2026
[bot] 🏷 收到,按最小范围做——我提的发现机制(
"*"列表模式、未知 id 附带最近会话提示)全部撤掉,跨会话 id 由用户在对话里告知模型。最终实现范围就是原 issue 的三点:
search_context增加可选conversation_id:不传或 == 当前 session → 现有行为;传其他历史pfa-*→ 只读搜索该 session。参数说明按你给的措辞调整:boot()/loadAll()已建立 id→文件映射,被 LRU 逐出的历史 session 也可定位)。另外保留两个最小正确性细节(不是新功能):
[search_context FAILED: unknown session "<id>"];decompress只作用于当前 session;大量原始内容用bili export <id> [--full])——防止模型拿到别的 session 的bN在当前会话 decompress 撞到同号块。改动仍全部留在本仓库(schema 派生常量同时供三个 wire injector 和 plugin manifest 消费,proxy/plugin 两种模式同步生效),不需要发 acp-kernel。开始实现,完成后回 PR。
ranxianglei commentedon Sep 16, 2026
[bot] 🏷 已按最小方案实现,PR 在这里:**https://github.com/ranxianglei/billion-context/pull/858**(Closes #841)
实现前发现 upstream 刚合入的 #760/#761 已经给所有 bili plugin-manifest 工具加了
conversation_id参数(用于共享 MCP 进程时的路由),所以本 PR 是在它之上扩展search_context的执行层语义,而不是另起一套:search_context({query, conversation_id: "pfa-old"})。id 与当前 session 相同(含 canonical 别名形式)→ 行为与现在逐字节一致;否则只读搜索目标 session。proxy 模式(wire schema 派生常量,kernel 常量零改动)和 plugin 模式(manifest 参数说明特化)都覆盖。peekSession/findSessionByCanonicalId),否则走新增的SessionStore.loadStateForSearch(id)—— 纯读路径,永不触发保存(区别于带 代理压缩不上报改写量,宿主上下文会计塌缩至 ~0(omps recordAnchoredHistoryRewrite 零调用);且持久化 lastInputTokens 恢复无钳制,旧版负值升级后复活 #408 clamp 副作用的loadSync)。[search_context FAILED: unknown session "..."],不创建任何状态。in session <id>标注 + 提示 block id 是 per-session 命名空间(decompress 仍作用于当前 session;批量内容继续用bili export <id> [--full])。search_context保留conversation_id在 args 里让 proxy 自行解析目标,其他工具的路由语义完全不变。参数说明按 issue 建议调整为:"Target bili conversation id. Defaults to the current conversation. May reference another historical pfa-* session for read-only search."
Pre-flight(rebase 到最新 master、acp-kernel 0.0.74):typecheck 干净;npm test 1654 pass / 0 fail / 2 skipped(e2e 需 live upstream,未跑);build 成功。新增
tests/search-context-cross-session.test.ts(schema 派生 + kernel 未突变、self-reference、unknown-id、resident 命中不触盘、冷加载只读证明)+ 扩展 manifest 断言。📌 中文摘要:修复/实现了 search_context 通过 conversation_id 只读查询历史 pfa-* session(内存优先、持久化兜底、零副作用),复用 #760 已上线的参数管道,可以合并。
ranxianglei commentedon Sep 17, 2026
继续
ranxianglei commentedon Sep 17, 2026
继续
feat: search_context targets historical sessions read-only via conver…
feat: search_context targets historical sessions read-only via conver…
ranxianglei commentedon Sep 17, 2026
收到。"继续"处理的是 PR #858 被 master 阻塞的问题——它提出来时 master 已前进 25 个 commit(含 #848 export summaries 修复、#853 summary cap、release v0.1.117),GitHub 报
mergeable_state: dirty(文本冲突),CI 虽绿但合不了。本轮做的事:
src/server.ts:保留 master 新增的storeEffectiveConfig+ 本 PR 的BILI_ACP_TOOLS_*派生常量;src/plugin.ts:保留 master 的effectiveConfig+ 本 PR 的SEARCH_CONTEXT_TOOL_NAME/SEARCH_CONTEXT_CONVERSATION_ID_PARAM。npm test1675 pass / 0 fail / 2 skipped(e2e 门控);build 成功。dirty→clean(可合并)。一个插曲:期间有另一个 daemon session 也做了同样的 rebase 并 push(head 变为 b941b5d)。我逐字节 diff 确认它与我验证过的 head(2eefd9b)tree 完全一致,所以结论不受影响,没有再推。
📌 中文摘要:PR #858(search_context 跨 session 只读查询)此前与 master 冲突被卡住,已 rebase 到最新 master 并解决 import 冲突,typecheck/全量测试/build/CI 全部通过,现在处于 clean 可合并状态,等你合并即可(合并动作只能由人来)。
PR: #858
fix: zero-injection session identity — route id-less MCP tool calls b…
fix: zero-injection session identity — route id-less MCP tool calls b…
fix: consume Codex per-call _meta.threadId in the MCP shim (ranxiangl…
test: teach #841 schema drift guard about the intentional #2579 compr…
test: walk only session subdirectories in the #841 cold-load check (u…
test: walk only session subdirectories in the #841 cold-load check (u…
test: walk only session subdirectories in the #841 cold-load check (u…
fix(tests): make #841 fixture dir scan sidecar-aware (pre-existing EN…
Make compress failures retryable in the same turn (ranxianglei#743)
Make compress failures retryable in the same turn (ranxianglei#743)
fix: bili export renders active block summaries missing from the trun…