mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 11:31:34 +00:00
* fix(memory-lancedb): gate auto-recall and auto-capture on per-agent memorySearch.enabled (#103590) The before_prompt_build auto-recall hook only checked the plugin-level autoRecall flag, so agents configured with memorySearch.enabled: false still received <relevant-memories> injected from the shared LanceDB store - leaking one agent's private memories into another agent's prompts. Gate both recall injection and agent_end auto-capture on the current agent's memorySearch.enabled (per-agent entry wins over agents.defaults; unset means enabled), mirroring core resolveMemorySearchConfig semantics. * fix(memory-lancedb): normalize agent ids before the memorySearch gate Review follow-up on #103799: a configured id like 'XiaoHuo' or one with surrounding whitespace missed the exact-match per-agent override and inherited the enabled default, leaving the disclosure path active. Normalize both the hook agent id and configured entry ids with the SDK normalizeAgentId before comparing. * fix(memory-lancedb): resolve the per-agent memorySearch gate via resolveAgentConfig * fix(memory): isolate LanceDB rows by agent Co-authored-by: Shubhankar Tripathy <reach2shubhankar@gmail.com> * fix(memory): isolate LanceDB rows by agent Co-authored-by: Shubhankar Tripathy <reach2shubhankar@gmail.com> * refactor(memory): keep LanceDB store types private --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
21 lines
769 B
TypeScript
21 lines
769 B
TypeScript
export const MEMORY_TABLE_NAME = "memories";
|
|
export const MEMORY_AGENT_ID_COLUMN = "agentId";
|
|
|
|
export function quoteLanceSqlString(value: string): string {
|
|
return `'${value.replaceAll("'", "''")}'`;
|
|
}
|
|
|
|
export function memoryAgentPredicate(agentId: string): string {
|
|
return `${MEMORY_AGENT_ID_COLUMN} = ${quoteLanceSqlString(agentId)}`;
|
|
}
|
|
|
|
export function hasAgentScopeColumn(schema: { fields: Array<{ name: string }> }): boolean {
|
|
return schema.fields.some((field) => field.name === MEMORY_AGENT_ID_COLUMN);
|
|
}
|
|
|
|
export function legacyMemorySchemaError(): Error {
|
|
return new Error(
|
|
'memory-lancedb: the existing memory table predates per-agent isolation. Run "openclaw doctor --fix" to assign legacy rows to the default agent, then restart OpenClaw.',
|
|
);
|
|
}
|