fovea: docs say a cut result is kept by the length guard, not the marker

#755 removed cut()'s "[fovea:" sniff, but the file header (and its copy
in page/measure.js) and the README still said content carrying the
marker is left alone, and the README still counted 31 tests. Comment
and README only; no code or version change.

Run on mote (Bun 1.4.2, temp HOME): bun test packages/fovea, 35 pass,
0 fail, including the measure.js freshness test.
This commit is contained in:
yetone
2026-11-05 15:13:35 +08:00
parent 1e9f14248e
commit 8e4105dd3d
3 changed files with 8 additions and 6 deletions
+2 -2
View File
@@ -54,7 +54,7 @@ git clone https://github.com/magpie-community/plugins && bun test packages/fovea
## 它怎么工作
`onRequest` 收到请求后:请求小于 `threshold` 原样放行;否则窗口(按条数与 token 预算取宽者)之前的旧消息逐条裁剪。Chat(`role:"tool"`)、Anthropic(`tool_result` 块)、Responses API(`function_call_output`)三种形状各自处理;无法识别的形状原样通过。已经带 `[fovea: …]` 标记的内容不再二次裁剪。失败即放行(fail open)。
`onRequest` 收到请求后:请求小于 `threshold` 原样放行;否则窗口(按条数与 token 预算取宽者)之前的旧消息逐条裁剪。Chat(`role:"tool"`)、Anthropic(`tool_result` 块)、Responses API(`function_call_output`)三种形状各自处理;无法识别的形状原样通过。已裁内容短于长度闸门(`head + tail + 80`),不会二次裁剪;正文里出现 `[fovea:` 字样不构成豁免。失败即放行(fail open)。
| 选项 | 默认 | 含义 |
|---|---|---|
@@ -78,7 +78,7 @@ git clone https://github.com/magpie-community/plugins && bun test packages/fovea
## 证据三层,各管什么
1. **规则正确性** —— `bun test`:31 个确定性用例(离线、零依赖)。覆盖三种形状的工具配对、protect 在两种模式下生效、代理对不劈开、document 块不动、标记幂等、连续两轮已裁前缀逐字节相同。
1. **规则正确性** —— `bun test`:35 个确定性用例(离线、零依赖)。覆盖三种形状的工具配对、protect 在两种模式下生效、代理对不劈开、document 块不动、标记幂等、连续两轮已裁前缀逐字节相同。
2. **同一请求确实变小** —— `bun benchmark.mjs [request.json] [options]`,或直接在证据页粘贴你的请求。合成样例:47,777 → 14,148 字符,已裁的 27 条消息逐字稳定。
3. **真实 token / 缓存 / 费用** —— `FOVEA_GATEWAY_KEY=<临时key> bun live-benchmark.mjs`:同模型、同请求、ABBA 四连发,记录供应商返回的 input / cache_read / output token 与耗时,只看暖缓存的第二次。0.1.0 时代的一次实测:163,143 → 42,358 prompt tokens,中位延迟 7.1s → 2.5s(因历史形状与供应商缓存而异)。**账单以 `magpie usage --csv` 的 `cost_usd` 为准;字符百分比不是美元。**
+3 -2
View File
@@ -46,8 +46,9 @@
// saccade it is the old task, and collapses with the rest. Tool calls and
// their ids are never touched — an old tool result is shortened or
// noted, not removed, so every tool_call still has its answer.
// Already-shortened content carries the marker and is left alone, so a
// history re-sent each turn is cut once, not again. A reply is never
// Already-shortened content is short enough to pass the length guard, so
// a history re-sent each turn is cut once, not again; a marker in the
// content itself exempts nothing. A reply is never
// touched: what the agent keeps from it is the agent's to keep.
//
// Chat (role:"tool"), Anthropic (tool_result blocks) and the Responses API
+3 -2
View File
@@ -46,8 +46,9 @@
// saccade it is the old task, and collapses with the rest. Tool calls and
// their ids are never touched — an old tool result is shortened or
// noted, not removed, so every tool_call still has its answer.
// Already-shortened content carries the marker and is left alone, so a
// history re-sent each turn is cut once, not again. A reply is never
// Already-shortened content is short enough to pass the length guard, so
// a history re-sent each turn is cut once, not again; a marker in the
// content itself exempts nothing. A reply is never
// touched: what the agent keeps from it is the agent's to keep.
//
// Chat (role:"tool"), Anthropic (tool_result blocks) and the Responses API