@psiclawops/hypermem 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/INSTALL.md +203 -23
  3. package/README.md +139 -216
  4. package/bench/README.md +42 -0
  5. package/bench/data-access-bench.mjs +380 -0
  6. package/bin/hypermem-bench.mjs +2 -0
  7. package/bin/hypermem-doctor.mjs +412 -0
  8. package/bin/hypermem-model-audit.mjs +339 -0
  9. package/bin/hypermem-status.mjs +491 -70
  10. package/dist/adaptive-lifecycle.d.ts +81 -0
  11. package/dist/adaptive-lifecycle.d.ts.map +1 -0
  12. package/dist/adaptive-lifecycle.js +190 -0
  13. package/dist/background-indexer.js +9 -9
  14. package/dist/budget-policy.d.ts +1 -1
  15. package/dist/budget-policy.d.ts.map +1 -1
  16. package/dist/budget-policy.js +10 -5
  17. package/dist/cache.d.ts +4 -0
  18. package/dist/cache.d.ts.map +1 -1
  19. package/dist/cache.js +2 -0
  20. package/dist/composition-snapshot-integrity.d.ts +36 -0
  21. package/dist/composition-snapshot-integrity.d.ts.map +1 -0
  22. package/dist/composition-snapshot-integrity.js +131 -0
  23. package/dist/composition-snapshot-runtime.d.ts +59 -0
  24. package/dist/composition-snapshot-runtime.d.ts.map +1 -0
  25. package/dist/composition-snapshot-runtime.js +250 -0
  26. package/dist/composition-snapshot-store.d.ts +44 -0
  27. package/dist/composition-snapshot-store.d.ts.map +1 -0
  28. package/dist/composition-snapshot-store.js +117 -0
  29. package/dist/compositor.d.ts +125 -1
  30. package/dist/compositor.d.ts.map +1 -1
  31. package/dist/compositor.js +692 -44
  32. package/dist/cross-agent.d.ts +1 -1
  33. package/dist/cross-agent.js +17 -17
  34. package/dist/doc-chunk-store.d.ts +19 -0
  35. package/dist/doc-chunk-store.d.ts.map +1 -1
  36. package/dist/doc-chunk-store.js +56 -6
  37. package/dist/dreaming-promoter.d.ts +1 -1
  38. package/dist/dreaming-promoter.js +2 -2
  39. package/dist/hybrid-retrieval.d.ts +38 -0
  40. package/dist/hybrid-retrieval.d.ts.map +1 -1
  41. package/dist/hybrid-retrieval.js +86 -1
  42. package/dist/index.d.ts +15 -6
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +33 -7
  45. package/dist/knowledge-store.d.ts +4 -1
  46. package/dist/knowledge-store.d.ts.map +1 -1
  47. package/dist/knowledge-store.js +27 -4
  48. package/dist/library-schema.d.ts +12 -8
  49. package/dist/library-schema.d.ts.map +1 -1
  50. package/dist/library-schema.js +22 -8
  51. package/dist/message-store.d.ts.map +1 -1
  52. package/dist/message-store.js +7 -3
  53. package/dist/metrics-dashboard.d.ts +18 -1
  54. package/dist/metrics-dashboard.d.ts.map +1 -1
  55. package/dist/metrics-dashboard.js +52 -14
  56. package/dist/reranker.d.ts +1 -1
  57. package/dist/reranker.js +2 -2
  58. package/dist/schema.d.ts +1 -1
  59. package/dist/schema.d.ts.map +1 -1
  60. package/dist/schema.js +28 -1
  61. package/dist/seed.d.ts +1 -1
  62. package/dist/seed.d.ts.map +1 -1
  63. package/dist/seed.js +3 -1
  64. package/dist/session-flusher.d.ts +2 -2
  65. package/dist/session-flusher.js +2 -2
  66. package/dist/spawn-context.d.ts +1 -1
  67. package/dist/spawn-context.js +1 -1
  68. package/dist/topic-store.js +5 -5
  69. package/dist/topic-synthesizer.d.ts +20 -0
  70. package/dist/topic-synthesizer.d.ts.map +1 -1
  71. package/dist/topic-synthesizer.js +114 -4
  72. package/dist/trigger-registry.d.ts +1 -1
  73. package/dist/trigger-registry.d.ts.map +1 -1
  74. package/dist/trigger-registry.js +14 -6
  75. package/dist/types.d.ts +273 -3
  76. package/dist/types.d.ts.map +1 -1
  77. package/dist/version.d.ts +7 -7
  78. package/dist/version.d.ts.map +1 -1
  79. package/dist/version.js +17 -7
  80. package/docs/DIAGNOSTICS.md +205 -0
  81. package/docs/INTEGRATION_VALIDATION.md +186 -0
  82. package/docs/MIGRATION.md +9 -6
  83. package/docs/MIGRATION_GUIDE.md +125 -101
  84. package/docs/ROADMAP.md +238 -20
  85. package/docs/TUNING.md +30 -6
  86. package/install.sh +159 -408
  87. package/memory-plugin/LICENSE +190 -0
  88. package/memory-plugin/README.md +20 -0
  89. package/memory-plugin/dist/index.js +50 -0
  90. package/memory-plugin/package.json +2 -2
  91. package/package.json +18 -4
  92. package/plugin/LICENSE +190 -0
  93. package/plugin/README.md +20 -0
  94. package/plugin/dist/index.d.ts +55 -0
  95. package/plugin/dist/index.d.ts.map +1 -1
  96. package/plugin/dist/index.js +362 -42
  97. package/plugin/dist/index.js.map +1 -1
  98. package/plugin/package.json +2 -2
  99. package/scripts/install-runtime.mjs +13 -3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  All notable changes to hypermem are documented here.
4
4
 
5
+ ## 0.9.0 - adaptive context lifecycle
6
+
7
+ - **Adaptive lifecycle is now production behavior.** Compose, afterTurn, recall, trim, compaction, and eviction share the same pressure-band policy across bootstrap, warmup, steady, elevated, high, and critical states.
8
+ - **Smart recall and adaptive eviction landed.** `/new` and confident topic shifts widen recall, high-pressure turns gate recall down, and topic-centroid-guided eviction activates only at elevated pressure or worse.
9
+ - **Lifecycle telemetry is release-gated.** Trim and compose reports classify lifecycle bands, divergence, and metadata-only topic signal without exposing topic names, prompt text, document text, or user content.
10
+ - **Deterministic topic evidence replaces live-sample gating.** The 0.9.0 topic-bearing compose gate is covered by deterministic fixtures and report tests, while live topic-bearing samples remain future tuning evidence only.
11
+ - **Forked-context integration is wired.** Forked subagent children inherit bounded parent hot-window context and start warmup or steady instead of cold bootstrap unless `/new` is explicit.
12
+ - **Vector coverage is repaired.** Active facts, knowledge, and eligible episodes reached 100% vector coverage before the release candidate validation pass.
13
+
14
+ ## 0.8.8 - release hardening, diagnostics, lifecycle visibility
15
+
16
+ - **Release packaging aligned across packages.** Core, hypercompositor, and memory plugin versions align at 0.8.8, with version parity validation and bump-script hardening to prevent stale plugin dependencies or lockfile drift.
17
+ - **Installer path simplified.** The shell installer now follows the npm-first path, stages the runtime with `hypermem-install`, preserves existing config/data, backs up existing staged runtime when confirmed, and prints merge-safe OpenClaw activation commands.
18
+ - **Integration validation documented.** `docs/INTEGRATION_VALIDATION.md` defines the install state machine, fresh install checks, upgrade checks, package dry-run validation, and common integration failure signatures.
19
+ - **Diagnostics documented.** `docs/DIAGNOSTICS.md` covers `hypermem-status`, `hypermem-model-audit`, compose/trim reports, version parity, release-path checks, runtime logs, warm restore diagnostics, adaptive lifecycle diagnostics, and the runtime diagnostics API allowlist blocker.
20
+ - **Adaptive lifecycle visibility landed.** The pure lifecycle policy kernel, compose diagnostics, and afterTurn gradient cap are wired while leaving recall breadth, eviction tuning, and telemetry tuning deferred to 0.9.0.
21
+ - **Warm restore hardening is included.** Snapshot integrity, repaired restore paths, provider/parity gates, repair notices, and repair-depth caps are covered by validation guidance and release tests.
22
+ - **Reranker and embedding fixes are included.** Reranker wiring, ZeroEntropy endpoint handling, sqlite-vec native runtime packaging, and provider/model diagnostics are part of the 0.8.8 operational release train.
23
+
24
+ ## 0.8.6 — docs cleanup, model audit config parsing, validator fix
25
+
26
+ - **`hypermem-model-audit` now understands object-shaped OpenClaw model config.** It correctly reads `model.primary` plus fallback arrays from modern agent config instead of reporting an empty model set.
27
+ - **Docs release notes no longer drift on package version text.** README and INSTALL now point operators to the next npm release instead of hard-coding conflicting minimum versions.
28
+ - **README and INSTALL roles are clearer.** INSTALL is explicitly the canonical operator bring-up guide, while README stays as the shorter install-state overview.
29
+ - **Docs validator false positives fixed.** `scripts/validate-docs.mjs` now checks only `openclaw config set plugins.slots.* ...` lines, so `config get` examples no longer trigger bogus plugin-id mismatch warnings.
30
+
31
+ ## 0.8.5 — provider/model-aware failover detection, release parity
32
+
33
+ - **Provider + model identity is now tracked explicitly in HyperCompositor model state.** Mid-session routing changes are detected on the full `provider/model` key, not budget alone, so `github-copilot/claude-sonnet-4-6` and `anthropic/claude-sonnet-4-6` are treated as different operational envelopes.
34
+ - **Downshift detection now keys off provider/model-aware state.** Budget-downshift handling still stays conservative, but verbose logs now surface provider swaps, model swaps, and budget deltas clearly during `context:assemble`.
35
+ - **Install docs now declare the full operator path.** README, INSTALL.md, and TUNING.md now separate staging from activation, document install states explicitly, add merge-safe wiring guidance, and clarify what healthy-but-empty looks like on a first run.
36
+ - **0.8.5 release parity.** Package versions are aligned for the next publish while preserving the npm-first installer and merge-safe config guidance landed from Pylon's install review.
37
+
5
38
  ## 0.8.4 — compaction fence fix, install-path fixes, zod runtime packaging
6
39
 
7
40
  - **Compaction fence tail preservation fixed.** The recent-tail preservation fix is included so compaction no longer drops the protected recent tail during fence advancement.
package/INSTALL.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # hypermem — Installation Guide
2
2
 
3
+ This is the canonical install procedure. Keep README shorter and point operators here for the full bring-up path.
4
+
3
5
  ## Prerequisites
4
6
 
5
7
  - **Node.js 22+** (uses built-in `node:sqlite`)
@@ -15,22 +17,67 @@ openclaw config get gateway # should return gateway config, not an error
15
17
 
16
18
  If `gateway status` shows "disabled" or "not configured", complete OpenClaw onboarding first. `openclaw gateway restart` only works when the gateway service is already set up. On a brand-new OpenClaw install that has never been started, you need `openclaw gateway start` (or the full onboarding flow) before installing plugins.
17
19
 
20
+ ## Non-OpenClaw usage
21
+
22
+ HyperMem can also be used as a normal Node.js library without OpenClaw plugins. This mode is useful for tests, custom agents, migration tooling, and experiments with the memory/composition API.
23
+
24
+ ```bash
25
+ npm install @psiclawops/hypermem
26
+ ```
27
+
28
+ ```typescript
29
+ import { HyperMem } from '@psiclawops/hypermem';
30
+ import { join } from 'node:path';
31
+ import { homedir } from 'node:os';
32
+
33
+ const hm = await HyperMem.create({
34
+ dataDir: join(homedir(), '.openclaw', 'hypermem'),
35
+ embedding: { provider: 'none' },
36
+ });
37
+
38
+ await hm.recordUserMessage('my-agent', 'session-1', 'Hello');
39
+ const composed = await hm.compose({
40
+ agentId: 'my-agent',
41
+ sessionKey: 'session-1',
42
+ prompt: 'Hello',
43
+ tokenBudget: 4000,
44
+ provider: 'anthropic',
45
+ });
46
+ ```
47
+
48
+ No gateway, plugin load path, or OpenClaw config is required in library mode. OpenClaw-specific setup starts below.
49
+
18
50
  ## Quick Start
19
51
 
20
- > **Release note:** if the npm package you installed does not contain `hypermem-install` or `install:runtime`, you are on an older public release. Use the source-clone path in this guide or wait for `0.8.4+`.
52
+ This guide is deliberately declarative. Follow the steps in order and verify each install state before moving on.
53
+
54
+ > **Release note:** if the npm package you installed does not contain `hypermem-install`, `install:runtime`, and `hypermem-model-audit`, you are on an older public release. Use the source-clone path in this guide or wait for the next npm release.
21
55
 
22
56
  ```bash
23
57
  npm install @psiclawops/hypermem
24
58
  npx hypermem-install
25
59
  ```
26
60
 
27
- `hypermem-install` stages the plugin runtime into `~/.openclaw/plugins/hypermem`. It does **not** modify your OpenClaw config and does **not** restart the gateway.
61
+ `hypermem-install` stages the plugin runtime into `~/.openclaw/plugins/hypermem`. It does **not** modify your OpenClaw config and does **not** restart the gateway. That means a successful `npx hypermem-install` is **not** a completed install. It is only a completed staging step.
62
+
63
+ The shell installer is now a thin npm-first wrapper around this same path:
64
+
65
+ ```bash
66
+ curl -fsSL https://raw.githubusercontent.com/PsiClawOps/hypermem/main/install.sh | bash
67
+ ```
68
+
69
+ It installs the npm package into `~/.hypermem`, backs up any existing staged runtime when confirmed, stages the runtime with `hypermem-install`, writes a lightweight starter config only if no config exists, and prints merge-safe OpenClaw activation commands. It does not edit OpenClaw config and does not restart the gateway.
70
+
71
+ Release validation details live in [docs/INTEGRATION_VALIDATION.md](./docs/INTEGRATION_VALIDATION.md). Diagnostic surfaces live in [docs/DIAGNOSTICS.md](./docs/DIAGNOSTICS.md).
28
72
 
29
73
  > **Prerequisites:** OpenClaw must be installed and onboarded. Run `openclaw gateway status` to confirm. If the gateway is not configured, complete OpenClaw setup first.
30
74
  >
31
75
  > **Config merge warning:** if you already have values in `plugins.load.paths` or `plugins.allow`, merge them instead of overwriting blindly.
32
76
 
33
- Create the config directory and set the embedding provider:
77
+ Create the config directory and write the current recommended fresh-install starter config. This does 2 things:
78
+
79
+ 1. sets `embedding.provider` to `none` so a clean install does not try to use Ollama by default
80
+ 2. applies the current recommended lean compositor settings so fresh installs start from the same OpenClaw and HyperMem guidance we want operators to use
34
81
 
35
82
  ```bash
36
83
  mkdir -p ~/.openclaw/hypermem
@@ -38,11 +85,41 @@ cat > ~/.openclaw/hypermem/config.json <<'JSON'
38
85
  {
39
86
  "embedding": {
40
87
  "provider": "none"
88
+ },
89
+ "compositor": {
90
+ "budgetFraction": 0.55,
91
+ "contextWindowReserve": 0.25,
92
+ "targetBudgetFraction": 0.50,
93
+ "warmHistoryBudgetFraction": 0.27,
94
+ "maxFacts": 25,
95
+ "maxHistoryMessages": 500,
96
+ "maxCrossSessionContext": 4000,
97
+ "maxRecentToolPairs": 3,
98
+ "maxProseToolPairs": 10,
99
+ "keystoneHistoryFraction": 0.15,
100
+ "keystoneMaxMessages": 12,
101
+ "wikiTokenCap": 500
41
102
  }
42
103
  }
43
104
  JSON
44
105
  ```
45
106
 
107
+ If you want a lighter or richer memory profile later, adjust from this baseline using the tuning guidance below instead of starting from the older code defaults.
108
+
109
+ ### Install states
110
+
111
+ Treat the install as 5 explicit states:
112
+
113
+ | State | Meaning | Success signal |
114
+ |---|---|---|
115
+ | 1. Package installed | npm package is present | `npm install` succeeds |
116
+ | 2. Runtime staged | plugin payload copied into `~/.openclaw/plugins/hypermem` | `npx hypermem-install` succeeds and files exist |
117
+ | 3. OpenClaw wired | config points at HyperMem plugins | `plugins.load.paths` and `plugins.slots.*` are set correctly |
118
+ | 4. Runtime loaded | gateway restarted and loaded both plugins | `openclaw plugins list` shows both plugins loaded |
119
+ | 5. Runtime active | HyperMem is actually composing turns | logs show `hypermem initialized` and compose activity |
120
+
121
+ Do not stop at state 2 and call the install done.
122
+
46
123
  Wire both plugins into OpenClaw:
47
124
 
48
125
  **Step 1: Check your existing config (mandatory — do this before wiring).**
@@ -52,7 +129,7 @@ openclaw config get plugins.load.paths
52
129
  openclaw config get plugins.allow
53
130
  ```
54
131
 
55
- Note any existing values. You must include them in the commands below.
132
+ Note any existing values. You must include them in the commands below. If `plugins.allow` is null, unset, or empty, skip the allowlist step entirely.
56
133
 
57
134
  **Step 2: Wire plugins.**
58
135
 
@@ -83,30 +160,104 @@ OpenClaw loads the plugin runtime from `~/.openclaw/plugins/hypermem/`.
83
160
 
84
161
  ### Verification checkpoints
85
162
 
86
- 1. **Build verified**
87
- - root build succeeds
88
- - `plugin` build succeeds
89
- - `memory-plugin` build succeeds
163
+ Run the installed-system doctor first:
164
+
165
+ ```bash
166
+ hypermem-doctor --fix-plan
167
+ ```
168
+
169
+ `hypermem-doctor` is read-only. It inspects OpenClaw config, HyperMem config, plugin wiring, recommended OpenClaw runtime settings, data directory shape, runtime plugin load state, and active model context-window risk. It prints exact `openclaw config set ...` commands when something needs review. It does not edit config or restart the gateway.
170
+
171
+ Expected result after a complete install: no required failures. Recommendation warnings should be reviewed before production use, especially context-window warnings for GPT/OpenAI-compatible/local gateways.
172
+
173
+ Walk the install state machine explicitly if you need a manual check:
174
+
175
+ 1. **Runtime staged**
176
+ ```bash
177
+ ls ~/.openclaw/plugins/hypermem
178
+ ```
179
+ Expected: `dist`, `plugin`, `memory-plugin`, and package metadata exist.
90
180
 
91
181
  2. **Wiring verified**
92
- - OpenClaw accepts `plugins.load.paths`
93
- - slots are set to `hypercompositor` and `hypermem`
94
- - gateway restart succeeds
182
+ ```bash
183
+ openclaw config get plugins.load.paths
184
+ openclaw config get plugins.slots.contextEngine
185
+ openclaw config get plugins.slots.memory
186
+ openclaw config get plugins.allow
187
+ ```
188
+ Expected: HyperMem paths are present, slots point to `hypercompositor` and `hypermem`, and allowlist entries were merged only if the install already used an allowlist.
189
+
190
+ 3. **Runtime loaded**
191
+ ```bash
192
+ openclaw plugins list
193
+ ```
194
+ Expected: both `hypercompositor` and `hypermem` show as loaded.
195
+
196
+ 4. **Runtime healthy**
197
+ ```bash
198
+ hypermem-status --health
199
+ ```
200
+ Expected on fresh installs: the plugin may report `no sessions ingested` or empty counts. That means healthy but unused, not broken.
201
+
202
+ 5. **Model budget audited**
203
+ ```bash
204
+ hypermem-model-audit --strict
205
+ ```
206
+ Expected: every configured model either matches a known context-window pattern or has explicit `contextWindowOverrides`. For GPT/OpenAI-compatible/local gateways, prefer explicit overrides unless logs prove OpenClaw passes a correct runtime `tokenBudget`.
207
+
208
+ 6. **Runtime active**
209
+
210
+ Send a message to any agent, then verify:
211
+
212
+ ```bash
213
+ openclaw logs --limit 100 | grep -E 'hypermem|context-engine|budget source'
214
+ ```
215
+
216
+ Expected lightweight-mode lines:
217
+ - `[hypermem] hypermem initialized`
218
+ - `[hypermem] Embedding provider: none — semantic search disabled, using FTS5 fallback`
219
+ - `[hypermem:compose]`
220
+ - `budget source: runtime tokenBudget=...` or `budget source: contextWindowOverrides[...]` for the active model
221
+
222
+ If you see a fallback like `falling back to default engine "legacy"`, the install is **not** fully active yet even if staging and wiring succeeded.
223
+
224
+ ---
95
225
 
96
- 3. **Runtime verified active**
226
+ ## Upgrade Path
97
227
 
98
- Send a message to any agent, then verify:
228
+ Upgrades preserve the HyperMem data directory and existing config. The runtime staging directory is replaceable.
99
229
 
100
230
  ```bash
101
- openclaw logs --limit 100 | grep -E 'hypermem|context-engine'
231
+ cp -a ~/.openclaw/plugins/hypermem ~/.openclaw/plugins/hypermem.backup.$(date +%Y%m%d-%H%M%S) 2>/dev/null || true
232
+ npm install @psiclawops/hypermem@latest
233
+ npx hypermem-install
234
+ openclaw gateway restart
102
235
  ```
103
236
 
104
- Expected lightweight-mode lines:
105
- - `[hypermem] hypermem initialized`
106
- - `[hypermem] Embedding provider: none — semantic search disabled, using FTS5 fallback`
107
- - `[hypermem:compose]`
237
+ Then validate:
238
+
239
+ ```bash
240
+ openclaw plugins list
241
+ openclaw logs --limit 100 | grep -E 'hypermem|context-engine|falling back'
242
+ hypermem-status --health
243
+ hypermem-model-audit --strict
244
+ ```
108
245
 
109
- If you see a fallback like `falling back to default engine "legacy"`, the install is **not** fully active yet even if the build and wiring steps succeeded.
246
+ Pass criteria:
247
+
248
+ - `~/.openclaw/hypermem/config.json` is preserved unless the operator edits it intentionally.
249
+ - existing `~/.openclaw/hypermem/agents/*/messages.db` files remain present.
250
+ - `openclaw plugins list` shows both `hypercompositor` and `hypermem`.
251
+ - logs do not show `falling back to default engine "legacy"`.
252
+ - health output is clean, or reports only healthy-empty state on unused installs.
253
+
254
+ Rollback disables HyperMem without deleting data:
255
+
256
+ ```bash
257
+ openclaw config set plugins.slots.contextEngine legacy
258
+ openclaw config set plugins.slots.memory none
259
+ openclaw gateway restart
260
+ ```
110
261
 
111
262
  ---
112
263
 
@@ -139,7 +290,7 @@ Everything runs in-process on SQLite memory databases. No external database serv
139
290
 
140
291
  > **Package versions:** the root package (`hypermem`) and the two plugins (`hypercompositor`, `hypermem-memory`) are versioned independently. Plugin versions trail the core by one minor version when no plugin-facing API changes ship in a release — this is expected.
141
292
 
142
- The **embedding layer** (L3 semantic search) requires a configured provider. Without one, hypermem falls back to FTS5 keyword matching. This is functional but degrades recall quality. See [Setup Styles](#setup-styles) below.
293
+ The **embedding layer** (L3 semantic search) requires a configured provider. Without one, hypermem falls back to FTS5 keyword matching. This is functional but degrades recall quality. Fresh installs should start with `provider: "none"` explicitly so the runtime behavior is intentional and easy to verify, then upgrade later. See [Setup Styles](#setup-styles) below.
143
294
 
144
295
  ---
145
296
 
@@ -428,6 +579,8 @@ See [Embedding Providers](#embedding-providers) above.
428
579
 
429
580
  ### Step 4 — Restart and verify
430
581
 
582
+ Do not start tuning before this section passes. If HyperMem is not loaded and composing, the next problem is installation, not tuning.
583
+
431
584
  ```bash
432
585
  openclaw gateway restart
433
586
  ```
@@ -659,6 +812,16 @@ Solo installs can skip this.
659
812
 
660
813
  ## Token Budget Tuning
661
814
 
815
+ **Lookup paths for operators and agents.** To inspect the active config at any time:
816
+
817
+ ```bash
818
+ cat ~/.openclaw/hypermem/config.json
819
+ openclaw config get plugins.entries.hypercompositor.config
820
+ openclaw config get plugins.slots.contextEngine
821
+ ```
822
+
823
+ Resolution order is: (1) `plugins.entries.hypercompositor.config` in `openclaw.json`, (2) `~/.openclaw/hypermem/config.json`, (3) code defaults. See [docs/TUNING.md](./docs/TUNING.md) for the full tuning reference.
824
+
662
825
  These settings live in `~/.openclaw/hypermem/config.json` under the `compositor` key. All fields are optional — omit any knob to get the code-level default. Gateway restart required after changes.
663
826
 
664
827
  The recommended starting config for a standard single-agent deployment is intentionally lean on turn-1 warming. Semantic recall and fact triggers fire against each incoming message, so topic-relevant context surfaces as the conversation takes shape. This produces a steadier pressure profile than aggressive pre-loading and avoids the warm→trim→compact cycling you see when every session starts near the top of the budget.
@@ -728,6 +891,10 @@ HyperMem sizes the token budget from the model string using an internal pattern
728
891
  - `warmHistoryBudgetFraction` × *wrong budget* → wrong warm load on first turn
729
892
  - Trim tiers and compaction thresholds fire against the wrong ceiling
730
893
 
894
+ **Treat this as mandatory tuning, not optional polish.** If the runtime does not pass the real model budget, you must supply the correct window yourself. In practice that means OpenAI-compatible surfaces, Codex/OpenRouter-style providers, custom provider prefixes, and local model gateways often need an explicit override because the model string alone is not a trustworthy source of truth.
895
+
896
+ **When you know both numbers, set both.** Each override entry accepts `contextTokens` and `contextWindow`. HyperMem resolves from `contextTokens` first, then `contextWindow`, and the validator enforces `contextTokens <= contextWindow`. Setting both makes your intended usable budget explicit and documents the full advertised window for future operators.
897
+
731
898
  The two symptoms that indicate window-detection failure:
732
899
 
733
900
  1. **Undersized window detected** (you have a 200k model, HyperMem thinks it's 90k): every turn warms near the top of the misdetected budget, trim fires constantly, semantic recall and facts get starved. You see continuous `warm→trim→compact` cycling even on short sessions.
@@ -743,6 +910,16 @@ The two symptoms that indicate window-detection failure:
743
910
 
744
911
  If you see `fallback contextWindowSize` for your model, detection failed and you need an override.
745
912
 
913
+ **Packaged audit helper.** HyperMem now ships `hypermem-model-audit`, which inspects your configured models plus any existing `contextWindowOverrides` and flags models that are running on risky autodetect paths:
914
+
915
+ ```bash
916
+ hypermem-model-audit
917
+ hypermem-model-audit --strict
918
+ hypermem-model-audit --models openai-codex/gpt-5.4,ollama/llama-3.3-70b
919
+ ```
920
+
921
+ Use it during install and after model changes. `--strict` exits non-zero if a model is missing explicit metadata or is only partially overridden.
922
+
746
923
  **Apply an override.** Add a `contextWindowOverrides` block to `~/.openclaw/hypermem/config.json`. The key is `"provider/model"` as it appears in your agent's model string (lowercase, exact match):
747
924
 
748
925
  ```json
@@ -752,9 +929,10 @@ If you see `fallback contextWindowSize` for your model, detection failed and you
752
929
  "contextWindowReserve": 0.25,
753
930
  "warmHistoryBudgetFraction": 0.27,
754
931
  "contextWindowOverrides": {
755
- "ollama/llama-3.3-70b": { "contextTokens": 131072 },
756
- "copilot-local/custom-sft": { "contextTokens": 32768 },
757
- "vllm/qwen3-coder-ft": { "contextTokens": 262144 }
932
+ "ollama/llama-3.3-70b": { "contextTokens": 131072, "contextWindow": 131072 },
933
+ "openai-codex/gpt-5.4": { "contextTokens": 200000, "contextWindow": 200000 },
934
+ "copilot-local/custom-sft": { "contextTokens": 32768, "contextWindow": 32768 },
935
+ "vllm/qwen3-coder-ft": { "contextTokens": 262144, "contextWindow": 262144 }
758
936
  }
759
937
  }
760
938
  }
@@ -769,6 +947,8 @@ Resolution order, highest-to-lowest priority:
769
947
 
770
948
  Gateway restart required after editing overrides. Invalid override entries (malformed keys, impossible ranges, empty values) are dropped on load with a warning; the sanitizer will not let a bad override poison the resolver.
771
949
 
950
+ **OpenAI-family warning.** Do not assume `gpt-*`, `openai/*`, `openai-codex/*`, or OpenAI-compatible hosted endpoints will always arrive with correct runtime budget metadata. If you cannot prove the runtime is logging `runtime tokenBudget=...` for that exact model, add an explicit override and verify it in logs before tuning anything else.
951
+
772
952
  **Interaction with warming and trimming.** Once the correct window is in place:
773
953
 
774
954
  - First-turn warm load = `detectedWindow × budgetFraction × (1 - contextWindowReserve) × warmHistoryBudgetFraction`