Skip to content

v0.42.0

Choose a tag to compare

@github-actions github-actions released this 12 Sep 12:22
· 90 commits to master since this release

v0.42.0

Migration / breaking

  • The shared database schema version advances from 83 to 84. The upgrade adds persisted protected-token floor state to session_meta. Stop and restart all Magic Context instances sharing the database, including OpenCode servers, Pi and Oh My Pi (OMP) processes, and instances in other projects. A running older instance can block migration; after migration, a 0.41.x build (schema version 83) refuses the database rather than silently running without context management. Update pinned installations as well as the CLI. Run npx @cortexkit/magic-context@latest doctor --force if an installation remains stale. Downgrading the plugin alone does not downgrade the database.
  • protected_tags is deprecated and ignored. Use the integer protected_tokens setting, or omit it to derive protection from the usable context window. There is no tag-count-to-token-count conversion. Existing settings produce a deprecation warning. Explicit token floors accept 4,000–1,000,000 tokens.
  • The sidekick agent and /ctx-aug are removed. The old sidekick config block, including entries inside user profiles, is ignored with a warning. Remove it from configuration; setup and dashboard controls no longer offer it. Historian, dreamer, ctx_search, and automatic search remain available.
  • Agent-facing tool definitions change. The ctx_note/ctx_search/ctx_memory surfaces change through bulk note dismissal, search guidance, and removal of sidekick-specific behavior. Budget for one priced prompt-cache bust per session on the first turn after upgrade as the tool definitions change; this is an upgrade transition, not a recurring per-turn charge.
  • The mid-turn hold is removed. Eligible context work no longer waits for a tool loop to end. Automatic reclaim still needs an independently authorized cache-busting pass; open tool calls remain protected.

Token-based recent-context protection (#423)

Recent context is protected by token mass rather than by a fixed number of tags, so a few large outputs and many small outputs no longer receive the same effective window. The default is 5% of the usable context window, with a lower bound of 16,000 tokens (or 8% of the window when that is smaller) and an upper bound of 64,000: 8,000 tokens at a 100k usable window, 16,000 at 200k, and 50,000 at 1M. Protection follows persisted tag chronology and retained original token sizes. Floor snapshots keep the effective window stable between priced passes, including across restarts. Status and hygiene reporting use token-window measurements. The newest three ctx_reduce examples remain protected independently of the configurable window.

One cache-bust decision for context work

Automatic age cleanup, deduplication, compression, reasoning clearing, queued reductions, synthetic todos, and published-history refreshes are coordinated behind a shared cache-bust decision rather than creating separate cleanup-driven cache busts. Force-pressure episodes survive the temporary usage dip caused by their own reclaim batch, avoiding repeated originating cleanups during the same pressure episode; a batch that reclaims nothing does not consume an episode, and the ≥95% emergency escape bypasses a consumed episode on OpenCode and Pi as it already did in the Rust module. Rust protection is applied per tool arc, so a protected result can no longer strand its dropped call past emergency. Pending historian publications and compaction-marker moves are distinguished from actual prefix corruption. Contention recovery keeps the last consistent replay state instead of adopting partial work.

Reasoning and content-strip replay now retain exact applied parts and IDs across marker movement, projection changes, and restarts. Native reasoning migration is retired only after its replacements are confirmed active; re-exempting content waits for a priced pass. Pi preserves its served prefix when native compaction is cancelled, and reminder and seam-marker stripping is frozen for replay.

Safer dropped-tool inputs (#431)

Dropped tool arguments are rendered as inert placeholders instead of keeping executable-looking argument values. OpenCode and Pi reject copied dropped-placeholder inputs before tool execution and direct the agent to ctx_expand to recover the original arguments. The guard matches the placeholder shape rather than rejecting unrelated prose containing the word “dropped.” Existing render transitions are priced rather than silently changing a deferred prefix.

Large-session responsiveness (#437)

Post-compartment cleanup now walks only through the published boundary in bounded pages and yields between pages, rather than synchronously hydrating every stored part in the session. Tool invocation ownership survives page boundaries. Pi's cleanup converter likewise avoids materializing the rest of the branch. The separate per-message part lookup used by the incremental FTS indexer during streaming is hardened with an explicit selectivity hint so its plan no longer depends on planner statistics, and its per-event re-reads are coalesced to one read per message.

Steady-state transforms coalesce storage reads across OpenCode, Pi, and Rust, hydrate only needed dropped-tag rows, and reuse stable-prefix snapshot digests. Decay rendering uses incremental exact token counts instead of repeated full-prefix tokenization. Rust adapters avoid repeated hot-path store discovery and ordinal reads.

Pi: dropped tool calls now leave the request

On Pi and Oh My Pi, a tool call dropped in "full" mode kept a placeholder pair on the wire indefinitely; a long session on a 272k Codex window carried ~1,400 such pairs (~470 KB) and hit "input exceeds the context window" with nothing left to reclaim. Full drops now remove the whole call/result pair (including the native Responses item) on the next priced pass, with the newest 20 keeping their placeholder as before; open tool calls and signed-reasoning turns on Anthropic keep their pair. Existing sessions upgrade on their first priced pass, never on a cached one. Related fixes in the same incident: a provider usage reading above the model's absolute window is now clamped and treated as pressure (it used to be discarded, leaving the scheduler on a stale reading), the historian trigger sees the same pressure the scheduler does, the hygiene ratio counts surviving placeholders, reclaim hints are re-checked at delivery so already-dropped tags are never offered, and the ctx_reduce acknowledgement distinguishes already-dropped from already-queued tags.

Historian and dreamer reliability (#432, #435)

  • Completed curate runs with successful ctx_memory operations no longer fail merely because the final assistant response has no text. Pending, errored, aborted, or timed-out tool calls still do not count as completed work. Progress reports show applied memory-operation counts.
  • Pi/OMP subagent usage is captured from child events and persisted for dashboard reporting instead of recording every run as 0/0. This records new runs; it does not reconstruct past ephemeral children.
  • Historian trigger skips retain their reasons instead of repeatedly retrying an unchanged filtered tail. Filtered tails no longer manufacture budget overflow, unresolved model fallbacks are cached, stalled coverage repair is bounded by publication progress, and wrapup final-window promotion is corrected.
  • Child sessions are retired only after prompt settlement. Timed-out or unresolved children are hidden and left for deferred cleanup instead of racing detached host writers.
  • Passive startup and status notices use notifications rather than injecting user-role turns. Ignored-message rollback failures, including HTTP 409, are consumed rather than replaying a notice storm.

Context limits and recovery (#56)

Successful provider requests can invalidate stale detected context limits when real input usage disproves them. Model-scoped proof is kept distinct from the emergency input wall and bounded by trusted hard limits. Pi's raw fallback after transient storage failure is checked for fit instead of sending an over-limit request, and Pi's fail-closed refusals now stop the turn: Pi ignores exceptions thrown from context hooks and continues with the original messages, so refusals are delivered as a visible retry entry plus an abort of the in-flight turn instead of a thrown error. Last-known-good replay on Pi checks its appended raw tail for fit before serving it. Rust state synchronization resumes from boundary-scoped state without closing clients shared by other sessions, and partial mirror drains are not marked complete.

Notes, search, and embeddings

  • ctx_note accepts note_ids for bulk dismissal, with matching schema fields across TypeScript, Pi, and Rust.
  • ctx_search guidance now asks for natural-language questions that retain the exact paths, symbols, config keys, or error strings expected in the answer, rather than bare keyword stacks. Note-search relevance is calibrated alongside the guidance update.
  • The Synapse embedding client accepts the current models.list capability descriptor and batch/token-limit contract, retaining model/artifact identity checks. Shadow backfill no longer repeatedly resubmits unchanged stalled batches.
  • Mural caching includes the effective image-support verdict so SDK capability changes invalidate stale results.

Community contributions

  • Oh My Pi native replay for Codex (#433, @SilentBless). On OMP, Codex replays the assistant's providerPayload.items as authoritative native history, so Magic Context reductions on assistant.content never reached the wire. Reductions now apply to the native replay with a durable, priced activation, optional Codex reasoning retention, and clone-remapped state. Native replay state lives in a versioned document inside an existing session-metadata field; no schema change. Deployment boundary: the format is not backward-readable. A pre-0.42.0 Pi/OMP process reading a session that has activated native replay loses its trailing-blank decisions (replay bytes change), and a pre-0.42.0 writer erases the nested state. Restart all Pi/OMP processes on a host together when upgrading, and do not downgrade a session that has activated native replay.
  • ctx_memory update honors category (#436, #438, @G0-0000). Recategorizing a memory works in both the TypeScript transform and the Rust transform mode, with duplicate detection inside the update transaction on both SQLite backends (Bun and Node), and the recategorization rendered in the <memory-updates> delta.

Dashboard and diagnostics

A separate dashboard release is needed alongside the plugin release. Since dashboard 0.15.0, its sidekick panel and profile fields have been removed; log views accept both current and legacy log formats, including opaque message prose and quoted field suffixes; OMP diagnostics and OpenCode database-path discovery have been improved. New Pi/OMP usage records appear in the existing invocation views. protected_tokens is currently raw-JSONC-only and debug_rpc is deliberately not a form control.

User-only debug_rpc enables local process-memory and heap diagnostics; heap snapshots are refused above a resident-memory ceiling. New attribution tools cover native memory, cache-bust request/response correlation, replay differences, and nudge gating. Slow SQLite writes carry transaction-site attribution to identify contention sources.

Also

  • Documentation folds the former How it works page into Overview and Context reduction, preserves its old URL with a redirect, and explains session lifecycle and cache behavior without the removed mid-turn hold.
  • The clone-session script preserves merged_reasoning_stripped_ids.
  • Claude Code assistant tags are minted on first sight, with late-tag epoch handling scoped to that serializer profile.
  • TUI hygiene text is shorter and no longer includes duplicate footnotes.
  • Shared storage remains machine-scoped; MAGIC_CONTEXT_STORAGE_DIR selects an alternate storage root.
  • Memory mirrors in the Rust transform mode now carry their original timestamps; mirrored rows no longer land with a 1970 created_at.
  • Dependency locks include @cortexkit/subc-client 0.11.1 (TypeScript), subc-core 0.17.37, and subc-protocol 0.19.1.