Skip to content

Releases: cortexkit/magic-context

v0.10.1

17 Apr 21:37

Choose a tag to compare

🛠 Fixes

Embedding crash under concurrent load (#21) — fully reproduced and fixed on two fronts:

  • Native runtime upgrade. Bumped @huggingface/transformers from ~3.7.6 to ^4.1.0, which pulls in onnxruntime-node@1.24.3 with native library libonnxruntime.1.24.3.dylib. That's a ~2.5-year jump over the old 1.14.0.dylib (Feb 2023) that shipped with onnxruntime-node@1.21.0, whose ReleaseIoBinding cleanup path could double-free during concurrent InferenceSession::LoadModel calls 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 call createPipeline() on the same .onnx file at the exact same instant. Lock uses atomic fs.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 via try/finally after load.

Both fixes validated end-to-end:

  • npm pack + npm install smoke 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: true flag from the pipeline() call — transformers v4 canonicalizes on dtype, and we were always asking for dtype: "fp32" (full precision, not quantized). Behavior unchanged; the cached .onnx on 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

17 Apr 17:50

Choose a tag to compare

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-codex400K (was 128K)
  • opencode/big-pickle200K (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) — drives tail_size and 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 minimumresolveHistorianContextLimit now 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 commentsexperimental.compaction_markers → compaction_markers migration no longer drops the empty experimental object, preserving user comments anchored to it.
  • Stable test hashes — removed Bun.hash from 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_budgetremoved. doctor cleans it automatically.
  • OPENCODE_MODELS_PATH / OPENCODE_MODELS_URL env vars now honored.

v0.9.1

16 Apr 17:18

Choose a tag to compare

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

15 Apr 08:30

Choose a tag to compare

v0.9.0

Config Changes

  • compaction_markers promoted to stable top-level config — moved from experimental.compaction_markers to top-level compaction_markers, default true. Doctor auto-migrates old configs.
  • Pinned plugin versions respected — doctor now warns instead of auto-upgrading pinned versions (@0.8.12 etc). Use --force to explicitly upgrade.

CLI / Install

  • bunx --bun everywhere — install scripts, README, and help text now use bunx --bun to prevent bunx from delegating to system Node via the #!/usr/bin/env node shebang (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 ~/.npmrc min-release-age or ~/.bunfig.toml minimumReleaseAge is 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

15 Apr 08:41

Choose a tag to compare

Dashboard v0.2.7

  • Config editor updated for stable compaction_markers top-level setting (moved from experimental)
  • bunx --bun in all user-facing help text and toast messages

v0.8.12

14 Apr 07:27

Choose a tag to compare

Bug Fixes

  • Agent switching on ignored messagessendIgnoredMessage and promptAsync calls 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

13 Apr 17:39

Choose a tag to compare

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.modes in models.dev data (e.g. gpt-5.4 + modes.fastgpt-5.4-fast with serviceTier: "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.json or tui.json had a pinned version like @cortexkit/opencode-magic-context@0.7.4, both doctor and startup treated it as "already present" without upgrading to @latest. Since OpenCode resolves the lowest pinned version across configs, a stale tui.json entry could lock the entire plugin to an old version even after doctor --force. (Closes #13)
  • Release script used node instead of bun — Fixed scripts/release.sh to use bun for version sync.

v0.8.10

12 Apr 16:25

Choose a tag to compare

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 the models.dev cache. Custom/proxy models like google/antigravity-claude-opus-4-6-thinking with explicit limit.context in 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

12 Apr 16:21

Choose a tag to compare

v0.8.9

Bug Fixes

  • Windows dashboard "Database not found" — The dashboard was looking for context.db under %APPDATA% on Windows, but the plugin stores it at ~/.local/share on all platforms. Both resolve_db_path and resolve_opencode_db_path now use the same XDG_DATA_HOME or ~/.local/share path unconditionally. (Closes #10)
  • Windows embedding model failures — Set an explicit cacheDir for @huggingface/transformers at ~/.local/share/opencode/storage/plugin/magic-context/models/ instead of relying on the library's default .cache inside node_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

12 Apr 13:46

Choose a tag to compare

v0.8.8

Improvements

  • Memory injection reranking — Injection priority now uses utility-class tiers instead of seen_count alone: 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.