A new gateway middleware, @magpie-community/middleware-fovea 0.2.2 (webkubor, #640): old tool output and text in a long history are cut to head and tail, with the boundary only on multiples of `cut_step` (24) so the cut prefix stays byte-identical between turns and the prompt cache holds. The leading user items before the first answer (Codex's AGENTS.md, environment_context and the task; Claude Code's first message) stay whole. `saccade` ("off" by default) drops the old context on a new topic, judged against that same task. Old images become a text note that keeps their `cache_control`. Ships an evidence page (Plugins > Fovea evidence) that computes a paste-in A/B in the frame, with no network.
What was run, at the reviewed head b9883cf206814fdc01950a00d413a36856de4e11, on mote (macOS, Bun 1.4.2, sandbox HOME):
- `bun test packages/fovea`: 33 pass, 0 fail. The two new Codex saccade cases fail with 0357f1c's middleware (and pass at the head).
- `bun scripts/check.mjs fovea` and `bun scripts/check.mjs`: pass. `page/measure.js` is byte-identical to a fresh `bun build.mjs`.
- `npm pack --dry-run`: 18 files, 131.8 kB unpacked; no brand/, no live-benchmark.mjs.
- The head merged onto origin/main 82b254f2 (registry.json auto-merged): `bun scripts/check.mjs` passes and `HOME=$(mktemp -d) bun test` (the whole repo, as pr.yml runs it): 5477 pass, 0 fail.
- A probe calling onRequest turn after turn. Codex-shaped Responses (instructions, developer permissions item, AGENTS.md, environment_context, the task as input_text, then reasoning with encrypted_content, function_call and function_call_output, 60 turns) and Claude Code-shaped Messages (system with cache_control, a first message with system-reminder, task and an image with cache_control, then thinking + signature, text, tool_use and a 6400-char tool_result with emoji, 70 turns). `instructions`, `system`, `tools`, every reasoning, function_call and assistant item, ids, counts and the cache_control count are unchanged; the four leading Codex items reach upstream byte-identical; no lone surrogate. The shared prefix breaks once per cut_step (Codex 6 of 60 turns, Messages 5 of 70; 0 without fovea), with `saccade: "auto"` too. With auto, a same-task follow-up on Codex ("scheduler retry timing assertion still fails in internal/sched, fix it") and on Messages collapses nothing; a new topic collapses from that turn on (one extra prefix break). Bodies went 16.1 MB to 9.4 MB (Codex) and 26.1 MB to 13.9 MB (Messages) over the run.
- Text the middleware adds upstream is only `[fovea: N chars of old tool output omitted]` and `[fovea: prior topic not carried]`: neither names magpie, a vendor or a limit. Codex's instructions are never touched.
Not tried: a live vendor request with real cache-hit numbers (the evidence is the byte-level prefix). pr.yml's runs were waiting on approval for a first-time contributor, so the CI record is the merged-tree run above. A new topic that shares a common word such as "the" with the task stays below the 0.08 overlap bar only when it has enough words; with saccade off by default that is a tuning note, not a blocker. @magpie-community/middleware-fovea is new to npm, so its first version needs an owner (trusted publishing can't create a package); magpie serves it from the dist branch meanwhile.
3.3 KiB
3.3 KiB
Changelog
本文件记录 fovea 的对外变化。格式遵循 Keep a Changelog,版本遵循语义化版本。
[0.2.2] — 2026-11-04
Fixed
saccade: "auto"的话题判定改用与任务豁免同一口径的「任务」:首条回答之前的前导 user 消息中的最后一条。Codex 形状下首条 user 是 AGENTS.md,旧规则拿它比对,于是同一任务的跟进被判成换话题、任务与工具输出整段折叠;反过来,真换题但碰巧与 AGENTS.md 同词时又不折叠。两向各有用例。
Changed
live-benchmark.mjs不再随包发布(它会改写运行中 magpie 的插件选项),只留在仓库里。- README 快速上手不再预设
saccade: "auto",改为说明默认off适合带缓存的长工具循环,auto的取舍写在旁边。
[0.2.1] — 2026-11-03
Fixed
- 旧图片换成注记时保留块的
cache_control——那是供应商缓存的一个断点,静默丢掉会少一个命中位(两模式均保留,有用例)。 - 任务豁免从「第一条 user 消息」改为「首条回答之前的整段前导」:Codex 形状下 AGENTS.md 与 environment_context 在任务之前,旧规则保护的是 AGENTS.md、裁的是真任务;新规则在首条 assistant 回复 / 工具调用 / reasoning 处截止。
[0.2.0] — 2026-11-02
fovea 首个版本。前身是本仓的 context-slim 草稿(PR #467,已关闭),在独立开发仓 webkubor/fovea 成型后回到这里;与该仓同源同版。
Added
cut_step:裁剪边界按块移动,块内已裁前缀逐字节稳定,供应商 prompt cache 可连续命中;不足一块不动。附连续两轮与跨块边界的回归测试。saccade(off/auto/always):最新问题与首条任务词面重叠趋近零时,旧上下文折叠为一行[fovea: prior topic not carried];「继续」类短跟进不触发。state_marker:agent 自带结构化状态块的契约——带标记的消息在两种模式下都完整,且原始任务消息随之可裁。protect正则在折叠模式下同样生效。- Responses API
function_call_output的数组output与字符串形式对称处理,call_id永不动。 - 证据体系:
benchmark.mjs(同一请求前后对照、共同前缀占比、已裁前缀逐字稳定)、live-benchmark.mjs(同模型 ABBA 受控实测,退出恢复插件选项)、插件内证据页(零权限、不联网、不保存正文)。 keep_recent_tokens预算窗口;品牌资产(logo 双色 / banner);bun test27 例离线全绿。
Changed
- 更名
context-slim→fovea,标记从[context-slim: …]改为[fovea: …];名字即机制——中央凹看得清、周边视野只剩轮廓,saccade 是视线跳向新目标。
Fixed
- 早期草稿中
cut_step把不足一块的历史量化到 0、从不裁剪的问题。 keep_recent_tokens走窗停在溢出消息上、恰好保护了预算本应放弃的巨型消息的问题(评审 §1 修复过程中发现)。- 旧版
isImage把 document 块当图片换成注记的问题;代理对在头尾两端的劈开问题。
[0.1.0] — 2026-10-28
- 初版:旧工具输出与长文本留头尾,旧图换注记,消息条数/顺序/id/配对不变。