# Changelog

## 1.6.0 (2026-09-26)

- Retire the spend guard. It rewrote requests behind Pi's back (a digest plus a
  20K tail from half the context window, so models silently lost their working
  context and the prompt cache), paused sessions with errors only a human could
  clear, blocked manual `/compact` on large sessions, and published pauses its
  own auto-heal never cleared, which kept goals and subagent dispatch blocked.
  Removed with it: the managed-child lifetime allowance (8M cache-inclusive
  tokens, hard stop). Requests now carry the full history Pi built; context
  limits are Pi's compaction, which stays mechanical when automatic.
- Kept: a cap on any single tool result over 160K characters, applied per
  request, so one unbounded output cannot wedge a session.
- Compatibility: sessions whose last guard record is not `ready` get one
  closing `ready` record, so pi-codex-goal, pi-subagent-extension and
  pi-message-sidebar stop honoring a pause nobody can clear. `/mantice-guard`
  and `/mantice-child-budget` remain as no-ops because the subagent preflight
  requires them in every child.
- CI now builds and tests against Pi 0.87.1, the release users run; the 1.5.0
  regression passed CI because it tested 0.85.1.

## 1.5.1 (2026-09-26)

- Spend guard keeps the system prompt and tool declarations when it reduces a
  request. Pi 0.86 moved both into the transcript's leading `system` message;
  the guard's digest replaced `messages[0..cut]` wholesale, so from the first
  reduction onward every request in the session went out with no instructions
  and no tools (GPT answered that it had no tools, GLM ran away). The guard now
  folds conversation only and restores the system messages, in order, ahead of
  the digest. Checkpoints written by 1.5.0 under Pi >= 0.86 no longer match the
  conversation prefix and are discarded, so affected sessions heal on the next
  request after a restart. The estimate also counts tools declared in system
  messages.

## 1.5.0 (2026-09-26)

- Re-vendor pi-subagent-extension from 1016b93: the packaged
  `fornace-model-routing` skill is dropped (1.2.0). The user-level skill at
  `~/.pi/agent/skills/` (distributed by pi-setup) owns the routing contract;
  the bundled copy collided with it at every startup and had drifted stale.
  `pi.skills` no longer points into `node_modules/pi-subagent-extension`.
- Bundles pi-message-sidebar 2.2.0 (vendored from e1c37f6): the FILES list can
  no longer squeeze MESSAGES below three visible slots (a 127-file edit list
  took ~25 rows and left one message); FILES is capped at six rows idle,
  twelve while browsing, with `… N more` truncation rows; focusing the rail
  and pressing `f` enters hierarchical files navigation (`↑↓` move, `↵`/`c`
  copy the path, `Esc` returns to messages); and the session identity leads
  with the stable cmux role id bound to this surface's UUID in the cmux-role
  registry (fallback: the dynamic `surface:N` ref), read from the durable
  `CMUX_SURFACE_ID` env without a subprocess.

## 1.4.7 (2026-09-15)

- Spend guard truncates oversized tool results in the projected request instead
  of pausing the session. A single unbounded tool result (a 929,590-token
  `fast_read` of an SDK header) previously made the request irreducible —
  reduction keeps the newest tool batch whole — and the guard paused mid-goal.
  `truncateOversizedToolResults` caps any individual tool result at 40K tokens
  in the projected request only (first 8K + last 2K chars, toolCall pairing
  intact, placeholder names the original size and the recovery path). The
  session file keeps the full original.

## 1.4.6 (2026-09-14)

- Spend guard no longer counts `cacheRead` towards spend-pace (`recent`) and
  cumulative token thresholds. Sessions with hot prompt caches (e.g. 80k-120k
  cached tokens on Gemini/Anthropic) were previously accumulating millions of
  apparent tokens within minutes, triggering `token rate soft threshold`
  compaction and blowing away provider prompt caches. Compaction now only fires
  on high un-cached throughput (`input + output + cacheWrite`) or when total
  context length legitimately exceeds soft limits (`context soft threshold`).

## 1.4.5 (2026-09-14)

- Work never stops on mechanical reduction failures or stalled reductions when
  the request fits within the model's actual context window.
- Interrupted tool calls (where a user sent a message while a tool was
  running or after aborting it) no longer crash compaction with `incomplete
  retained tool batch`. Abandoned calls are safely cleared so user
  interruptions never brick sessions.
- Incomplete, unpaired, or unfinishable tool batches no longer throw fatal
  errors during compaction.
- If mechanical reduction fails or stalls (e.g. freeing < 10% or irreducible
  tail), but the request fits within 80% of the model's context window, the
  guard admits the request unreduced with a warning instead of pausing.
- Non-child pauses auto-heal on session restore and prepare: sessions paused
  under older versions immediately resume work on reload or next message.
- Malformed durable guard records are safely ignored instead of pausing.

## 1.4.4 (2026-09-14)

- Checkpoint prefix mismatch no longer pauses the session. A checkpoint is a
  caching optimization for projected request history; if message metadata or
  branch history differs between turns (e.g. Pi populates `usage`, reorders
  keys, or deserializes from disk), the cached checkpoint is simply invalid.
  The guard now silently discards the stale checkpoint and re-evaluates the
  full context, creating a fresh checkpoint only if context limits require it.
  Sessions paused under prior versions with `checkpoint prefix changed`
  automatically clear to `ready` on restore or request admission without
  requiring `/mantice-guard retry`.

## 1.4.3 (2026-09-14)

- A repair retry now re-evaluates the spend thresholds from scratch instead
  of demanding a verified reduction unconditionally. When the repaired
  request fits every threshold (for example after the 1.4.2 estimator fix
  removed a false positive), the retry admits it and clears the pause.
  Forcing a reduction anyway dead-ended the retry on the newest tool batch
  and re-paused a session with nothing left to repair. Threshold-triggered
  retries still compact as before.

## 1.4.2 (2026-09-14)

- Images no longer count at base64 wire size. A session that attached
  screenshots (4.3MB of base64 across three images) estimated over one
  million request tokens and hit the spend guard pause five times over the
  200K limit, stopping work on spend that never happens: providers bill the
  decoded raster, not the base64 encoding. The estimator now walks content
  blocks the way pi itself does, counting each image at a fixed 4800 chars
  (1200 tokens) and each thinking or tool-call block at text weight, with
  system prompt and tool schemas estimated separately.

## 1.4.1 (2026-09-14)

- Spend-pace triggers no longer pause the session when reduction cannot
  shrink the request. A long automation session crossed the 8M cumulative
  token threshold with a request already far below the context limit;
  mechanical reduction had nothing left to fold away, so the guard paused
  forever with an unrepairable cause and every retry re-paused identically.
  Work stopped with no way out. Cumulative and five-minute throughput
  thresholds now attempt the reduction as a token saving and, when it stalls
  or the request is one indivisible tool batch, admit the request unreduced
  with a visible warning: the request fits, so it runs. Only a request that
  genuinely cannot fit the context limit still pauses, with its named
  blocker. Pace admissions cool down for one rate window so a session over
  the lifetime threshold does not re-attempt or re-notify on every request.

## 1.4.0 (2026-09-14)

- A tool result's `details` no longer counts against the request estimate.
  Providers transmit `content` only; `details` is local render state that Pi
  persists in the session file. A 537KB image left there by an image tool added
  716,624 base64 characters — about 179,000 tokens — to every later request in
  that session, and paused a live session at 232,770 estimated tokens while the
  provider was billing 48,999. Replaying that session's messages: 347,604 tokens
  before this change, 131,083 after.
- `mechanical reduction made insufficient progress` is gone. A stalled reduction
  now reports what it measured (before, after, limit) and which of three things
  blocked it: one retained message too large to fold away, named by tool and
  clock time; the system prompt and tool schemas alone over the limit; or a
  diffuse tail with no dominant message.
- Every pause carries its own recovery instruction and persists it, so the
  repeat error on each later request says the same specific thing. Pauses that
  `/mantice-guard retry` cannot clear now say so and name `/tree` or `/new`
  instead — reduction never drops the newest tool batch, so retrying a pause on
  a message inside it stalls identically.
- `no reducible history before retained tail` now reads `the request is already
  one indivisible tool batch`, with the matching recovery.
- A paused record stores the size the stalled reduction actually reached instead
  of carrying forward the previous `after`.

## 1.3.0 (2026-09-13)

- Keep provider failures in Mantice routing instead of treating six errors as
  evidence for request compaction.
- Emit `budget_yield` when a managed child reaches its durable token tranche so
  the parent can continue from partial work without blocking sibling admission.

## 1.2.1 (2026-09-13)

- Encode `fast_read.level` as a string enum. Gemini subscription requests no
  longer receive unsupported `const` fields from this tool.
- No routing, pricing or automatic-guard policy changes in this hotfix.

## 1.2.0 (2026-09-10)

- New `fast_session` tool: the agent-callable twin of `/fast session`. It
  arms the mechanical gate mid-turn and fires the exact same compaction
  path on the first idle `agent_settled`, so it never aborts an active
  run. While armed, threshold and overflow auto-compactions also turn
  mechanical (zero model calls). Agents should call it at ~50% context
  usage and then finish their reply.
- `MechanicalGate` gained a `has()` probe so the tool trigger can tell an
  armed gate from one already consumed by an auto-compaction.

## 1.1.1 (2026-09-08)

- Resolve Chat Completions and Responses through Pi's bundled API factories.
  Installed packages now load and stream with host-provided Pi dependencies.
- Pass the host-resolved Chat Completions transport into admission recovery,
  preserving its retry and cancellation behavior.
- Run existing wire verification from the packed artifact in CI and publishing.
  Correct the fixtures' required `max` catalog alias and surface catalog warnings.

## 1.1.0 (2026-09-08)

- Two-stage compaction: `/fast session` now performs stage 1 mechanically
  (deterministic bounded digest, zero model calls, millisecond scale) and
  `/compact` remains Pi native, receiving the pruned payload. The flash-chain
  summarizer, chunking and part checkpoints were removed with it.
- New `fast_read` and `fast_write` RTK tools for cheap filtered file reads
  and write receipts.
- Fixed a dead customInstructions injection: Pi 0.85.1 never read back
  `session_before_compact` mutations, so pruning markers now live in the
  pruned messages themselves.

## 1.0.1 (2026-09-03)

- CI: declared `@types/node` as a dev dependency so `npm ci` typechecks on a
  clean install; the v1.0.0 tag workflow failed at typecheck before reaching
  publish. No runtime changes.
# Changelog

## 1.0.0

- Live capability-aware catalog (absorbs fornace-pi-models a2a63f7).
- Flash-chain compaction with usage accounting and cancel-before-max policy.
- Canonical overflow mapping including Z.ai 1261; route/backend change notices.
- /mantice-setup onboarding planner (see docs/PLAN.md M4).
