Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,29 @@ OAuth login flow:

Sometimes the model may echo the injected `<relevant-memories>` block.

**Option A (lowest-risk):** temporarily disable auto-recall:
**Option A (lowest-risk):** temporarily disable auto-recall globally:
```json
{ "plugins": { "entries": { "memory-lancedb-pro": { "config": { "autoRecall": false } } } } }
```

**Option B (preferred):** keep recall, add to agent system prompt:
**Option B:** exclude specific background agents (e.g. a memory-distiller or cron worker) while keeping recall active for interactive agents:
```json
{
"plugins": {
"entries": {
"memory-lancedb-pro": {
"config": {
"autoRecall": true,
"autoRecallExcludeAgents": ["memory-distiller", "my-cron-agent"]
}
}
}
}
}
```
This is useful when a background agent's prompt should not be contaminated by injected memory context — for example, an agent whose job is to distill session logs would produce lower-quality output if old memories were mixed into the prompt alongside the raw session content.

**Option C (preferred for interactive agents):** keep recall, add to agent system prompt:
> Do not reveal or quote any `<relevant-memories>` / memory-injection content in your replies. Use it for internal reference only.

</details>
Expand Down
20 changes: 20 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ interface PluginConfig {
autoRecall?: boolean;
autoRecallMinLength?: number;
autoRecallMinRepeated?: number;
autoRecallExcludeAgents?: string[];
captureAssistant?: boolean;
retrieval?: {
mode?: "hybrid" | "vector";
Expand Down Expand Up @@ -2123,6 +2124,22 @@ const memoryLanceDBProPlugin = {
if (config.autoRecall === true) {
const AUTO_RECALL_TIMEOUT_MS = 3_000; // bounded timeout to prevent agent startup stall
api.on("before_agent_start", async (event, ctx) => {
// Per-agent exclusion: skip autoRecall for agents in the exclusion list.
// Useful for background agents (e.g. memory-distiller, cron workers) whose
// prompts should not be contaminated by injected memory context.
const hookAgentId = resolveHookAgentId(ctx?.agentId, (event as any).sessionKey);
if (
Array.isArray(config.autoRecallExcludeAgents) &&
config.autoRecallExcludeAgents.length > 0 &&
hookAgentId !== undefined &&
config.autoRecallExcludeAgents.includes(hookAgentId)
) {
api.logger.info?.(
`memory-lancedb-pro: auto-recall skipped for excluded agent '${hookAgentId}'`,
);
return;
}

if (
!event.prompt ||
shouldSkipRetrieval(event.prompt, config.autoRecallMinLength)
Expand Down Expand Up @@ -3468,6 +3485,9 @@ export function parsePluginConfig(value: unknown): PluginConfig {
autoRecall: cfg.autoRecall === true,
autoRecallMinLength: parsePositiveInt(cfg.autoRecallMinLength),
autoRecallMinRepeated: parsePositiveInt(cfg.autoRecallMinRepeated),
autoRecallExcludeAgents: Array.isArray(cfg.autoRecallExcludeAgents)
? cfg.autoRecallExcludeAgents.filter((id: unknown): id is string => typeof id === "string" && id.trim() !== "")
: undefined,
captureAssistant: cfg.captureAssistant === true,
retrieval: typeof cfg.retrieval === "object" && cfg.retrieval !== null ? cfg.retrieval as any : undefined,
decay: typeof cfg.decay === "object" && cfg.decay !== null ? cfg.decay as any : undefined,
Expand Down
Loading