Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ For each request, the proxy resolves the settings by longest-URL-prefix match (t
- **Type:** `boolean`
- **Default:** `false`
- **Status:** ACTIVE
- **Description:** Opt-in **persistent model reminders** (issue [ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433), via the `acp-kernel` rules API). When enabled, an `acp_rule` tool is injected alongside the ACP tools: calling it with a short `rule` argument records a principle-level reminder that is **hard-protected** from compression (the call + result stay in context across every fold), and omitting the argument lists the recorded rules. Passing `delete` with a rule id (e.g. `"rule3"`) removes that one rule (`Removed ruleN: <text>`); passing `clear: true` removes every rule. The two are mutually exclusive with each other and with `rule` — one operation per call — so a stale or accidentally-recorded rule can be deleted instead of hedged with a counter-rule. Guidance on *when* to record (user-emphasized lessons, behaviors the user asks to remember, major pitfalls hit) lives entirely in the tool description — nothing is added to the system prompt. Kernel limits apply (50 rules × 300 chars each); duplicate text is rejected pointing at the existing id. Injection follows the wire's native-tool surface exactly like `absorb`: proxy mode injects the tool on the anthropic/openai/responses native-tools wires, plugin mode advertises it in the plugin manifest **only while enabled** (hosts register the manifest's tools verbatim — advertising a disabled tool breaks them, #1192; execution gated per session). Recorded rules persist across restarts in the session state; removals persist the same way. Requires `acp-kernel` >= 0.0.70 (>= 0.0.84 for delete/clear). Humans can inspect or record rules without going through the model: pi/omp expose a native `/acp-rule` command — bare `/acp-rule` lists every recorded rule, `/acp-rule <text>` records one directly (#1251).
- **Description:** **Persistent model reminders** (issue [ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433), via the `acp-kernel` rules API), **off by default** — set `compress.rules: true` to enable it (the #1399 decision: once enabled the model has full rights over session rules and may call it unprompted, including delete/clear). When enabled, an `acp_rule` tool is injected alongside the ACP tools: calling it with a short `rule` argument records a principle-level reminder that is **hard-protected** from compression (the call + result stay in context across every fold), and omitting the argument lists the recorded rules. Passing `delete` with a rule id (e.g. `"rule3"`) removes that one rule (`Removed ruleN: <text>`); passing `clear: true` removes every rule. The two are mutually exclusive with each other and with `rule` — one operation per call — so a stale or accidentally-recorded rule can be deleted instead of hedged with a counter-rule. Guidance on *when* to record (user-emphasized lessons, behaviors the user asks to remember, major pitfalls hit) lives entirely in the tool description — nothing is added to the system prompt. Kernel limits apply (50 rules × 300 chars each); duplicate text is rejected pointing at the existing id. Injection follows the wire's native-tool surface exactly like `absorb`: proxy mode injects the tool on the anthropic/openai/responses native-tools wires, plugin mode advertises it in the plugin manifest **only while enabled** (hosts register the manifest's tools verbatim — advertising a disabled tool breaks them, #1192; execution gated per session). Recorded rules persist across restarts in the session state; removals persist the same way. Requires `acp-kernel` >= 0.0.70 (>= 0.0.84 for delete/clear). Humans get the full operation set without going through the model: pi/omp expose a native `/acp-rule` command with the same semantics as the tool — bare `/acp-rule` lists every recorded rule, `/acp-rule <text>` records one directly, `/acp-rule remove <id>` deletes one, and bare `/acp-rule clear` wipes all recorded rules (`clear <text>` records instead of wiping) (#1251; remove/clear added in #1399).

#### `reasoning`

Expand Down
2 changes: 1 addition & 1 deletion CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
- **类型:** `boolean`
- **默认值:** `false`
- **状态:** ACTIVE
- **说明:** 可选开启的**持久化模型提醒**(issue [ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433),经由 `acp-kernel` rules API)。启用后,一个 `acp_rule` 工具随 ACP 工具一同注入:传入简短的 `rule` 参数调用可记录一条**原则级提醒**,该提醒受**硬性保护**免于压缩(调用及结果在每次折叠中都保留在上下文中);省略参数则列出已记录的规则。传入 `delete`(规则 id,如 `"rule3"`)删除该条规则(返回 `Removed ruleN: <text>`);传入 `clear: true` 清空全部规则。两者互斥,且均与 `rule` 互斥——一次调用只能执行一种操作——因此过时或误记的规则可以直接删除,而无需再写一条"作废声明"对冲。关于*何时*记录(用户强调的教训、用户要求记住的行为、遇到的重大陷阱)的指导完全写在工具描述里——不向系统提示词添加任何内容。受内核限制约束(50 条规则 × 每条 300 字符);重复文本会被拒绝并指向已有的 id。注入跟随线上原生工具面,与 `absorb` 完全一致:代理模式在 anthropic/openai/responses 原生工具线上注入该工具,插件模式在插件清单中声明(执行按会话门控)。已记录的规则在会话状态中持久化,跨重启保留;删除同样持久化。要求 `acp-kernel` >= 0.0.70(delete/clear 需要 >= 0.0.84)。人也可以不经过模型查看或记录指令:pi/omp 提供原生 `/acp-rule` 命令 —— 裸 `/acp-rule` 列出全部已记录规则,`/acp-rule <文本>` 直接记录一条(#1251)。
- **说明:** **持久化模型提醒**(issue [ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433),经由 `acp-kernel` rules API),**默认关闭**——设 `compress.rules: true` 显式开启(#1399 定案:开启后模型对会话规则有全权,可未经提示自主调用,含 delete/clear)。启用后,一个 `acp_rule` 工具随 ACP 工具一同注入:传入简短的 `rule` 参数调用可记录一条**原则级提醒**,该提醒受**硬性保护**免于压缩(调用及结果在每次折叠中都保留在上下文中);省略参数则列出已记录的规则。传入 `delete`(规则 id,如 `"rule3"`)删除该条规则(返回 `Removed ruleN: <text>`);传入 `clear: true` 清空全部规则。两者互斥,且均与 `rule` 互斥——一次调用只能执行一种操作——因此过时或误记的规则可以直接删除,而无需再写一条"作废声明"对冲。关于*何时*记录(用户强调的教训、用户要求记住的行为、遇到的重大陷阱)的指导完全写在工具描述里——不向系统提示词添加任何内容。受内核限制约束(50 条规则 × 每条 300 字符);重复文本会被拒绝并指向已有的 id。注入跟随线上原生工具面,与 `absorb` 完全一致:代理模式在 anthropic/openai/responses 原生工具线上注入该工具,插件模式在插件清单中声明(执行按会话门控)。已记录的规则在会话状态中持久化,跨重启保留;删除同样持久化。要求 `acp-kernel` >= 0.0.70(delete/clear 需要 >= 0.0.84)。人也可以不经过模型执行全部操作:pi/omp 提供原生 `/acp-rule` 命令,语义与工具一致 —— 裸 `/acp-rule` 列出全部已记录规则,`/acp-rule <文本>` 直接记录一条,`/acp-rule remove <id>` 删除一条,裸 `/acp-rule clear` 清空全部(`clear <文本>` 是记录而非清空)(#1251;remove/clear 由 #1399 补齐)。

#### `reasoning`

Expand Down
2 changes: 1 addition & 1 deletion PLUGIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Fetch once at plugin startup.
}
```

Register the tools natively with your agent, in whichever wire format your agent speaks — register exactly what `toolNames` lists. The opt-in tools (`absorb`, `acp_rule`) appear only when the proxy's config enables them; calling one that is known but disabled answers `200` with an explanatory `result` instead of an error (#1192). If `protocolVersion` is higher than you know, still register the tools — extra fields in schemas are ignored by agents.
Register the tools natively with your agent, in whichever wire format your agent speaks — register exactly what `toolNames` lists. `absorb` appears only when the proxy's config enables it; `acp_rule` is advertised only when the proxy's config enables it (`compress.rules: true`, opt-in). Calling a tool that is known but disabled answers `200` with an explanatory `result` instead of an error (#1192). If `protocolVersion` is higher than you know, still register the tools — extra fields in schemas are ignored by agents.

### 2. Request headers

Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The proxy injects four context-management tools (`compress`, `decompress`, `sear

An opt-in fifth tool, `absorb` (`compress.absorb.enabled: true` — see [CONFIGURATION.md](CONFIGURATION.md)), compresses **individual tool results the moment they arrive**: large results (builds, logs, greps) get a forced absorb instruction, the model distills each into a compact summary, and the original pair is hidden from the wire from the next turn on — keeping mid-session pressure lower between fold rounds (#605).

An opt-in sixth tool, `acp_rule` (`compress.rules: true` — see [CONFIGURATION.md](CONFIGURATION.md)), records **persistent principle-level reminders**: a short rule recorded by the model (user-emphasized lessons, behaviors to remember, major pitfalls hit) is hard-protected from compression — the call and its result stay in context across every fold — and omitting the argument lists the recorded rules; passing `delete` with a rule id (e.g. `"rule3"`) removes one rule and `clear: true` removes all of them ([ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433)).
The sixth tool, `acp_rule` (opt-in via `compress.rules: true` — see [CONFIGURATION.md](CONFIGURATION.md); once enabled the model has full rights over session rules and may call it unprompted, #1399), records **persistent principle-level reminders**: a short rule recorded by the model (user-emphasized lessons, behaviors to remember, major pitfalls hit) is hard-protected from compression — the call and its result stay in context across every fold — and omitting the argument lists the recorded rules; passing `delete` with a rule id (e.g. `"rule3"`) removes one rule and `clear: true` removes all of them ([ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433)).

The seventh tool, `acp_retrieve` (opt-in on every lane — set `compress.ccr.enabled: true` at any level, after local verification; plugin lanes require the explicit global `true` so the manifest advertises the tool, #1271/#1273 — see [CONFIGURATION.md](CONFIGURATION.md)), backs the **content-addressed message store** (built-in CCR, #1097/#1179): oversized tool results are **ID-referenced at arrival instead of force-distilled** — the wire keeps a byte-stable placeholder and the original goes into a per-session content-store envelope (hash-deduped), retrievable on demand via one cheap tool call. V2 makes folds lossless too: covered originals are stored when a fold lands, `decompress` restores ranges (`startId`/`endId` refs) instead of whole blocks, and `search_context` hits carry the covered `mNNNNN` refs so you can fetch exactly what you need. Lossless by default: a retrieve not made costs nothing but the call; a detail distilled away by absorb is gone for good. Scope: proxy mode, plus plugin lanes on the anthropic + openai wires when explicitly enabled (`acp_retrieve` is advertised in the plugin manifest then, #1271); responses marker/text routes and google in plugin mode stay disarmed because no request-only round-trip channel exists there (silent loss, #1097).

Expand Down Expand Up @@ -884,14 +884,16 @@ API: `bili plugin install claude` writes a model-mediated
MCP tool and pastes the report back verbatim. codex/kimi/hermes expose no
user-typable command seam — ask the model to call its `acp_cache` tool directly.

The same seam carries `/acp-rule` (#1251) — the human entry point to the
persistent-rules feature (identical output to the `acp_rule` tool): pi/omp
register it natively — bare `/acp-rule` lists every recorded rule, and
`/acp-rule <text>` records one directly (as if the model had called it). The
wrapped transcript message is stripped from model context by content signature
like the cache report — recorded rules reach the model every turn via the
system-prompt injection anyway. delete/clear subcommands land with #1178;
other lanes get it in follow-up work.
The same seam carries `/acp-rule` (#1251/#1399) — the human entry point to
the persistent-rules feature (identical output to the `acp_rule` tool):
pi/omp register it natively with the tool's full operation set — bare
`/acp-rule` lists every recorded rule, `/acp-rule <text>` records one directly
(as if the model had called it), `/acp-rule remove <id>` deletes one, and bare
`/acp-rule clear` wipes all recorded rules (`clear <text>` records instead of
wiping — a typo must not destroy every rule). The wrapped transcript message
is stripped from model context by content signature like the cache report —
recorded rules reach the model every turn via the system-prompt injection
anyway.

### Legacy opencode-acp sessions (#920)

Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ QQ群:

可选的第五个工具 `absorb`(`compress.absorb.enabled: true` —— 见 [CONFIGURATION.zh-CN.md](CONFIGURATION.zh-CN.md))对**各个工具结果即时压缩**:大结果(构建、日志、grep)被附带强制吸收指令,模型将各自蒸馏为紧凑摘要,原配对从下一轮起从线上隐藏 —— 使折叠轮之间的中间会话压力更低(#605)。

可选的第六个工具 `acp_rule`(`compress.rules: true` —— 见 [CONFIGURATION.zh-CN.md](CONFIGURATION.zh-CN.md))记录**持久化的原则级提醒**:模型记录的简短规则(用户强调的教训、要求记住的行为、撞到的大坑)受硬性保护不被压缩——调用及结果在每次折叠中都保留在上下文中——省略参数则列出已记录规则;传入 `delete`(规则 id,如 `"rule3"`)删除单条规则,传入 `clear: true` 清空全部规则([ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433))。
第六个工具 `acp_rule`(默认关闭;设 `compress.rules: true` 显式开启 —— 见 [CONFIGURATION.zh-CN.md](CONFIGURATION.zh-CN.md)。开启后模型对会话规则有全权、可未经提示自主调用,#1399)记录**持久化的原则级提醒**:模型记录的简短规则(用户强调的教训、要求记住的行为、撞到的大坑)受硬性保护不被压缩——调用及结果在每次折叠中都保留在上下文中——省略参数则列出已记录规则;传入 `delete`(规则 id,如 `"rule3"`)删除单条规则,传入 `clear: true` 清空全部规则([ranxianglei/billion-context-pi#433](https://github.com/ranxianglei/billion-context-pi/issues/433))。

第七个工具 `acp_retrieve`(全车道默认关闭、显式开启 —— 任意层级设 `compress.ccr.enabled: true` 方可启用,建议先本地验证;插件车道需全局显式 `true` 才会在 manifest 广播工具,#1271/#1273;见 [CONFIGURATION.zh-CN.md](CONFIGURATION.zh-CN.md))支撑**内容寻址消息存储**(内置 CCR,#1097/#1179):超大工具结果**在到达时改为 ID 引用,而非强制蒸馏**——线上保留字节稳定的占位符,原文进入按会话的内容存储信封(按内容哈希去重),模型通过一次廉价工具调用按需取回。v2 让折叠同样无损:折叠落定时被覆盖的原文会存入存储,`decompress` 可按区间恢复(`startId`/`endId` ref)而无需整块展开,`search_context` 命中条目携带覆盖的 `mNNNNN` ref,让你精确取回所需内容。默认无损:未执行的 retrieve 只花一次调用;而被 absorb 蒸馏掉的细节则永久丢失。仅代理模式、仅原生工具线(marker/文本协议没有执行 retrieve 的通道,存储在这些场景下自动解除武装,而不是静默丢失内容)。

Expand Down Expand Up @@ -387,7 +387,7 @@ HTTPS 走证书 MITM,HTTP 走临时 `opencode.json` 副本(`/bili/` 改写;JSONC

`/acp` 面板在所有模式下都绑定当前会话,`acp_status` 工具是其宿主内等价手段。在命令编辑器支持新增条目的宿主(2.0.x 稳定版,`editor.add`)上,V2 插件额外注册 `/acp` 斜杠命令 —— 以合成非模型消息渲染,面板优先(与 `acp_status` 工具一致);旧形状上该注册保持惰性。注意 `opencode run` 模式完全不派发斜杠命令(它们会透传给模型)—— 请用 TUI。

同一接缝还承载 `/acp-rule`(#1251)—— 持久指令功能的人侧入口(输出与 `acp_rule` 工具一致):pi/omp 原生注册 —— 裸 `/acp-rule` 逐字列出全部已记录指令,`/acp-rule <文本>` 直接记录一条(等价于模型调用)。包裹后的 transcript 消息按内容签名从模型上下文剥离(与缓存报告同机制)—— 已记录的指令本来就每轮经 system prompt 注入。delete/clear 子命令随 #1178 落地;其他 lane 见后续工作。
同一接缝还承载 `/acp-rule`(#1251/#1399)—— 持久指令功能的人侧入口(输出与 `acp_rule` 工具一致):pi/omp 原生注册,操作集与工具完全一致 —— 裸 `/acp-rule` 逐字列出全部已记录指令,`/acp-rule <文本>` 直接记录一条(等价于模型调用),`/acp-rule remove <id>` 删除一条,裸 `/acp-rule clear` 清空全部(`clear <文本>` 是记录而非清空——一个手误不该毁掉所有规则)。包裹后的 transcript 消息按内容签名从模型上下文剥离(与缓存报告同机制)—— 已记录的指令本来就每轮经 system prompt 注入。

### 旧 opencode-acp 会话(#920)

Expand Down
4 changes: 2 additions & 2 deletions src/absorb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type CoreMessage,
} from "acp-kernel";
import { PROXY_TOOL_NAMES, RULE_TOOL_NAME } from "./compress-tool.js";
import { effectiveRulesConfig } from "./rules-feature.js";
import { effectiveRulesEnabled } from "./rules-feature.js";
import { IMAGE_FULL_TOOL_NAME, imageCompressionEnabled } from "./image-compress.js";
import { ccrEnabled, retrieveToolName } from "./store.js";
import { log as loggerLog } from "./logger.js";
Expand Down Expand Up @@ -52,7 +52,7 @@ export function isProxyToolFor(name: string, session: Session | undefined, confi
if (absorb?.enabled === true && name === (absorb.toolName ?? ABSORB_TOOL_NAME)) return true;
if (ccrEnabled(session) && name === retrieveToolName(session)) return true;
if (imageCompressionEnabled(session) && name === IMAGE_FULL_TOOL_NAME) return true;
return effectiveRulesConfig(session, config)?.enabled === true && name === RULE_TOOL_NAME;
return effectiveRulesEnabled(session, config) && name === RULE_TOOL_NAME;
}

// Per-turn view transform: drop absorbed tool-call/result pairs, then append
Expand Down
Loading
Loading