Skip to content

[PR] kernel: keep mid-conversation anthropic system messages verbatim (#3991) - #3992

Merged
ranxianglei merged 5 commits into
ranxianglei:masterfrom
m1ch4ls:2026-10-20_anthropic-system-message-passthrough
Oct 21, 2026
Merged

ranxianglei merged 5 commits into
ranxianglei:masterfrom
m1ch4ls:2026-10-20_anthropic-system-message-passthrough

Conversation

@m1ch4ls

@m1ch4ls m1ch4ls commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3991

kernel-change: wire保真 — anthropic mid-conversation role:"system" messages must round-trip verbatim. The codec in kernel/src/wire/anthropic.ts is the only layer that rebuilds messages[]; the host side only sees the rebuilt body (justification in #3991).

External contributor PR: the kernel boundary asks for owner approval before implementation. #3991 is that request; the patch is offered for review and needs that approval before merge.

Problem

pi (models with supportsMidConvoToolChanges) declares tools activated mid-session as tool_addition blocks inside a mid-conversation role:"system" message, and also emits empty system messages carrying message-level output_config. anthropicToCore flattened these into the user/assistant stream, and coreToAnthropic re-emitted them as role:"user":

Change

  • kernel/src/wire/bili-message.ts: new rawAnthropicMessage?: unknown sidecar.
  • kernel/src/wire/anthropic.ts:
    • anthropicToCore maps each wire system message to exactly one core message (role system, wireIndex kept, deterministic id via deriveCanonicalMessageId). Its text is the joined text blocks, with non-text blocks as [type], or [system] when empty.
    • coreToAnthropic flushes the pending turn and re-emits the sidecar verbatim, so the message is never merged into adjacent user turns.
    • Kernel-synthesized system cores (rendered summaries, which have no sidecar) keep mapping to user. This is pinned by a parity test.
  • kernel/src/protected.ts: hasUnrecoverableMediaPayload returns true only for control-plane system messages: ones with non-text blocks (tool_addition/tool_removal) or message-level extra fields (output_config). Folding one would un-declare tools, and the host archives these nowhere. Plain-text system messages (isPlainTextSystemMessage) fold like any text message.
  • Claude Code lane: Claude Code 2.1.300 (Vertex fixture) also sends a trailing plain-text role:"system" message (# Environment …), and there it carries the request's only message-level cache_control. So:
  • Wire-contract ledger ([CI/testing] wire-contract anti-regression system: validation-parity fake upstreams + golden schema snapshots + constraint ledger + staged 4-protocol x 3-mode client smoke matrix #1304): new rule WC-022, plus a validator clause in validateAnthropicBody, a gate test, and a live-enforcement probe.
  • Version: kernel/package.json bumped 0.0.147 → 0.0.148, with both lockfiles updated to match.

Modes

The codec is shared by plugin and proxy mode, and both rebuild through coreToAnthropic. Verified live in proxy mode (BILI_PROVIDER_REWRITES → patched proxy → capture → api.anthropic.com):

  • pi called subagent successfully after subagents_enable.
  • Upstream returned 200/200, and the forwarded body kept all 3 system messages in order.
  • The tool-add turn got an 83% prompt-cache hit, versus 0% on the tools-array re-declaration fallback.
  • The invariant judge logged clean growth; unpatched master logged I1 violation: mid-history-drop.

Tests

  • New kernel/tests/anthropic-system-message-passthrough.test.ts (11 tests):

    • byte-exact round-trip of the captured pi shape
    • one core per system message, with wireIndex kept
    • no merge of surrounding user turns
    • string content
    • kernel system→user parity pin
    • unrecoverable classification
    • deterministic and distinct ids
    • parse fixed point
    • plain-text (Claude Code) shape: legacy id, foldable, mark harvested, byte-exact
    • kernel-rewritten text rebuild
    • host-stamped vs client marks

    Without the fix, 7 of the original 8 fail and 1 passes (the parity pin).

  • Kernel suite: npm test in kernel/, 1408/1408 pass (after rebase onto e98ccda9).

  • Bili suite (subset): wire-contract*, pi-native, anthropic-, e2e-anthropic, e2e-vertex-anthropic, vertex-wire-fixture, kernel-, invariant-judge*, incremental-*, issue2499, issue1470: 170 pass, including 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 (now green on master).

  • Real-data replay: the captured pi body and the Claude Code Vertex fixture through anthropicToCore → coreToAnthropic. All system messages are byte-exact. The only diff is the tool_result is_error:false drop, which was already on master.

  • CI failures not from this PR: the only red rows are #3769 upgraded pre-fold-gate state keeps rotation-hidden orphans hidden and the SMT # SKIP row. The master run for e98ccda9 (39447024068) fails #3769 identically on every test shard.

  • npm run typecheck and kernel tsc --noEmit are clean.

Known gaps (not addressed, by design)

@ranxianglei ranxianglei changed the title kernel: keep mid-conversation anthropic system messages verbatim (#3991) [PR] kernel: keep mid-conversation anthropic system messages verbatim (#3991) Oct 20, 2026
@m1ch4ls

m1ch4ls commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

(ai: anthropic/claude-opus-5-5)

Pushed f8221c1. The first CI run caught a Claude Code lane regression in tests/e2e-vertex-anthropic.test.ts. Claude Code 2.1.300 also sends a trailing plain-text role:"system" message. Classifying every system sidecar as unrecoverable gave it a BLOCKED ref, which moved the preserveRecentMessages window back one message. It also kept the request's only message-level cache_control out of cacheControls.

Now only control-plane system messages (non-text blocks or message-level fields) are unrecoverable. Plain-text ones fold, keep their legacy id, and have their mark harvested. The PR body is updated with the details. The other red jobs (lifecycle-ledger-guard, #1839 G3, #3769) are red on master 860e6174 as well.

…xianglei#3991)

Pi declares tools activated mid-session as tool_addition blocks inside a
mid-conversation role:"system" message (and emits empty system messages
carrying message-level output_config). anthropicToCore flattened those
into the user/assistant block stream and coreToAnthropic re-emitted them
as role:"user": on 0.1.202 the tool_addition blocks were dropped (tools
never reached the model); on master, with ranxianglei#3410's unknown-block
passthrough, upstream 400s ("'tool_addition'/'tool_removal' blocks are
only permitted within `role: "system"` messages").

Each wire system message now maps to exactly one core message carrying
the original on a rawAnthropicMessage sidecar; coreToAnthropic re-emits
it verbatim without merging adjacent user turns. Kernel-synthesized
system cores (no sidecar) still map to user. protected.ts classifies the
sidecar as unrecoverable so a fold can never destroy a tool declaration.

Records the upstream rejection as WC-022 in the wire-contract ledger.

kernel-change: wire保真 — anthropic mid-conversation system messages (ranxianglei#3991)
…ible (ranxianglei#3991)

CI caught a Claude Code lane regression: Claude Code (2.1.300, Vertex
fixture) appends a plain-text environment note as a trailing
role:"system" message, and on that fixture it carries the request's only
message-level cache_control.

- Only system messages with non-text blocks or message-level extra fields
  (Pi's tool_addition deltas, output_config) are unrecoverable. Plain-text
  ones keep a numeric ref, so the recent-zone window no longer slides back
  one message (tests/e2e-vertex-anthropic.test.ts).
- The system message's cache_control is harvested into cacheControls like
  any text block's, so the host's client-managed caching detection (ranxianglei#1637)
  and WC-010's breakpoint budget still see it.
- The rebuild uses m.text when the kernel rewrote a plain-text system
  message (e.g. emergency truncation), and puts a host-stamped mark on the
  last block when the original has none.
- A single-text-block system message keeps the legacy per-block id, so
  upgraded sessions see no ref churn.

kernel-change: wire保真 — anthropic mid-conversation system messages (ranxianglei#3991)
master took 0.0.147 while this branch was open.

kernel-change: wire保真 — anthropic mid-conversation system messages (ranxianglei#3991)
@m1ch4ls
m1ch4ls force-pushed the 2026-10-20_anthropic-system-message-passthrough branch from f8221c1 to 6eafb2a Compare October 20, 2026 15:23
@m1ch4ls

m1ch4ls commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

(ai: anthropic/claude-opus-5-5)

Rebased onto e98ccda9 and bumped the kernel to 0.0.148, since master took 0.0.147 in the meantime. kernel-guard is green. The test shards fail only on #3769 upgraded pre-fold-gate… (plus the SMT # SKIP row), and master e98ccda9 fails the same on every test shard (run 39447024068).

@ranxianglei

Copy link
Copy Markdown
Owner

ework接单

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重:不重复——检索 open+closed issue 与 PR,无其他条目针对同一缺陷(Anthropic wire 的会话中段 role:"system" 消息);相关条目:#3991(本 PR 源 issue)、#3997(master CI 红,解释本 PR 的红分片)。
标签:已在源 issue #3991 打好 bug / pi / claude-code / scope/wiring / p1(缺陷类;涉及 pi 与 Claude Code 两条车道;协议接线层;p1 = 受影响轮次直接 400,可用性缺陷)。

独立验证(代码审查 + 本地定向 + CI 取证)

验证基准:6eafb2a8e;当前头 08d6d632 是一次纯 master 合并(delta 仅 master 侧提交:#4015/#3769 flake 修复、#4008 mysql2 懒加载 + dist gate 泛化),本 PR 自己的文件零改动,以下结论全部继续成立。

代码审查:diff 干净(9 文件),机制核对无误——每条 wire role:"system" 映射为恰好一条 core(内容哈希 id、保留 wireIndex)、原始字节经 rawAnthropicMessage sidecar 原样带回出站(仅当 kernel 改写过文本才按新文本重建);保护判定区分 control-plane(非 text 块/消息级字段 → 不可折叠)与 plain-text(可折叠、mark 收割进缓存记账);WC-022 约束按 #1304 纪律进 wire-contract ledger,正/反双向门禁齐备。

本地定向跑(全绿):kernel 钉死测试 13/13(含与 #3953 straddle-truncate 的交互用例);wire-contract 22/22(WC-022 正反例);e2e-anthropic 11/11、e2e-vertex-anthropic 2/2、pi-native 17/17、vertex-wire-fixture 8/8、incremental-lane / invariant-judge{,-e2e} / issue1470 / issue2499 全过;typecheck 干净。

CI 取证(最新状态):

行为变更披露(旧 → 新)

  1. pi 车道(supportsMidConvoToolChanges 模型):会话中段 role:"system" 里的 tool_addition/tool_removal 声明——旧版 v0.1.202 静默丢弃(subagent 激活成功但永不可调用);master(post-anthropic wire silently drops unknown top-level blocks (incl. PDF document) when rebuilding history #3410)保留块但把消息重发成 role:user → Anthropic 硬 400。新:原样透传为 role:system。
  2. Claude Code 2.1.300+:尾部带 cache_control 的纯文本 system 消息——旧:被并进前一条 user turn 以 role:user 发出,其 cache_control 从 cacheControls 记账中丢失。新:原样以 role:system 发出,沿用既有 legacy id(零 ref churn)、可按普通文本折叠、cache_control 正确收割进缓存账([Bug] Anthropic lane never emits cache_control breakpoints — prompt cache can only ever cover the system head (~11K), the whole history re-bills at full price every request #1637 断点检测与 WC-010 预算从此看得到它)。
  3. kernel 自产 system core(无客户端 sidecar)仍映射为 user——既有 parity 由新增测试钉住,未动。
  4. 已知缺口(随 anthropic wire silently drops unknown top-level blocks (incl. PDF document) when rebuilding history #3410 一并带入,PR 正文已披露):token 估算只数 system 文本、不数 tool_addition 定义体。

结构化八问

  1. 是什么问题:pi / Claude Code 会在 Anthropic wire 上发会话中段的 role:"system" 消息(工具增删声明、effort 载体、CC 尾部环境文本),旧 codec 不建模这种形状,导致静默丢弃或上游硬 400。
  2. 什么原因导致的:kernel/src/wire/anthropic.ts 的入站转换对 messages[] 里的 role:system 没有分支——块内容被保留后落到 user turn,违反 Anthropic「tool_addition/tool_removal 仅允许出现在 system」的线级约束(已作为 WC-022 记入 wire-contract ledger)。
  3. 影响范围与严重程度:pi 车道用 supportsMidConvoToolChanges 模型 + subagent 激活、以及 Claude Code 2.1.300+ 尾部 system 场景;p1——受影响轮次直接 400,该会话实际不可用(v0.1.202 变体则是静默丢能力)。
  4. 怎么修复的:把 role:system 建模为一等公民——每条恰好对应一条 core(内容哈希派生 id、保留 wireIndex、原始字节作 sidecar),出站先 flush 未决 turn 再逐字重发(kernel 改写文本时才重建);保护判定拆成 control-plane 不可折叠 vs plain-text 可折叠 + mark 收割;WC-022 双向门禁兜底。
  5. 是否有回归问题:逐项过——kernel 自产 system→user parity 有测试钉住;字符串 content、确定性 id、parse 不动点、客户端 cache_control 位置、thinking/signature 通道均不受影响;本地定向套件全绿 + typecheck 干净。CI 仅有的红 = 既有 [Bug] MCP failed compression record rotation prematurely rewrites the history prefix, triggering expensive cache recompu | [Bug] MCP 失败压缩记录轮换提前改写历史前缀,触发大额缓存重算 #3769 flake(probe-delete-me #3997-B),master 自身同红,与本 PR 无关。
  6. 是否破坏缓存:修的是缓存而非破坏——CC 尾部断点从丢失变为被正确记账;legacy id 不变 → 存量会话零 ref churn、无新接缝;此前 400/丢弃路径本身就是会话级故障。
  7. 是否改了设计方向:无转向——在既有 codec 内补齐缺失的 role:system 建模,沿用既有 sidecar/media 模式(与 anthropic wire silently drops unknown top-level blocks (incl. PDF document) when rebuilding history #3410 同类)。
  8. 是否引入新配置:无 env/config/CLI。唯一新增内部导出 isPlainTextSystemMessage(kernel/src/protected.ts),unused-exports gate 通过。

判定

本 PR 代码与行为通过独立验证,未引入任何回归;CI 仅剩的红是 master 既有的 #3769 flake(#3997-B,#4015 修复后负载下仍未收敛,同等阻塞当前所有 PR)。技术面 ready——kernel 变更属 human-only review 层,需 owner 批准后人工合并;可接受 known-red 分片先行合并,或待 #3997-B 收敛后再合。我不执行合并。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

已接单并完成独立验证,完整报告见本线程上一条(含八问、行为变更披露、CI 取证)。当前状态无变化,收敛为待你拍板的三件事:

现状(刚重新核实)

需要你拍板

  1. kernel 变更批准:本 PR 动 kernel/(wire codec + protected),按 Kernel Boundary 属 human-only review 层,需你批准后人工合并——我不执行 merge/publish。
  2. 合并时机二选一:① 接受 known-red 分片先行合并(红与本 PR 无关,master 同红);② 待 probe-delete-me #3997-B 收敛后再合。若选 ②,建议在 probe-delete-me #3997 线程触发对该 flake 的继续处理(上一轮 ci-worker 的 [PR] fix: bare-id loadSync hydrates pooled envelopes without the unified index (master CI flake, #4014) #4015 未解决负载下的问题)。
  3. 行为变更确认(详见报告):pi 车道中段 system 消息从「丢弃/400」→ 原样透传;CC 尾部纯文本 system 消息从「并进 user turn、cache_control 丢失」→ 原样 role:system、legacy id 不变、mark 正确记账。无新配置。

一句话:代码可以合,等你点头;红的不是它的锅。

…y fixes (Windows EBUSY index.db close, storage-mode pin) for red shards (ranxianglei#3992)
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 非新缺陷——本轮红与 #3997 子缺陷 B(#3769 分片负载下 hydration flake)签名完全一致;#3997 已由 owner 于 10-21 关闭(A/C 修复合并、master 绿)。不新立项。

结论:红与本 PR 无关,已通过同步 master 解决。新 head c0c095426 CI 全绿(45/45,0 失败)。

本轮动作(auto-fix lane,第 1 次尝试):

  1. 独立核实作者声明:master e98ccda9 自己的 run 39447024068 有 4 个红分片,job 118712744155 日志第 9430 行即同一断言(tests/issue3769-upgrade-compat.test.ts:179 "record hydrates before the upgrade turn")→ 红是 master 既有,与本 PR diff 无关(本 PR 只动 kernel wire codec;旧 head 合并 master 后的 diff 中 PR 自有文件零改动)。
  2. 红分片归因:旧 head 08d6d632 的 4 个红分片各只挂 [Bug] MCP failed compression record rotation prematurely rewrites the history prefix, triggering expensive cache recompu | [Bug] MCP 失败压缩记录轮换提前改写历史前缀,触发大额缓存重算 #3769 家族两个测试(原 e2e + [PR] fix: bare-id loadSync hydrates pooled envelopes without the unified index (master CI flake, #4014) #4015 自带的回归测试 pooled-bare-load);SMT # SKIP 行是跳过(无求解器)不是失败;其余零失败。本地定向复跑两个测试均通过(upgrade-compat 3/3、bare-load 1/1)→ 只在 CI 并发分片负载下出现,非确定性。
  3. 发现当前 master 5f3b1e601 已带两个正打这两个测试的修复:9a497802e(pooled-bare-load 先关 store1 再删 index.db——Windows EBUSY)、602996bc2([Bug] MCP failed compression record rotation prematurely rewrites the history prefix, triggering expensive cache recompu | [Bug] MCP 失败压缩记录轮换提前改写历史前缀,触发大额缓存重算 #3769 套件钉死 storage mode——同分片进程内跨测试文件的存储模式泄漏,与红分片日志里 "indexed 0 state files" 但磁盘上 envelope 存在的现象吻合)。master 自身最新 run 39555368846 全绿。
  4. 处置:把 master forward-merge 进 PR 分支(纯同步提交 c0c095426,零内容变更;推送前已验证文件级不相交、无冲突),经 maintainer-edit 推到作者 fork,本地定向测试复跑绿。结果:此前红的 test (ubuntu-latest, 24, 1) 等分片全部转绿。

八问:

  1. 是什么问题:CI 并发分片负载下,"新 store 读旧会话目录" 的 hydration 步骤间歇性读不到已有会话记录,[Bug] MCP failed compression record rotation prematurely rewrites the history prefix, triggering expensive cache recompu | [Bug] MCP 失败压缩记录轮换提前改写历史前缀,触发大额缓存重算 #3769 家族两个测试变红,连带压住所有基于 master 的 PR。
  2. 什么原因导致的:测试环境非 hermetic——同一分片进程内前序测试文件改动了存储模式环境,导致该套件里的 store 未按预期以 full 模式启动(磁盘 walk/索引看不到已写出的 envelope);Windows 上另叠加打开句柄未释放时删 index.db 报 EBUSY。机制表述来自 master 侧两个修复提交的归因(602996bc2/9a497802e);本方独立验证的是:master 既有红、本地单独跑必过、仅分片负载下现形、同步后转绿。
  3. 影响范围与严重程度:仅 CI 信号面(红分片阻塞合并判定),无用户可见行为影响(修复均为 test-only)。
  4. 怎么修复的:本 PR 分支零代码改动——同步携带上述两个测试 hermeticity 修复的 master 进来即可;修复本体在 master 侧([PR] test: pin storage mode in compress-from-store (CI red — same class as #4076) #4113/[PR] gate: isolate npm metadata cache per run (Lane U stale-latest false red) #4114 系列提交)。
  5. 是否有回归问题:无。本轮无任何代码变更;本 PR 自身 diff 上一轮已全量审过(kernel codec parity / cache_control / foldability 均有测试钉住,guard/gate 各 lane 绿),本轮完整 CI 重跑全绿。
  6. 是否破坏缓存:不涉及(零代码变更)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入新配置:无。

附带一句:本轮结果同时佐证了 #3997 的关闭判断(子缺陷 B 随那两个测试 hermeticity 修复收敛),无需重开。

剩余待办(等你拍板,详见 floor 17):① kernel 变更批准(Kernel Boundary 人工层,本 PR 动 kernel/src/wire/*);② 行为变更确认(pi 会话中途 system 消息改为逐字透传而非拍平成 user;CC 尾部纯文本 system 消息保持 role:system)。合并不由我执行。

收工判定:CI 障碍已清除,PR 技术面就绪,等人工评审与合并决定。

@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.723-master.5469a16 (rolling master tag).

npm install -g billion-context@0.0.723-master.5469a16  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit that referenced this pull request Oct 21, 2026
)

openaiToCore keeps the raw wire message on mid-history system/developer
cores (rawOpenaiMessage); coreToOpenai re-emits it byte-exact, re-laying
plain text when kernel ops rewrote it. hasUnrecoverableMediaPayload:
structured (non-plain-text) mid system never folds — DSH tool_addition
style declarations survive instead of being stringContent-flattened.
ranxianglei pushed a commit that referenced this pull request Oct 21, 2026
…only bili's carriers re-voice (#4166, #4159, #4165)

kernel (mirrors #3992 on the remaining two wires):
- openai: mid-history system parses with a rawOpenaiMessage verbatim
  sidecar; coreToOpenai re-emits it byte-exact (re-blocked only when the
  kernel itself edited the text); non-plain-text system is unfoldable
- responses: mid-history system/developer become positioned sidecar
  cores (refs + fold coverage + layout slots); head prefix still hoists
  (#377); coreToResponses re-emits raw verbatim; kernel 0.0.149

host:
- systemToUser/revoiceMidSystemDevelopers take a predicate; both codecs
  re-voice ONLY isRenderedSummaryMessage carriers — client-origin mid
  system/developer is data, never re-voiced (#4159)
- prepare-responses: #1638 re-typing hack retired (codec-native now,
  mode-invariant projection — the plugin->proxy degrade no longer
  re-projects or re-bills, #2867); #3713 masking retired (real cores)
- compress-loop-responses: visibility markers + retrieval injections are
  born user; no blanket re-voice on the re-request
- loop/adapter-openai: same carrier-only narrowing (loop/prepare parity)
ranxianglei pushed a commit that referenced this pull request Oct 21, 2026
…only bili's carriers re-voice (#4166, #4159, #4165)

kernel (mirrors #3992 on the remaining two wires):
- openai: mid-history system parses with a rawOpenaiMessage verbatim
  sidecar; coreToOpenai re-emits it byte-exact (re-blocked only when the
  kernel itself edited the text); non-plain-text system is unfoldable
- responses: mid-history system/developer become positioned sidecar
  cores (refs + fold coverage + layout slots); head prefix still hoists
  (#377); coreToResponses re-emits raw verbatim; kernel 0.0.149

host:
- systemToUser/revoiceMidSystemDevelopers take a predicate; both codecs
  re-voice ONLY isRenderedSummaryMessage carriers — client-origin mid
  system/developer is data, never re-voiced (#4159)
- prepare-responses: #1638 re-typing hack retired (codec-native now,
  mode-invariant projection — the plugin->proxy degrade no longer
  re-projects or re-bills, #2867); #3713 masking retired (real cores)
- compress-loop-responses: visibility markers + retrieval injections are
  born user; no blanket re-voice on the re-request
- loop/adapter-openai: same carrier-only narrowing (loop/prepare parity)
This was referenced Oct 21, 2026
Louie0806 pushed a commit to Louie0806/billion-context that referenced this pull request Nov 4, 2026
… stored summary (ranxianglei#5620)

The ranxianglei#5620 usage wall: in image-heavy workflows every message carrying
remote-URL images / DeepSeek Files API file refs was permanently pinned
by hasUnrecoverableMediaPayload, turn integrity pinned its partners, and
the context floor climbed to ~70% of the window while folds kept pace
with growth but could never lower it.

Split the class (conservative enumeration):
- new kernel/src/media-refs.ts: extractMediaRefs pulls known re-access
  handles (non-data: URLs, file ids, fileUris) from all five wire
  sidecar families; hasRefRecoverableMediaPayload = at least one handle;
  unknown opaque shapes keep pinning until their semantics are known
- hasUnrecoverableMediaPayload media branches now return
  !hasRefRecoverableMediaPayload(msg); control-plane structured system
  branches (ranxianglei#3992/ranxianglei#4166) and refless shapes are untouched
- apply path appends a deterministic MEDIA REFS section to the stored
  block summary (applySingleRange union incl. consumed-block carry;
  applyRefolds per-block carry), so handles survive folds/merges/
  distillations mechanically — never model discretion (on the wire a
  URL part is often invisible to the summarizer); decompress restores
  the original losslessly either way
- compression-rules: MEDIA REFS preservation added to T1/T2/T3 rules;
  golden regenerated (justification: ranxianglei#5620 root fix, three prompt fields
  extended additively, COMPRESS_PHILOSOPHY unchanged)
- cosmetic: normalize one stray leading space on the tier-2
  Open-objectives bullet (pre-existing, touched while inserting the
  sibling line)

Legacy sessions self-heal without migration code: pre-ranxianglei#5620 BLOCKED refs
on now-foldable media migrate to fresh numbers via the existing ranxianglei#3805
deferred-render path (carrier render deferred to next fold boundary).

kernel version 0.0.179 -> 0.0.180
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.

[Bug][pi] anthropic wire: mid-conversation role:"system" messages are re-emitted as user — tool_addition blocks dropped on 0.1.202, hard 400 on master

2 participants