Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

config: say existing pages keep their contextual retrieval mode (#5012 item 6)

garrytan25f83708a656
diff --git a/src/commands/config.ts b/src/commands/config.ts
index 2b4d20df4b..67d80fd594 100644
--- a/src/commands/config.ts
+++ b/src/commands/config.ts
@@ -406,6 +406,7 @@ async function setConfigWithDecideHooks(engine: BrainEngine, key: string, value:
if (key.startsWith('persistence.')) await (await import('./config/preparation-keys.ts')).refuseInvalidPreparationValue(engine, key, value);
if (key.startsWith('facts.')) await (await import('./config/facts-values.ts')).refuseInvalidFactsConfigValue(key, value);
await engine.setConfig(key, value);
+ if (key === 'search.contextual_retrieval') console.log((await import('./config/contextual-mode-hint.ts')).contextualModeHint());
if (key === 'auto_chronicle') await acknowledgeAutoChronicle(engine, value);
if (!key.startsWith('decide.slots.')) return;
try {
diff --git a/src/commands/config/contextual-mode-hint.ts b/src/commands/config/contextual-mode-hint.ts
new file mode 100644
index 0000000000..a51f972e4f
--- /dev/null
+++ b/src/commands/config/contextual-mode-hint.ts
@@ -0,0 +1,13 @@
+/**
+ * #5012 item 6: changing the contextual retrieval mode (`config set
+ * search.contextual_retrieval`, `sources set-cr-mode`) does not restamp
+ * existing pages: each keeps the mode recorded when it was imported, and the
+ * new value applies to pages imported from then on. Only pages with no
+ * recorded mode are stamped by `gbrain repair contextual-mode`. Printed after
+ * the value is written.
+ */
+export function contextualModeHint(sourceId?: string): string {
+ const scope = sourceId ? ` --source ${sourceId}` : '';
+ return 'Existing pages keep the contextual retrieval mode recorded when they were imported; the new mode applies to pages imported from now on.\n'
+ + `Pages with no recorded mode get one from: gbrain repair contextual-mode${scope} --apply (preview first: gbrain repair contextual-mode${scope})`;
+}
diff --git a/src/commands/sources.ts b/src/commands/sources.ts
index 96339ace60..0f772e6cd2 100644
--- a/src/commands/sources.ts
+++ b/src/commands/sources.ts
@@ -919,6 +919,7 @@ async function runSetCrMode(engine: BrainEngine, args: string[]): Promise<void>
} else {
console.log(`Set source "${id}" contextual_retrieval_mode = ${mode}.`);
}
+ console.log((await import('./config/contextual-mode-hint.ts')).contextualModeHint(id));
}
async function runArchive(engine: BrainEngine, args: string[]): Promise<void> {