Files
deepseek-harness/packages/compaction/compaction-basic
涂轶翔 101f26de4e fix(system-prompt): 保留 section API 的增量系统指令 (#6941)
* feat(system-prompt): admit section updates incrementally

* docs(system-prompt): accept retirement restart gap

* test(system-prompt): cover retirement and reentry before admission

* test(system-prompt): align rebase fixtures and persistence history

* fix: align section prompt consumers and CI fixtures

* test: pin credentials for section snapshot fixtures

* test: align remaining snapshots with section admission

* test: preserve section metadata in Web and PowerShell replays

* refactor(system-prompt): retire sections through Cordis cleanup

* chore: refresh section admission history after rebase

* fix(system-prompt): advance admission head after compaction

* fix(system-prompt): trim sections before admission hashing

* docs: move system upgrade guides to current version

* docs: add system message contribution cookbook

* perf(system-prompt): avoid indexing history for admission

* refactor(system-prompt): derive admission from logged sections

* test(system-prompt): update lifecycle and compaction consumers

* test(system-prompt): refresh CLI section event expectations

* test(system-prompt): refresh question composer section metadata

* feat(system-prompt): resolve same-name sections by scope

* refactor(persona): use ordinary section registrations

* refactor(system-prompt): clarify assembly and related control flow

* test(system-prompt): reconcile rebased section snapshots

* test(python): use current system text helper after rebase

* test(system-prompt): refresh CLI expected section blocks

* test(system-prompt): reconcile latest master integration

* test(agent-loop): seed tools before deferred addition assertion

* refactor(compaction): replace system heads when compacting prefixes

* refactor(system-prompt): separate source text and notice attribution

* fix(system-prompt): preserve legacy instructions in compaction snapshots

* refactor(compaction): build system snapshots while reading the summary prefix

* refactor(compaction): rebuild current system instructions

* refactor(system-prompt): defer compaction rebuild to admission

* refactor(system-prompt): remove redundant fixtures and setup

* fix(plan-mode): announce committed user transitions

* docs(system-prompt): reconcile section lifecycle and compaction design

* refactor(system-prompt): consolidate projection version increments

* fix(system-prompt): reconcile master integration and replay fixtures

* docs(system-prompt): align upgrade guide with current release

* refactor(system-prompt): make admission operations explicit

* fix(system-prompt): reconcile master API and release changes

* docs(system-prompt): regenerate catalogs after master refresh

* refactor(llm-pi-ai): delegate text rendering to pi-ai

* fix(llm-pi-ai): preserve blank lines between system text parts

* refactor(system-prompt): remove redundant retirement metadata

* refactor(system-prompt): own admission and use canonical surface targets

* refactor(system-prompt): compare captured sections at commitment

Assembly fixes section text and lifecycle; PromptAssembly.systemUpdates() compares them with the committed projection when the loop commits. This replaces SystemPrompt.admit(), needsRebuild() and isCurrent(), the SystemAdmission export, the loop's reassembly after compaction, and SessionSurface.systemHeadResetSeq. The projection records a pending rebuild as a boolean that an attributed reset clears.

After a compaction inside a step, the rebuilt head uses the sections captured for that step; later source changes arrive as ordinary updates at the next step.

* test: await the session read fixture and type a matcher for lint

* test(tool-executor-ptc): describe same-name section override on executor replacement

Duplicate section names no longer reject a scoped executor; the earlier registration is overridden and returns as an ordinary update when the executor leaves.

* docs(upgrade-guide): move system-prompt integrations to v0.2.2-rc.3

The root version on master is 0.2.2-rc.3; verify-upgrade-guides rejects a guide added under an earlier version directory.

* refactor(system-prompt): rebuild over system messages without sections

A system message without source.sections now marks rebuilding pending, like a compaction summary. The next model attempt replaces the head with current sections and clears later system messages. This removes the separate legacy flag and its appended whole-prompt replacement and notice.

Sessions written by earlier releases, migrated logs, and imported DeepSeek conversations take the same path, so the importer and its tests return to their master versions.

* test(web): refresh the imported-conversation recording and drop a stray bytecode file

The Web recording for a resumed DeepSeek import was recorded while the prompt was appended after the imported history; the head is replaced again, as on master. The .pyc under the macOS signing skill was staged by accident in an earlier merge.

* refactor(session): scan system nodes on read

surface.systemNodes is read only when a system rebuild is written. Scanning the current surface nodes on each read restores the surface fold's plan types and state to their master definitions, which no longer carry the system message.

* refactor(session): rename SystemSurfaceNode.hasContent to isEmpty

The flag reports that the logged content array has no blocks. isEmpty matches the documented "empty head" wording and covers a head that was written empty without ever being cleared.

* refactor(llm): join system text through extractTextContent

extractTextContent gains a trim option that trims each text block and omits blocks left empty. The DeepSeek serializer, the pi-ai converter, and the prompt inspector use it with a blank-line separator in place of three hand-written joins.

The pi-ai converter now trims system and developer text like the other two, so whitespace-only blocks are omitted there as well.

* test(snapshots): refresh the PowerShell and cordis-inspect recordings

The two PowerShell scenarios still held the initial system message as one unattributed block; replay now writes one block per section with its attribution. The cordis-inspect-jsdoc recording embeds the API catalog, which names SystemSurfaceNode.isEmpty since the rename.

* test(plan-mode,harness-dev-context): cover a rejected pre-step and a repeated legacy prompt

A rejected pre-step must leave a queued plan-mode switch pending and unannounced until the next accepted step. A second unattributed system message with the same legacy paragraphs must keep the admitted paragraphs.

* test(web): refresh Web recordings for section-attributed system messages

Twenty-seven Web recordings still held the initial system message as one unattributed block. Replay now writes one text block per section with its attribution; twenty-six recordings differ only in that line.

plan-review also records the plan-mode switch notice before the first prompt and appends a plan:status update on exit in place of a head replacement and a series header, so its expanded golden gains the notice row.

The Creator persona test joins the system text blocks with blank lines, as the adapters do, before matching the persona line.

* refactor(system-prompt): require the retry argument of systemUpdates

The agent loop passes it on every attempt. A custom loop that omitted it on a retry received a full comparison in place of the pending rebuild, with no diagnostic; the type now makes each caller state which attempt it is.

* docs(upgrade-guide): move the system prompt integrations guide to v0.2.2-rc.5

The root version is 0.2.2-rc.5 after the master merge, and verify-upgrade-guides rejects a guide added under an earlier version directory.

* test(web): refresh the mention path presence recording for section-attributed system messages

* test: align two specs that master left failing

The DeepSeek settings spec waited for a saved notice carrying the provider label from before the rename to DeepSeek API. The Windows packaging workflow spec seeded one of the two helpers that the Stage workflow helpers step copies.

* chore: remove a Python cache file committed by mistake
2026-11-19 21:11:38 +08:00
..

description, kind
description kind
Automatic conversation condensation for deployments choosing, tuning, or debugging how older history is summarized as token pressure builds. package-reference

@deepseek-ai/dsh-compaction-basic

English | 中文

Summary

This package keeps long agent conversations working near the model's context limit. As token pressure builds, it condenses the oldest history into a summary while preserving recent messages; after a context-overflow error, it condenses and retries. You can also request condensation with /compact and optionally trim oversized tool outputs first. Condensation uses one extra model request and retains only its summary text. It cannot reduce the system prompt, tools, or session prefix, or split one indivisible unit such as a single huge tool call.

Table of Contents


Use this package

Mount this package to get automatic conversation condensation in a composition that already provides an LLM, session storage, and token measurement. The shipped dsh base enables it by default; mount it explicitly to control when condensation starts.

What you get

With the default settings you get four behaviors: automatic condensation as the conversation grows toward the model's context limit; recovery after a confirmed context-overflow error, where the conversation condenses and the request retries; on-demand condensation through the /compact command; and — when the pruner is mounted — trimming of oversized tool outputs before condensation.

Smallest working composition

Mount session storage, token measurement, the optional pruner, this backend, and optionally the on-demand command:

- name: '@deepseek-ai/dsh-session'
- name: '@deepseek-ai/dsh-token-meter'
- name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
- name: '@deepseek-ai/dsh-compaction-basic'
- name: '@deepseek-ai/dsh-command-compact'

You can verify success by watching the conversation continue past the point where it would otherwise overflow, and by running /compact for an immediate condensation. If the composition lacks an LLM, session storage, session projections, or token measurement, the plugin fails to load. One backend can serve models with different context sizes; give each route its own threshold and retention with a per-model override:

- name: '@deepseek-ai/dsh-compaction-basic'
  config:
    thresholdRatio: 0.8
    retainRatio: 0.16
    modelPolicies:
      - provider: local
        model: small-context
        thresholdRatio: 0.7
        headroomTokens: 4096
        maxTokens: 4096
        retainTokens: 2048

Tuning when condensation starts

All settings are optional. With context window W, effective request output cap O, and headroom B, the default trigger is floor(min(W × 0.8, W − O − B)), where B = 65,536 tokens. Retention keeps the newest 16% of W − O verbatim. The table below lists every setting; the generated configuration catalog also includes their types.

Field Default Meaning
thresholdRatio 0.8 Window fraction used in floor(min(W × thresholdRatio, W − O − headroomTokens)).
headroomTokens 65536 Additional pressure headroom beyond the routed output reservation; a non-negative integer.
retainRatio 0.16 Recent conversation kept verbatim as a fraction of W − O; mutually exclusive with retainTokens.
retainTokens — Absolute recent-conversation budget kept verbatim; mutually exclusive with retainRatio and must be below the resolved threshold.
summarizationProvider '' Set together with summarizationModel; an empty pair uses the model that produced the latest assistant message, then the latest routed request target, then the AgentOptions pair.
summarizationModel '' Set together with summarizationProvider; an empty pair uses the model that produced the latest assistant message, then the latest routed request target, then the AgentOptions pair.
maxTokens headroomTokens (65536) Positive summary output cap, including any provider-counted reasoning tokens. Explicit per-model caps override explicit global caps; otherwise the cap follows the resolved headroom.
compactionRetries 1 Extra condensation attempts after the first when pressure remains above threshold.
maxOverflowRetries 1 Maximum retries after a confirmed context-window overflow; 0 disables recovery only.
modelPolicies [] Exact { provider, model, ...partialPolicy } overrides for individual model routes.
auto true Enable automatic condensation and overflow recovery; set false for manual-only operation.

Misconfiguration fails fast: unknown settings, duplicate per-model overrides, invalid token counts, both retention forms together, or a retention ratio at least as large as the threshold ratio reject the plugin at load. When the model is first used, W − O − B must be positive and the resolved retained budget must be below the trigger. Zero headroom requires an explicit positive maxTokens, globally or in that model policy. Small-window deployments must configure headroom that fits their capacity; lower thresholdRatio to compact earlier.

What happens when condensation runs

The oldest balanced span is replaced by one summary message and the recent tail stays verbatim; the conversation continues from the summary. The operation reports how many history items were condensed and the estimated tokens freed. If nothing can be condensed safely — for example the whole conversation is one indivisible unit — nothing changes and nothing is written to the session log. If no model is available to write the summary (no configured target and no routed request yet), condensation fails with a clear error telling you to configure the summarization provider and model or route one request.

Switching models

Before a changed provider/model request is committed, automatic compaction measures the existing history against the destination model's capacity, output reservation, and pressure policy. Once the session holds an assistant message, every summary, including /compact and overflow recovery, goes to the model that produced the latest one and uses that model's summary settings; before the first assistant message the summary uses the latest request header and then the AgentOptions pair; a newly selected model is not used until it has answered, and an explicitly configured summary target still takes precedence. When the estimate admits a destination that then rejects its first request as too long, overflow recovery therefore summarizes on the model that last answered and retries the destination request. The destination request proceeds only after history falls below its threshold. Failure reports MODEL_SWITCH_COMPACTION_FAILED and leaves the previous request header intact; select a larger model or retry after correcting the reported cause. Completed pruning or condensation remains in the session even when a later attempt fails. The check runs when the next request is prepared, and auto: false disables it.

The destination must have a registered adapter, declared context capacity, and a valid pressure budget even for short history. The default 65,536-token headroom does not fit a window of that size or smaller; set modelPolicies[].headroomTokens for that route as in the example above. See the upgrade guide for migration.

On-demand condensation with /compact

With dsh-command-compact mounted, type /compact in a chat UI to condense immediately, even below the pressure threshold. The command reports how many history items were condensed and the estimated tokens saved. While the agent is mid-turn or condensation is already running, /compact reports that condensation is unavailable; prompts you send while it runs are accepted and start after it finishes.

Trimming oversized tool outputs

Mount dsh-compaction-tool-result-pruner before this package to trim oversized tool results as part of condensation. Trimming makes no model call and can remove the need to summarize at all: when the trimmed conversation fits within the threshold, condensation skips the summary. Trimming only runs after a condensation trigger qualifies — a below-pressure conversation is never touched.


Understand the implementation

Implementation internals — click to expand

This section explains the design decisions behind the backend; the observable behavior is fully covered in Use this package.

Design philosophy

The backend is built on four commitments:

  • One measurement service prices every decision. The singleton ctx.tokenMeter measures the latest canonical logged envelope and current surface at one consumed-log revision. When the routed adapter declares request-image pricing, the meter applies it to image history. Model-switch pressure, retention, and range selection use destination pricing; region shrink validation uses the last committed route; logged replacement shadow prices stay on the route-independent heuristic so pure projection folds remain consistent.
  • The log-recorded bracket is the transaction. All entry points share one bracket-first region transaction: validate the range and live lock, append compaction/start synchronously, prepare and await the summary, revalidate, append compaction/summary plus the replacement, and make exactly one closing attempt. Automatic and explicit-region calls require a numeric open-turn owner and whole-surface stability; compactNow() reserves idle admission, uses turn: null, accepts append-only context outside its selected span, flushes every closed attempt, and releases admission in finally.
  • Summarization reuses the provider's warm prefix. Replaying the system prompt held by the system/message at surface node 0, the last routed request's tools, and the shadowed-region messages byte-for-byte makes the auxiliary call a genuine prefix of the conversation, so only the trailing instruction and the summary output are uncached.
  • summarize() is the sole subclass hook. A template- or remote-summarizer subclass can override it while pressure, retention, cited source events, shrink validation, and shadowed-token accounting stay on the token meter.

Automatic triggers and overflow recovery

The agent/request listener waits for routing listeners to select the destination, then checks its pressure before the new header is logged. It uses compactPressure directly because compactIfNeeded reads the committed header; both paths generate summaries through summarize(), which reads the route recorded on the latest assistant message before the committed header because a request that failed has already replaced that header. A host-only session projection, compactionAnsweredRoute, holds that provider/model pair, so a restored session reads it from its checkpoint; the plugin registers the projection at construction and releases it on unload.

With auto: true, a serial agent/pre-step listener checks pressure before request derivation: it prices the latest durable routed request envelope through ctx.tokenMeter, and when pressure crosses the routed model’s threshold it prunes, then summarizes the oldest balanced span while keeping a priced recent tail. An explicit range can also start later in the conversation. Both ends must preserve tool-call/result pairs and the range must exclude the initial system message. The agent/request-error listener reacts to a provider-confirmed CONTEXT_WINDOW_EXCEEDED: it bypasses the normal threshold and retention policy, attempts one maximal balanced head reduction, and authorizes a retry only after the surface replacement generation advances. Cancellation stays authoritative throughout.

Pressure policy resolves capacity from the adapter that owns the durable route. Missing capacity, output plus headroom exhausting the window, or a retained budget at least as large as the threshold makes the manual pressure path throw a target-specific configuration error. The agent/pre-step listener warns once for that exact target and continues the turn; provider-confirmed overflow recovery remains available. Model-switch checks instead reject the request with MODEL_SWITCH_COMPACTION_FAILED, including when capacity or adapter lookup fails.

Summarization mechanics

A direct ctx.llm.stream() call uses the configured provider/model pair and cap, falling back to the model that produced the latest assistant message, then the latest logged request target, and then the AgentOptions pair, without running the loop-only agent/request extension point. The call replays the derived system/message at surface node 0 as the leading entry of messages, followed by the shadowed-region messages (including a shadowed in-history system/message in its surface position), and supplies the latest request header's active tools for route-specific projection, including when the summary goes to a different model than that header names. The selected adapter must resolve image references in the replayed messages or explicitly reject them. The call appends the compaction instruction as the final user message, preserving the provider's warm prefix where projection permits. An empty-content system head contributes no message but remains outside the compacted range. The final instruction is a frozen RequestUserInput without durable identity or source; the replayed history and persisted checkpoint remain durable messages. The call sets GenerateOptions.purpose to compaction; only returned text enters the checkpoint, excluding reasoning and tool calls. Image output fails with UNSUPPORTED_CONTENT rather than disappearing. The replacement user message frames the summary with <compacted-summary> tags; the raw summary remains on the compaction/summary event. The call also carries Session.toolHistory() so the runtime can project deferred and retained definitions; a prefix missing update messages uses active declarations without developer updates.

The region transaction

Failed summary requests dispatch synchronous compaction/summary-error after checking cancellation and selection stability. A recovery listener must record a durable input change before requesting retry. The backend re-derives the selected messages and refreshes their token prices and shrink baseline. The image-offload plugin owns image selection; its recorded omissions remain effective if the summary later fails or is cancelled.

After validating the range and durable lock, the transaction appends compaction/start. The summarizer receives the initial system message and the selected conversation as they appear on the surface. Compaction does not evaluate current system sources. The system-prompt service rebuilds the instructions from current sources before the next conversation model attempt, including a retry after overflow recovery.

The transaction checks that the whole surface (automatic calls) or selected range (manual calls) is stable and that the framed summary is smaller than the selected range. It appends adjacent compaction/summary and replacement user/message events. The initial system message and messages outside the selected range remain unchanged. Exactly one compaction/end attempt follows. An unmatched start before a newer session/end-seed is stale. An unmatched start after that boundary reports busy. Cancellation remains authoritative after cleanup and durability.

Config resolution

resolveConfig validates and detaches defaults, resolveTargetPolicy merges exact provider/model overrides, and resolveCompactSpec requires explicit adapter capacity and routed output reservation to resolve the trigger and retained budget. The effective envelope’s maxTokens supplies that reservation, falling back to the adapter default and then zero. Model discovery (listModels()) is never consulted for policy; capacity comes from the durable route or the proposed destination during a model switch.

Source map

File Role
src/index.ts Plugin entry: BasicCompactionEngine, automatic listeners, entry-point dispatch
src/answered-route.ts Host-only projection of the provider/model recorded on the latest assistant message
src/region.ts Retention selection and the shared bracket-first compaction transaction
src/summarizer.ts Default ctx.llm.stream() summarization, checkpoint framing, safe-summary projection
src/config.ts Load-time validation and routed-model policy resolution
src/types.ts BasicCompactionConfig and resolved policy vocabulary

The package root's type declarations add compaction to LlmRequestPurposeMap. Direct callers constructing compaction requests use import type {} from '@deepseek-ai/dsh-compaction-basic' so GenerateOptions.purpose includes that key.


Further Exploration

Read these pages when the package-level contract is not enough; they move from the shared seam to the optional companions and the decision evidence.


Model Experience

Conversation history

What the model sees

After a successful step crosses the threshold, the optional pruner first rewrites oversized tool results. If summarization is still necessary, the next request receives the current system instructions at the head and a checkpoint at the selected range. The checkpoint contains the preamble below, a blank line, <compacted-summary>, the returned summary, and </compacted-summary>. Other retained conversation messages keep their relative order. Overflow recovery derives its immediate retry from this logged history.

Conversation checkpoint preamble
This is an automatically generated checkpoint condensing an earlier span of the conversation to free up context. Treat the captured context as established background and build on it without restating it. Continue the task directly from the messages that follow, without acknowledging this checkpoint.

Token effect

Model-free pruning can avoid the auxiliary call entirely; otherwise it reduces that call’s transcript before the summary replaces an older range. The shrink check compares the framed summary against the selected range; it excludes subsequent system-prompt rebuilding, so it does not guarantee that the complete next request is smaller. A summary remains until a later compaction replaces it, while an indivisible non-tool unit can still exceed the budget.

KV Cache effect

A checkpoint invalidates prefix reuse from the first replaced history token. The next model attempt also rebuilds the system head; changed instructions can therefore invalidate reuse before the selected range.

Auxiliary summarizer request

What the model sees

The summarizer receives the logged system head and selected conversation with the route’s tool declarations and developer updates, followed by the compaction instruction below. The conversation model receives the new system head and summary on subsequent requests. The compaction instruction and the summarizer’s reasoning stay private to the auxiliary request.

Compaction instruction (final user message)
You are now acting as a compaction engine for this AI coding assistant. Condense the conversation ABOVE into a structured checkpoint that lets another model resume the work with no loss of essential context.

Output EXACTLY the Markdown structure below: keep every section, in order. Use terse bullets, not prose paragraphs. Write "(none)" for an empty section — never drop a section.

## Primary Request and Intent
- [the user's original and evolving goals; quote verbatim where the exact wording matters]

## Key Technical Concepts
- [technologies, frameworks, patterns, and conventions in play]

## Files and Code
- [exact path: why it matters, key changes or snippets]

## Errors and Fixes
- [error: how it was resolved, plus any related user feedback]

## Pending Jobs
- [explicitly requested work not yet completed]

## Current Work
- [precisely what was in progress at this checkpoint]

## Next Step
- [the single next action, directly in line with the most recent request, or "(none)"]

## Critical Context
- [decisions and their rationale, constraints, user preferences, open questions, data needed to continue]

Rules:
- Write concise English engineering prose. Preserve exact file paths, commands, error strings, identifiers, numeric values, function signatures, and syntax fragments.
- Capture user feedback and explicit instructions faithfully, especially corrections.
- Do NOT mention this summarization request or that the context was compacted.
- Output only the checkpoint text: do not call any tool or take any other action.
- If the conversation already contains a <compacted-summary> block, it is a PRIOR checkpoint. Do not copy it forward verbatim: preserve still-true facts, drop stale ones, and merge newer information into a single consolidated summary under the same structure.

Token effect

This is a separate model call: the replayed conversation prefix plus the fixed instruction as input, with maxTokens-capped output. Convergence retries can pay this cost more than once.

KV Cache effect

The replayed system prompt, tools, and shadowed-region messages match the conversation's last routed request byte-for-byte, so the provider's warm prefix cache is reused up to the trailing instruction; only that instruction, and the summary output, is uncached. Routing the summarizer to a different provider/model, or compacting a non-head range, forgoes this reuse.

Known Limitations and Deferred Work

These limits define when automatic condensation is a poor fit or needs special care; they are the current package constraints.

  • Meter accuracy follows the fixed heuristic — missing reusable provider usage falls back to character count plus structural overhead rather than exact tokenization; image occurrences carry provider-exact visual tokens only on routes whose adapter declares request-image pricing.
  • An unavailable answering model is not skipped — the summary goes to the model that produced the latest assistant message even when that model can no longer serve requests, for example after its credentials were revoked or its quota ran out. Until the newly selected model has answered once, /compact and pressure compaction fail on that model; send a prompt so the new model answers, or configure summarizationModel.
  • A summary request is not split — when the summarizing model cannot hold the selected range plus the instruction, for example after its own history overflowed, the summary request fails and no checkpoint is written; configure a larger summarizationModel.
  • Overflow classification is adapter-maintained — provider wording can change; both DeepSeek adapters normalize recognized context-limit failures to CONTEXT_WINDOW_EXCEEDED.
  • Some indivisible-unit and envelope-only overflow remains outside surface compaction — recovery cannot shrink system/tools/prefix, split an indivisible non-tool node, or repair a tool unit whose non-prunable remainder still exceeds the window. The optional pruner can shrink text-bearing tool-result bulk inside an otherwise indivisible pair.
  • compactRegion requires an open turn — a manual call on a fully-closed session throws ("no open turn") rather than compacting.
  • Summarization failure preserves the latest durable surface — pre-step pressure logs a warning and continues; model-switch pressure rejects the destination request. Completed pruning and earlier checkpoints survive either failure. Summarization truncation at maxTokens, which hidden reasoning tokens can consume, follows the same rule.
  • Cross-model image pricing can reject a useful summary — switch range selection uses destination pricing, while shrink validation uses the committed route. Different image prices can make a summary fail shrink validation even when it would reduce destination pressure.

Dev Note

Working context for maintainers — click to expand

This Dev Note is working context for maintainers and is explicitly non-authoritative; shipped behavior lives in the sections above, the package code, and the linked Agent Notes.

  • Default ratios, undecided — thresholdRatio: 0.8 and retainRatio: 0.16 are fixed defaults; per-model tuning via modelPolicies exists, but no corpus-backed guidance on ideal values is recorded.
  • Tokenizer-accurate measurement, deferred — the token meter's four-characters-per-token heuristic underprices CJK text and JSON Schema documents; exact tokenization remains an open direction for the measurement service.
  • Overflow recovery beyond canonical errors, undecided — recovery triggers on CONTEXT_WINDOW_EXCEEDED only; other provider-side context failures are not classified.