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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to **billion-context** are documented here.
Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag.

## [Unreleased]
- **Image pre-compression (`compress.imageCompression`) and the `image_full` tool removed (#3266).** The opt-in downscale pass and its restore channel are gone from host and kernel: no more arrival-time shrinking, no `image_full` injection, no `[Downscaled screenshots]` notes, no image stats — `sharp` is no longer an optional dependency. Rationale: the restore loop was structurally unreachable on hosts that reject bili-injected tools (codex), and where reachable the model had no reliable way to learn the right ref, producing the 38-round guess-reject-resend loop in #3266 (cache hit 75%→28%). Every image now passes through byte-identical at original resolution. Sessions persisted by older versions load unchanged; their legacy `imageShrinks`/`imageFullRestored` state keys and `imageShrunk*` stats are ignored on load (never materialize). A future redesign is tracked on the issue.
- **Incremental marker divert + native client helpers (#3248 phase 2).** A native extension can now send incremental turns on its ORDINARY model requests: stamp `x-bili-plugin-turn: 1` (requires the usual `x-bili-plugin`) and post the incremental payload — the body shape (top-level `conversationId`/`sinceSeq`/`messages`, no top-level `model`) is the final word, so a marker on a non-incremental body rides the normal pipeline unchanged and no provider URL changes. The lane forwards to the ORIGINAL request path; `GET /__bili/plugin/turn` probes capability (`{ok, protocol: 1, feature, enabled, storage}`). Gated by the rollout feature `pluginIncrementalTurns` — default 0% keeps every install byte-identical; force with `rollout.features.pluginIncrementalTurns: true` or `BILI_ROLLOUT_PLUGIN_INCREMENTAL_TURNS=1` (still requires a live unified sidecar). Seeds imply `resync: true` (a first incremental turn never 409s, and interop full-resend traffic is replaced client-authoritatively); a system-only change rides an empty delta. Reference wirings: pi (`before_provider_headers`/`before_provider_request`/`after_provider_response`) and dsh-native (fetch patch `beforeSend`/`headersFor`/`onResponse`), both on the shared state machine in `src/agent/incremental-client.ts` (probe TTL cache, prefix-hash diffing, sticky system, per-conversation dead flag) — new hosts should reuse it.
- **Incremental turns (#3248): `POST /__bili/plugin/turn`.** Native hosts that keep their own full local history can stop resending it: the first turn seeds the canonical (server-side, unified messages table), later turns send only the delta (client-added messages including the previous assistant reply), and the lane assembles the full body and re-enters the proxy pipeline in-process — same session (the client's own conversation id), same fold ledger, same nudges/tools, freely interleaving with full-resend traffic. Strict ack contract (`x-bili-applied-seq`; 409 seq-mismatch/turn-in-flight forces resync), sticky system prompt, anthropic request params via allowlist, loopback-gated like every `/__bili/` surface. Requires `storage.unified` (503 otherwise); v1 keeps the O(full) pipeline walk (zero-hit, cheap) — the server-authored prefix fast path is tracked on the issue. A divergent `resync: true` records a base-seq epoch (`session_ext` `inc:base-seq`), so cold rebuilds slice past the rejected branch's append-only rows — one resync heals, restarts included; legacy-only storage degrades to the previous full-union read.
- **Resident metadata folds after save (#3050 R3 ②c):** an idle session's metadata record (fold anchors, cache ledger, lineage — the reconciliation bookkeeping that dominates long sessions) swaps to a transparent lazy proxy after the save captures it; any access re-materializes the persisted shape (exactly what a restart restores) with one disk read, and \`/__bili/memory\` gains a \`metadata\` column. Measured ~19.6 MB off the fattest dogfood session; an unrecoverable drop throws instead of persisting a thinned record.
Expand Down
19 changes: 0 additions & 19 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
| `compress.ccr` | object | enabled in proxy mode since v2 | — | Content cache & retrieve: large outputs stored losslessly beside the session, replaced by head excerpt + pointer fetched back via acp_retrieve; no cap or eviction. |
| `compress.search` | object | off | — | Search-behavior settings for search_context; currently holds planAware re-ranking. |
| `compress.search.planAware` | boolean | false | — | When on, search_context candidates are re-ranked against current plan state; off keeps byte-identical lexical results. |
| `compress.imageCompression` | object | opt-in (disabled) | — | Opt-in lossy downscale via optional sharp before sending; image_full restores originals; proxy mode only. |
| `compress.prompts` | Partial<Prompts> | unset (kernel doctrine) | — | Override the kernel doctrine texts; load-bearing for quality — gated behind acknowledgePromptsRisk. |
| `compress.reasoningGuard` | object | off | — | Auto-repair of reasoning-lattice truncation on gpt-5.x/6.x (up to 3 continue-nudge rounds). |
| `compress.outputSteering` | object { enabled?, verbosityLevel?, effortRouting? } | enabled false · verbosityLevel 2 | — | Appends a conciseness directive to the system-prompt tail; clamps mechanical continuation requests. |
Expand All @@ -262,11 +261,6 @@ This index is generated from `website/config-reference/*.yaml` — edit the seed
| `compress.ccr.excludeTools` | string[] | [] | — | Tool names excluded from CCR storage. |
| `compress.ccr.toolName` | string | "acp_retrieve" | — | Registered name of the retrieval tool. |
| `compress.ccr.maxHeadChars` | number | 96 | — | Maximum head-excerpt length left inline at the storage pointer. |
| `compress.imageCompression.enabled` | boolean | false | — | Enable lossy image downscaling (requires the optional sharp dependency). |
| `compress.imageCompression.minTokens` | number | 512 | — | Only downscale images whose counted tokens exceed this. |
| `compress.imageCompression.maxDimension` | number | 1280 | — | Largest output dimension after downscaling. |
| `compress.imageCompression.quality` | number | 80 | — | Encoder quality (1–100). |
| `compress.imageCompression.format` | string | "webp" | — | Output image format. |
| `compress.prompts.compressPhilosophy` | string | unset (kernel text) | — | Override of the compression philosophy doctrine paragraph. |
| `compress.prompts.howToCompressRules` | string | unset (kernel text) | — | Override of the compression how-to rules. |
| `compress.prompts.tier2DistillRules` | string | unset (kernel text) | — | Override of the tier-2 distillation rules. |
Expand Down Expand Up @@ -1373,19 +1367,6 @@ For each request, the proxy resolves the settings by longest-URL-prefix match (t
- **Description:** Opt-in **planning-aware retrieval** for `search_context` (issue #1336). When enabled, if a query matches more blocks than `limit`, the candidates are re-ranked against the current plan state extracted from the in-context message view: the LAST tool call of each planning tool (built-in patterns `TodoWrite`, `todowrite`, `todo_list`, `update_plan`, `TaskCreate`, `TaskUpdate`, plus every `compress.protectedLatestTools` pattern — same latest-wins semantics as the kernel's snapshot protection) and the most recent user turn. Candidate topics/summaries are scored by weighted term overlap with that state; blocks scoring above zero sort first, ties keep the original lexical order. Two things happen only then: the returned subset can differ from the pure lexical cut, and a `[plan-aware]` steering section is appended with (a) `top fetch targets:` — the covered ref spans of the top-scoring returned blocks, and (b) a hint for any covered ref already retrieved ≥2 times this session, pointing at a one-shot `decompress({blockId, startId, endId})` range restore instead of repeat `acp_retrieve`. When the flag is off, when no plan state is in context, or when the match pool fits inside `limit`, the output is byte-identical to the pre-feature behavior. Ranking touches candidate order only — no store/fold/injection mechanics change, no new persistence, and foreign-session searches (`conversation_id`) stay read-only lexical. Every re-rank logs an `[acp-search-plan] …` line with the per-block scores. Companion stats: whole-block decompresses count up in `acp_status` under a `RETRIEVAL QUALITY` line (total, plus how many had a cheaper precise path available — i.e. the block carried a ref span and CCR was armed), so the retrieve-vs-decompress trade can be measured before/after enabling. Sub-fields (merged deepest-wins like every other CompressSettings field):
- `planAware: boolean` — master switch; anything other than `true` keeps the feature fully off.

#### `imageCompression`

- **Type:** `object` (`{ enabled?, minTokens?, maxDimension?, quality?, format? }`)
- **Default:** *(disabled — the feature is off unless you set `enabled: true`)*
- **Status:** ACTIVE (v1 — proxy mode)
- **Description:** Opt-in **image pre-compression** for screenshot-heavy tool results (issue #1095, via the `acp-kernel` image-compression API, acp-kernel >= 0.0.84). Multimodal providers bill images by pixel area, so a phone screenshot costs more than a large code block. When enabled, screenshot-like images (deterministic heuristic classifier: portrait aspect ratio in band + minimum short side) in tool results are downscaled **once at arrival** — before they enter the wire — so the model still sees the UI at a fraction of the billed pixels. Non-screenshot images pass through byte-identical. The routing decision (pass vs downsample + recipe) is made by the kernel per image; the host executes the encode with the optional `sharp` dependency (lazy-loaded; missing or failing ⇒ the original passes through, never blocking the main flow). **Lossy by nature** — unlike text CCR, downscaled pixels can't be retrieved; mitigation: the injected `image_full` tool lets the model restore the original resolution for the rest of the session when it can't read details (sticky, idempotent; the restore persists across restarts with the shrink records). No proxy-side original storage is needed: the client's own history still carries the original bytes (it never saw the shrunk form), so a restored ref simply stops being re-routed and the original rides the wire again. Per-image savings log as `[acp-image] …` lines and aggregate into the `[acp-usage]` suffix (`img-saved=Ntok/MKB xK`). Sub-fields (merged deepest-wins like every other CompressSettings field):
- `enabled: boolean` — master switch; anything other than `true` keeps the feature fully off (byte-identical pass-through, no `image_full` tool on the wire).
- `minTokens: number` — only route images whose billing-aware token estimate ≥ this (kernel default `512`).
- `maxDimension: number` — longest side (px) of the downsample recipe (kernel default `1280`).
- `quality: number` — lossy encode quality 1–100 of the recipe (kernel default `80`).
- `format: "webp" | "jpeg" | "png"` — encode format of the recipe (kernel default `"webp"`).
All four wire carriers are rewritten at the forward boundary: Anthropic `image` blocks, OpenAI `image_url` parts (including single-string data-URL messages; remote URLs are never touched), Responses `input_image`, and Google `inlineData`. Determinism contract (same invariant as CCR #1097): the substituted-at-arrival bytes ARE the standing wire content — a guard refuses to re-route any payload that isn't a known original fingerprint for an already-shrunk ref, so processed messages re-entering the pass (fold re-requests) can't double-shrink and bust the prefix cache. Note the kernel's pixel-tile token estimate is coarse and capped (~2k tokens for large screenshots): a shrink may save real wire bytes while saving zero estimated tokens — both numbers appear in the log. Fingerprint bookkeeping is memory-only (not persisted): after a proxy restart, previously shrunk (non-restored) refs pass through at original resolution until the session resets — the double-shrink guard won't re-route payloads it can't verify as known originals, so savings for those refs pause rather than risk a double-shrink (a reset clears the records, so they re-shrink deterministically on the next arrival); previously restored refs stay restored. v1 scope gate: **proxy mode only** (plugin agents would need `image_full` advertised in their plugin manifest first). Requires `acp-kernel` >= 0.0.84 and the optional `sharp` package for actual shrinking (without it every image passes through unchanged).

#### `rules`

- **Type:** `boolean`
Expand Down
Loading
Loading