Skip to content

Commit ef2e8ab

Browse files
devinkuhnDK09876cursoragentnicoloboschi
authored
fix(openclaw): apply configured defaults to dynamic banks (#2441)
* fix(openclaw): apply configured defaults to dynamic banks Co-authored-by: Cursor <cursoragent@cursor.com> * fix(openclaw): route knowledge tools through identity resolution for user-scoped banks Knowledge tool factories now use resolveAndCacheIdentity before deriving bank IDs, matching auto-recall/retain so PluginToolContext sessions hit the correct per-user bank. Unresolved user identity returns a clear tool error instead of querying anonymous/openclaw fallbacks, and bank defaults are applied before execution. Co-authored-by: Cursor <cursoragent@cursor.com> * fix(agent-sdk): stop mapping max_results to recall max_tokens NemoClaw passed max_results=25 expecting a result-count cap, but the SDK used it as max_tokens=25 and starved recall. max_tokens now defaults to 1024 from max_tokens only; max_results slices the results array (1-50). Co-authored-by: Cursor <cursoragent@cursor.com> * refactor(openclaw): drop dead alias exports + tighten entityLabels shape - Remove unused @deprecated hasConfiguredMissions/applyConfiguredMissions aliases (new exports nothing imports). - normalizeEntityLabels now only accepts the server's shapes (a list, or a { attributes: [...] } object); a plain keyed object is dropped client-side instead of being sent and silently ignored by parse_entity_labels. - Update docs (types.ts, plugin.json, README) and tests to match. * fix(agent-sdk): drop unsupported max_results from recall tool The recall tool's max_results was previously aliased to the recall token budget (a no-op for result count). Rather than make it a real cap, remove it entirely — the tool accepts only max_tokens; use recallTopK for an auto-recall count cap. Also document the new per-user dynamic bank defaults (retainExtractionMode, enableObservations, enableAutoConsolidation, dispositions, entityLabels) on the docs-site OpenClaw page and fix its stale max_results guidance. --------- Co-authored-by: DK09876 <Dikshant.pradhan@vectorize.io> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Nicolò Boschi <boschi1997@gmail.com>
1 parent cc45e16 commit ef2e8ab

10 files changed

Lines changed: 851 additions & 128 deletions

File tree

hindsight-docs/docs-integrations/openclaw.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ Optional settings in `~/.openclaw/openclaw.json`:
123123
- `llmModel` - LLM model used with `llmProvider` (provider default if omitted)
124124
- `llmApiKey` - API key for the LLM provider. **Sensitive** — set via `openclaw config set ... --ref-source env --ref-id OPENAI_API_KEY` to reference an env var.
125125
- `llmBaseUrl` - Optional base URL override for OpenAI-compatible providers (e.g. `https://openrouter.ai/api/v1`)
126-
- `bankMission` - Agent identity/purpose stored on the memory bank. Helps the memory engine understand context for better fact extraction during retain. Set once per bank on first use — not a recall prompt.
126+
- `bankMission` - Agent identity/purpose stored on the memory bank's `reflect_mission`. **Only affects `reflect`** — does not steer retain or recall. Set once per bank on first use.
127+
- `retainMission` - Stamped onto the bank's `retain_mission` on first use. Steers what gets extracted as facts during retain.
128+
- `observationsMission` - Stamped onto the bank's `observations_mission` on first use. Controls what gets synthesised into observations during consolidation.
129+
- `retainExtractionMode` - Fact extraction mode stamped on first bank use: `concise`, `verbose`, `custom`, `verbatim`, or `chunks`. Leave unset to keep the server default.
130+
- `enableObservations` - Toggle observation consolidation after retain, stamped on first bank use.
131+
- `enableAutoConsolidation` - Toggle automatic consolidation scheduling, stamped on first bank use (via the bank config API).
132+
- `dispositionSkepticism` / `dispositionLiteralism` / `dispositionEmpathy` - Reflect disposition traits (`1``5`) stamped on first bank use.
133+
- `entityLabels` - Controlled vocabulary for entity labels. Either a list of attribute defs (e.g. `[{ "name": "person", "description": "Human user" }]`) or a `{ "attributes": [...] }` object; other shapes are ignored. Stamped on first bank use.
127134
- `dynamicBankId` - Enable per-context memory banks (default: `true`)
128135
- `bankId` - Static bank ID used when `dynamicBankId` is `false`.
129136
- `bankIdPrefix` - Optional prefix for bank IDs (e.g. `"prod"``"prod-slack-C123"` or `"prod-shared-bank"`)
@@ -146,7 +153,7 @@ Optional settings in `~/.openclaw/openclaw.json`:
146153
- `enableKnowledgeTools` - Register `agent_knowledge_*` tools for explicit agent-driven lookup, reflection, ingest, and knowledge-page management (default: `false`).
147154
- `debug` - Enable debug logging (default: `false`).
148155

149-
When using `agent_knowledge_recall` manually, pass `max_tokens` to control how much memory text the recall response may contain. Do not use `max_results` for this tool; OpenClaw auto-recall uses `recallTopK` when you need a count cap for automatically injected memories.
156+
When using `agent_knowledge_recall` manually, pass `max_tokens` to control how much memory text the recall response may contain. The tool has no `max_results` parameter — to cap the number of automatically injected memories, use `recallTopK` on auto-recall instead.
150157

151158
When using `agent_knowledge_reflect`, keep the default conservative settings unless you intentionally need a deeper synthesis: `budget` defaults to `low`, `max_tokens` defaults to `1024`, and `fact_types` defaults to `world`, `experience`, and `observation`. Reflect calls can be more expensive than recall because they retrieve memories and then call the configured Reflect LLM to generate an answer. For production banks, set a finite bank-level `reflect_source_facts_max_tokens` value (for example `4096` or `8192`) instead of leaving it unlimited, so ad-hoc reflection cannot pull an unbounded amount of source facts into the LLM context.
152159

@@ -181,6 +188,41 @@ Available isolation fields:
181188

182189
Use `bankIdPrefix` to namespace bank IDs across environments (e.g. `"prod"`, `"staging"`). Set `dynamicBankId` to `false` to use a single shared bank for all conversations. In static mode, the plugin uses `bankId` if set, otherwise the default `openclaw` bank name.
183190

191+
### Per-user bank defaults
192+
193+
With `dynamicBankId` enabled (the default), each derived bank otherwise inherits only the Hindsight **server** defaults (`concise` extraction, no entity labels, etc.). To make every per-user bank match your intended base/shared bank, set the bank-default options below — they are stamped onto each bank **on first use**, before its first retain or recall:
194+
195+
```json
196+
{
197+
"plugins": {
198+
"entries": {
199+
"hindsight-openclaw": {
200+
"enabled": true,
201+
"config": {
202+
"dynamicBankId": true,
203+
"dynamicBankGranularity": ["agent", "channel", "user"],
204+
"retainExtractionMode": "verbose",
205+
"enableObservations": true,
206+
"enableAutoConsolidation": true,
207+
"dispositionSkepticism": 3,
208+
"dispositionLiteralism": 3,
209+
"dispositionEmpathy": 4,
210+
"entityLabels": [
211+
{ "name": "person", "description": "A human user or contact" },
212+
{ "name": "project", "description": "A software project or product" }
213+
],
214+
"retainMission": "Extract durable preferences, decisions, and project context.",
215+
"observationsMission": "Synthesise stable user preferences and active projects.",
216+
"bankMission": "You are a helpful assistant with long-term memory across channels."
217+
}
218+
}
219+
}
220+
}
221+
}
222+
```
223+
224+
Unset options are not sent, so existing behaviour is unchanged when you only configure missions. Each bank is configured at most once per gateway process.
225+
184226
### Retention Controls
185227

186228
By default, the plugin retains `user` and `assistant` messages after each turn. You can customize this behavior:

hindsight-integrations/openclaw/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ Optional settings in `~/.openclaw/openclaw.json` under `plugins.entries.hindsigh
8686
| `bankMission` || Mission stamped onto the bank's `reflect_mission` column on first use. **Only affects the `reflect` operation** — does not steer retain or recall. Leave unset (or empty) to manage missions out-of-band via `PATCH /banks/{id}`. |
8787
| `retainMission` || Mission stamped onto the bank's `retain_mission` column on first use. Steers what gets extracted as facts during retain. Leave unset to use built-in extraction rules. |
8888
| `observationsMission` || Mission stamped onto the bank's `observations_mission` column on first use. Controls what gets synthesised into observations during consolidation. |
89+
| `retainExtractionMode` || Fact extraction mode stamped on each bank's first use: `concise`, `verbose`, `custom`, `verbatim`, or `chunks`. Use with dynamic banks so per-user banks match your analytics/base bank settings. |
90+
| `enableObservations` || When set, stamped on first bank use to toggle observation consolidation after retain. |
91+
| `enableAutoConsolidation` || When set, stamped on first bank use (via bank config API) to toggle automatic consolidation scheduling. |
92+
| `dispositionSkepticism` || Reflect skepticism trait (`1``5`) stamped on first bank use. |
93+
| `dispositionLiteralism` || Reflect literalism trait (`1``5`) stamped on first bank use. |
94+
| `dispositionEmpathy` || Reflect empathy trait (`1``5`) stamped on first bank use. |
95+
| `entityLabels` || Controlled vocabulary for entity labels. Either a list of attribute defs (see example below) or a `{ "attributes": [...] }` object — other shapes are ignored. Passed through to `PATCH /banks/{id}/config` as `entity_labels` on first bank use. |
8996
| `llmProvider` || LLM provider for memory extraction (`openai`, `anthropic`, `gemini`, `groq`, `ollama`, `openai-codex`, `claude-code`). Required unless `hindsightApiUrl` is set. |
9097
| `llmModel` | provider default | LLM model used with `llmProvider` |
9198
| `llmApiKey` || API key for the LLM provider. **Sensitive** — set via `openclaw config set ... --ref-source env --ref-id OPENAI_API_KEY` to reference an env var (or `--ref-source file`/`exec` for mounted-secret/Vault sources). |
@@ -121,10 +128,38 @@ Optional settings in `~/.openclaw/openclaw.json` under `plugins.entries.hindsigh
121128
| `debugPerfTiming` | `false` | Emit one info-level perf line per `before_prompt_build` (recall path) and `agent_end` (retain path) so you can spot whether latency is in the plugin or upstream. Off by default. Format: `perf: <hook> hook_total=Xms <hook-specific fields>`. Safe in production — uses the existing logger. |
122129
| `enableKnowledgeTools` | `false` | Register `agent_knowledge_*` tools for explicit agent-driven lookup, reflection, ingest, and knowledge-page management. Set automatically by the self-driving-agents CLI. |
123130

131+
### Per-user dynamic bank defaults
132+
133+
When `dynamicBankId` is enabled (default), OpenClaw derives a separate Hindsight bank per context (e.g. per Slack user). New banks otherwise inherit only Hindsight server defaults (`concise` extraction, no entity labels, etc.). Set the options below in plugin config to stamp **full bank defaults on first use** — before the first retain or recall touches that bank:
134+
135+
```json
136+
{
137+
"dynamicBankId": true,
138+
"dynamicBankGranularity": ["agent", "channel", "user"],
139+
"retainExtractionMode": "verbose",
140+
"enableObservations": true,
141+
"enableAutoConsolidation": true,
142+
"dispositionSkepticism": 3,
143+
"dispositionLiteralism": 3,
144+
"dispositionEmpathy": 4,
145+
"entityLabels": [
146+
{ "name": "person", "description": "A human user or contact" },
147+
{ "name": "project", "description": "A software project or product" }
148+
],
149+
"retainMission": "Extract durable preferences, decisions, and project context.",
150+
"observationsMission": "Synthesise stable user preferences and active projects.",
151+
"bankMission": "You are a helpful assistant with long-term memory across channels."
152+
}
153+
```
154+
155+
Unset options are not sent — existing behaviour is unchanged when you only configure missions (as before). Each bank is configured at most once per gateway process.
156+
124157
### Manual Knowledge Tools
125158

126159
When `enableKnowledgeTools` is enabled, the plugin registers explicit `agent_knowledge_*` tools in addition to automatic recall. Use `agent_knowledge_recall` for ordinary memory lookup. Use `agent_knowledge_reflect` only for deliberate synthesis, retrospectives, or long-term preference/pattern questions; it retrieves memories and then calls the configured Reflect LLM to generate an answer.
127160

161+
Knowledge tools resolve the same dynamic memory bank as auto-recall and auto-retain: the plugin runs the shared identity-resolution path (`resolveAndCacheIdentity`) from the tool session context before deriving the bank ID. With user-scoped dynamic banking (`dynamicBankGranularity` includes `"user"`), tools target the per-user bank for that session; if sender identity cannot be resolved, tool execution returns a clear error instead of querying the shared `openclaw` default or an `anonymous` fallback bank. Configured bank defaults (missions, extraction mode, entity labels, etc.) are applied on first knowledge-tool use, matching `getClientForContext` behavior.
162+
128163
`agent_knowledge_reflect` uses conservative defaults: `budget: "low"`, `max_tokens: 1024`, and `fact_types: ["world", "experience", "observation"]`. Production deployments should also set a finite bank-level `reflect_source_facts_max_tokens` value, such as `4096` or `8192`, rather than leaving reflection source facts unlimited.
129164

130165
### Session pattern filtering

hindsight-integrations/openclaw/openclaw.plugin.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,40 @@
5454
"type": "string",
5555
"description": "Mission stamped onto the bank's observations_mission column on first use. Controls what gets synthesised into observations during consolidation."
5656
},
57+
"retainExtractionMode": {
58+
"type": "string",
59+
"description": "Fact extraction mode stamped onto each bank on first use (dynamic or static). Options: concise, verbose, custom, verbatim, chunks. Leave unset to keep the Hindsight server default for new banks.",
60+
"enum": ["concise", "verbose", "custom", "verbatim", "chunks"]
61+
},
62+
"enableObservations": {
63+
"type": "boolean",
64+
"description": "When set, stamped onto each bank on first use to toggle observation consolidation after retain."
65+
},
66+
"enableAutoConsolidation": {
67+
"type": "boolean",
68+
"description": "When set, stamped onto each bank on first use via PATCH /banks/{id}/config to toggle automatic consolidation scheduling."
69+
},
70+
"dispositionSkepticism": {
71+
"type": "integer",
72+
"minimum": 1,
73+
"maximum": 5,
74+
"description": "Reflect skepticism trait (1=trusting, 5=skeptical) stamped on first bank use."
75+
},
76+
"dispositionLiteralism": {
77+
"type": "integer",
78+
"minimum": 1,
79+
"maximum": 5,
80+
"description": "Reflect literalism trait (1=flexible, 5=literal) stamped on first bank use."
81+
},
82+
"dispositionEmpathy": {
83+
"type": "integer",
84+
"minimum": 1,
85+
"maximum": 5,
86+
"description": "Reflect empathy trait (1=detached, 5=empathetic) stamped on first bank use."
87+
},
88+
"entityLabels": {
89+
"description": "Controlled vocabulary for entity labels. Either a list of attribute defs (e.g. [{\"name\":\"person\",\"description\":\"Human user\"}]) or a { \"attributes\": [...] } object, passed through to PATCH /banks/{id}/config as entity_labels on first bank use. Other shapes are ignored."
90+
},
5791
"embedVersion": {
5892
"type": "string",
5993
"description": "hindsight-embed version to use (e.g. 'latest', '0.4.2', or empty for latest)",
@@ -329,6 +363,34 @@
329363
"label": "Observations Mission",
330364
"placeholder": "Controls what gets synthesised into observations..."
331365
},
366+
"retainExtractionMode": {
367+
"label": "Retain Extraction Mode",
368+
"placeholder": "verbose, concise, custom, verbatim, or chunks"
369+
},
370+
"enableObservations": {
371+
"label": "Enable Observations",
372+
"placeholder": "true or false — stamped on first bank use"
373+
},
374+
"enableAutoConsolidation": {
375+
"label": "Enable Auto Consolidation",
376+
"placeholder": "true or false — stamped on first bank use"
377+
},
378+
"dispositionSkepticism": {
379+
"label": "Disposition Skepticism",
380+
"placeholder": "1–5"
381+
},
382+
"dispositionLiteralism": {
383+
"label": "Disposition Literalism",
384+
"placeholder": "1–5"
385+
},
386+
"dispositionEmpathy": {
387+
"label": "Disposition Empathy",
388+
"placeholder": "1–5"
389+
},
390+
"entityLabels": {
391+
"label": "Entity Labels",
392+
"placeholder": "e.g. [{\"name\":\"person\",\"description\":\"Human user\"}]"
393+
},
332394
"embedVersion": {
333395
"label": "Hindsight Embed Version",
334396
"placeholder": "latest (or pin to specific version like 0.4.2)"

0 commit comments

Comments
 (0)