Releases: cortexkit/magic-context
v0.10.1
🛠 Fixes
Embedding crash under concurrent load (#21) — fully reproduced and fixed on two fronts:
-
Native runtime upgrade. Bumped
@huggingface/transformersfrom~3.7.6to^4.1.0, which pulls inonnxruntime-node@1.24.3with native librarylibonnxruntime.1.24.3.dylib. That's a ~2.5-year jump over the old1.14.0.dylib(Feb 2023) that shipped withonnxruntime-node@1.21.0, whoseReleaseIoBindingcleanup path could double-free during concurrentInferenceSession::LoadModelcalls and produce SIGBUS/SIGTRAP crashes inside the worker thread. -
Cross-process file lock. Added a belt-and-suspenders lock around embedding model initialization in
embedding-local.ts, so two OpenCode processes (Desktop sidecar + TUI + dashboard, or two sessions launched simultaneously) never callcreatePipeline()on the same.onnxfile at the exact same instant. Lock uses atomicfs.open(path, "wx"), 3-minute stale-lock takeover, 5-minute total wait ceiling, and periodic heartbeat so slow loads don't get misdetected as crashed. Released cleanly viatry/finallyafter load.
Both fixes validated end-to-end:
npm pack+npm installsmoke test: pipeline loads in 118ms, embedding dims [1,384], magnitude 1.000000.- Concurrent-load stress test: two child processes racing → Worker A took lock in 2ms, Worker B waited 153ms for release, both loaded cleanly, identical embeddings, no crashes.
- Live session restart: embedding model loaded first try, memory embedded 268ms later, zero retries, lock file cleanly removed.
🔧 Internal
- Dropped deprecated
quantized: trueflag from thepipeline()call — transformers v4 canonicalizes ondtype, and we were always asking fordtype: "fp32"(full precision, not quantized). Behavior unchanged; the cached.onnxon disk is unchanged.
Thanks
Thanks to @andrewmd5 for the detailed repro with three crash instances and clear root-cause hypothesis — the report pointed directly at the native runtime race.
Full changelog: v0.10.0...v0.10.1
v0.10.0
Highlights
🛠 Anthropic signed-thinking error fix
Prevents messages.N.content: 'thinking' or 'redacted_thinking' blocks in the latest assistant message cannot be modified errors.
When the most recent assistant turn carried signed thinking / reasoning / redacted_thinking parts (Anthropic extended thinking), nudge injection was mutating the text part and invalidating the turn's signature, so the next turn got rejected by the provider. The plugin now detects signed turns and skips them — nudges re-anchor on the next cycle.
🎯 Context-limit resolution rewrite
Context limits are now resolved primarily via OpenCode's SDK /config/providers endpoint (matches OpenCode's own resolution, including its compiled-in snapshot, custom provider overrides, and experimental modes), with the on-disk models.json reader as a fallback.
This fixes reports where recently-added models silently fell back to 128K:
github-copilot/gpt-5.3-codex→ 400K (was 128K)opencode/big-pickle→ 200K (was 128K)- Derived experimental modes (
gpt-5.4-fast, etc.) inherit parent context correctly
The file-layer fallback also gained OPENCODE_MODELS_PATH / OPENCODE_MODELS_URL env support matching OpenCode's behavior, plus diagnostic logging so future limit-resolution reports can be triaged from logs alone.
🚨 Emergency drops during active historian
On small-context models (e.g. 128K), fast main + slow historian could overflow to 100%+ because pending drops were blocked while historian was running. At >= 85% usage the plugin now applies queued drops and heuristic cleanup even while historian is active. This is safe because historian reads raw OpenCode messages and writes to compartments/facts/memories, while drops mutate tags and pending_ops — disjoint data.
Verified with a new accumulating-overflow e2e test: before this fix the session reached 169%+ with zero drops materialized; after the fix it stabilizes oscillating around ~90–99% with drops materializing promptly.
📐 Auto-derived historian budgets
Replaced the static compartment_token_budget config with two auto-derived budgets:
- Trigger budget =
context × execute_threshold × 5%(clamped 5K–50K) — drivestail_sizeand commit-cluster triggers - Historian chunk budget =
historian_context × 25%(clamped 8K–50K) — drives per-call raw-history window
Fixes late triggering on small-context models (the old static 60K was 72% of usable on 128K × 65%, which was broken). Preserves legacy 1M × 40% behavior.
doctor automatically removes the deprecated compartment_token_budget key from existing configs.
Supporting fixes
- Historian fallback-chain scoped minimum —
resolveHistorianContextLimitnow scans the full expanded fallback chain and uses the minimum resolved context. Protects chunk-budget sizing when OpenCode falls back to a smaller-context entry. - Doctor preserves JSONC comments —
experimental.compaction_markers → compaction_markersmigration no longer drops the emptyexperimentalobject, preserving user comments anchored to it. - Stable test hashes — removed
Bun.hashfrom tests (unstable across Bun versions); using production MD5-based helpers. - Tighter e2e assertions — test suite now actually catches what it claims to guard against (context-limit percentage is exact, overflow guard fails on any prompt error, non-blocking invariant uses request-ordering instead of wall-clock timing).
New end-to-end test harness
Ships alongside the plugin in packages/e2e-tests/ — runs OpenCode with an isolated config + mock Anthropic provider. 13 scenario tests cover overflow guard, slow-historian non-blocking, memory injection, session isolation, emergency blocking, historian success, context-limit resolution, conflict disable, cache stability.
Config migration
compartment_token_budget— removed.doctorcleans it automatically.OPENCODE_MODELS_PATH/OPENCODE_MODELS_URLenv vars now honored.
v0.9.1
Fixes
- Memory injection for new sessions — Memories and session facts are now injected into
message[0]even when no compartments exist yet. Previously, brand-new sessions and existing projects where historian hadn't fired yet saw no<session-history>block at all, leaving agents without project memories until the first historian run. Now the block injects as soon as any memory or fact is available.
Notes
- 7 new tests cover memory-only, facts-only, combined injection, cache transitions from empty-to-populated, and defer-pass replay — reviewed by Oracle for cache safety.
Install: bunx --bun @cortexkit/opencode-magic-context@latest setup · npx @cortexkit/opencode-magic-context@latest setup
Upgrade: bunx --bun @cortexkit/opencode-magic-context@latest doctor
v0.9.0
v0.9.0
Config Changes
compaction_markerspromoted to stable top-level config — moved fromexperimental.compaction_markersto top-levelcompaction_markers, defaulttrue. Doctor auto-migrates old configs.- Pinned plugin versions respected — doctor now warns instead of auto-upgrading pinned versions (
@0.8.12etc). Use--forceto explicitly upgrade.
CLI / Install
bunx --buneverywhere — install scripts, README, and help text now usebunx --bunto prevent bunx from delegating to system Node via the#!/usr/bin/env nodeshebang (fixes #18)- Node version guard — install scripts check for Node ≥ 20.12 before falling back to npx
- min-release-age detection — doctor now warns when
~/.npmrcmin-release-ageor~/.bunfig.tomlminimumReleaseAgeis set, which can prevent OpenCode from installing the latest plugin version
Bug Fixes
- Key-file candidate filtering scoped to project directory
- Dreamer session discovery uses stripped project identity for OpenCode DB queries
Dashboard dashboard-v0.2.7
Dashboard v0.2.7
- Config editor updated for stable
compaction_markerstop-level setting (moved from experimental) bunx --bunin all user-facing help text and toast messages
v0.8.12
Bug Fixes
- Agent switching on ignored messages —
sendIgnoredMessageandpromptAsynccalls now preserve the session's active agent name instead of leaving it undefined, which caused OpenCode to default to the "build" agent and switch users away from their current agent (e.g., Prometheus/plan). Closes #15.
v0.8.11
v0.8.11
Bug Fixes
- Custom provider model context limits broken — JSONC comment stripping regex was destroying URLs inside JSON string values (e.g.
"$schema": "https://...") which silently broke OpenCode config parsing. Custom provider models with explicit context limits were never loaded, falling back to the 128K default. Replaced with a string-aware regex that preserves quoted content. (Closes #14) - Derived model IDs missing from context limit resolution — OpenCode creates model variants from
experimental.modesin models.dev data (e.g.gpt-5.4+modes.fast→gpt-5.4-fastwithserviceTier: "priority"). These derived IDs were not being expanded during context limit loading, causing them to fall back to 128K instead of inheriting the parent model's limit. - Pinned plugin versions not upgraded by doctor — If
opencode.jsonortui.jsonhad a pinned version like@cortexkit/opencode-magic-context@0.7.4, bothdoctorand startup treated it as "already present" without upgrading to@latest. Since OpenCode resolves the lowest pinned version across configs, a staletui.jsonentry could lock the entire plugin to an old version even afterdoctor --force. (Closes #13) - Release script used
nodeinstead ofbun— Fixedscripts/release.shto usebunfor version sync.
v0.8.10
v0.8.10
Bug Fixes
- Custom provider model context limits — Context limit resolution now reads custom model definitions from OpenCode's
opencode.json(c)config in addition to themodels.devcache. Custom/proxy models likegoogle/antigravity-claude-opus-4-6-thinkingwith explicitlimit.contextin the provider config were previously falling back to 128k default, causing incorrect pressure calculations and unnecessary compaction. OpenCode config entries override models.dev entries for the same provider/model key.
v0.8.9
v0.8.9
Bug Fixes
- Windows dashboard "Database not found" — The dashboard was looking for
context.dbunder%APPDATA%on Windows, but the plugin stores it at~/.local/shareon all platforms. Bothresolve_db_pathandresolve_opencode_db_pathnow use the sameXDG_DATA_HOMEor~/.local/sharepath unconditionally. (Closes #10) - Windows embedding model failures — Set an explicit
cacheDirfor@huggingface/transformersat~/.local/share/opencode/storage/plugin/magic-context/models/instead of relying on the library's default.cacheinsidenode_modules. The npm cached install path on Windows was often inaccessible, causing persistent "Unable to get model file path or buffer" failures. The new location is writable and survives plugin updates.
v0.8.8
v0.8.8
Improvements
- Memory injection reranking — Injection priority now uses utility-class tiers instead of
seen_countalone: memories the agent actually retrieved (tier 0) and constraint-guarding memories with "must"/"never"/"always" keywords (tier 1) are packed before generic memories. Within tiers, shorter memories are preferred so more fit in budget. - Smarter dreamer archive-stale — The dreamer archive task now uses structured archive/keep criteria validated through local experiments: CONSTRAINTS are nearly untouchable (archive only on exact word-for-word duplicates), KNOWN_ISSUES are never archived, and ARCHITECTURE_DECISIONS are archived only when they lack "because"/"to prevent"/"to avoid" rationale.
- User profile dedup in dreamer — The archive-stale task now loads active user memories and includes them as context, so dreamer can correctly identify project memories that merely restate preferences already covered by the globally-injected user profile.