Repository navigation
Add Active Memory recall plugin - #63286
Conversation
Greptile SummaryThis PR introduces structured per-plugin debug plumbing: a new Confidence Score: 5/5Safe to merge — all findings are minor style and edge-case observations that do not affect correctness in any real deployment scenario. Both findings are P2: one is dead/redundant code (last line of filterWeakRecallCandidates is always false), the other is an edge-case gap in stale-entry clearing for non-standard session keys that never occur in production. The structured pluginDebugEntries plumbing, fallback resolver, and extension refactor are all well-implemented with matching test coverage across index.test.ts, status.test.ts, and the runReplyAgent integration test. No files require special attention.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8abf8a1bee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🔒 Aisle Security AnalysisWe found 6 potential security issue(s) in this PR:
1. 🟠 Prompt injection risk: recalled memory summary injected as system context (Active Memory plugin)
DescriptionThe Active Memory plugin injects a recalled-memory summary into the system prompt via Although the plugin prepends a warning ( Vulnerable flow:
Vulnerable code: const metadata = buildMetadata(result.summary);
...
return {
prependSystemContext: ACTIVE_MEMORY_PLUGIN_GUIDANCE,
appendSystemContext: metadata,
};
RecommendationAvoid placing untrusted, user-influenced content into system role text. Safer options:
Example (preferred: non-system injection; pseudocode depends on your prompt builder API): // Instead of appendSystemContext
return {
// e.g. appendContext / messages addition (non-system)
appendContext: `Recalled memory (data, not instructions):\n<active_memory_plugin>\n${escapeXml(summary)}\n</active_memory_plugin>`,
};Also consider:
2. 🟠 Unauthorized users can enable verbose mode and trigger leakage of plugin debug/memory summaries
DescriptionThe inline directive persistence path allows any message sender to persist Impact:
Contributing code paths:
Vulnerable code (persistence without auth): if (
directives.hasVerboseDirective &&
directives.verboseLevel &&
allowInternalVerbosePersistence
) {
applyVerboseOverride(sessionEntry, directives.verboseLevel);
updated = true;
}Data flow:
RecommendationRequire sender authorization before persisting directives that change session behavior (including Example fix: // Add an explicit authorization flag to persistInlineDirectives params
export async function persistInlineDirectives(params: {
// ...existing...
isAuthorizedSender: boolean;
}) {
// ...
if (
params.isAuthorizedSender &&
directives.hasVerboseDirective &&
directives.verboseLevel &&
allowInternalVerbosePersistence
) {
applyVerboseOverride(sessionEntry, directives.verboseLevel);
updated = true;
}
}And pass Additionally, consider redacting or scoping 3. 🟡 Memory exhaustion risk: unbounded `rawReply` from embedded agent cached in `activeRecallCache`
DescriptionThe Active Memory plugin stores the full embedded agent output (
Vulnerable flow excerpt: const rawReply = (result.payloads ?? [])
.map((payload) => payload.text?.trim() ?? "")
.filter(Boolean)
.join("\n")
.trim();
...
const result: ActiveRecallResult = summary.length > 0
? { status: "ok", rawReply, summary, ... }
: { status: "empty", ... };
...
setCachedResult(cacheKey, result, params.config.cacheTtlMs);RecommendationAdd a hard cap on embedded agent output size before storing/caching, and prefer caching only the bounded Example (cap and optionally omit rawReply from cached results): const MAX_RAW_REPLY_CHARS = 8_000; // choose based on expected use
const rawReplyFull = (result.payloads ?? [])
.map((p) => p.text ?? "")
.join("\n");
const rawReply = rawReplyFull.length > MAX_RAW_REPLY_CHARS
? rawReplyFull.slice(0, MAX_RAW_REPLY_CHARS)
: rawReplyFull;
// Option A: do not cache rawReply at all
const cacheableResult: ActiveRecallResult = summary.length > 0
? { status: "ok", elapsedMs, rawReply: "", summary }
: { status: "empty", elapsedMs, summary: null };
setCachedResult(cacheKey, cacheableResult, params.config.cacheTtlMs);Also consider:
4. 🟡 Untrusted plugin debug lines can inject Slack/Telegram formatting and mentions in verbose replies
DescriptionVerbose-mode reply surfaces render Impact:
This enables mention-spam and UI spoofing/social engineering in channels when verbose is enabled by untrusted users. Vulnerable flow (high level):
Vulnerable code (sink example): return { text: lines.join("\n") };Sanitization is insufficient (source persistence): return sanitized.replace(/\s+/g, " ").trim();RecommendationTreat Options:
Example (generic neutralization for mention-like tokens before joining): function neutralizeMentions(text: string): string {
return text
.replace(/<!(here|channel|everyone)>/gi, "[!$1]")
.replace(/<@[^>]+>/g, "[@user]")
.replace(/@(here|channel|everyone)\b/gi, "@$1\u200b");
}
return { text: lines.map(neutralizeMentions).join("\n") };Additionally, consider restricting 5. 🟡 Cross-session session toggle via sessionId→sessionKey canonicalization (Active Memory)
DescriptionThe Active Memory plugin resolves a canonical This resolution is then used to read and write per-session toggle state (and persist plugin debug entries) even when the caller did not provide a
If an attacker (or an untrusted channel integration) can influence
Vulnerable code (canonicalization by for (const [sessionKey, entry] of Object.entries(store)) {
// ...
if (!candidateSessionId || candidateSessionId !== sessionId) continue;
const updatedAt = typeof (entry as { updatedAt?: unknown }).updatedAt === "number"
? ((entry as { updatedAt?: number }).updatedAt ?? 0)
: 0;
if (!bestMatch || updatedAt > bestMatch.updatedAt) {
bestMatch = { sessionKey, updatedAt };
}
}
return bestMatch?.sessionKey?.trim() || undefined;This pattern resembles an IDOR/session-fixation style issue because the plugin is effectively treating RecommendationDo not allow session mutation based solely on Recommended fixes (choose one or combine):
Example: fail closed when const sessionKey = ctx.sessionKey?.trim();
if (!sessionKey) {
return { text: "Active Memory: session toggle requires a sessionKey." };
}And for the hook:
6. 🔵 Information disclosure via logging of persisted transcript file path
DescriptionThe Active Memory plugin logs the full on-disk path to persisted sub-agent transcripts when
Vulnerable code: if (params.config.logging && transcriptPath) {
params.api.logger.info?.(`${logPrefix} transcript=${transcriptPath}`);
}RecommendationAvoid logging full absolute transcript paths, or log a redacted/relative identifier. Example: if (params.config.logging && transcriptPath) {
const base = resolvePersistentTranscriptBaseDir(params.api, params.agentId);
const rel = path.relative(base, transcriptPath);
params.api.logger.info?.(`${logPrefix} transcript_id=${rel.replace(/\\/g, "/")}`);
}If you must log paths for debugging, gate it behind a higher-verbosity/debug log level and ensure logs are access-controlled. Analyzed PR: #63286 at commit Last updated on: 2026-04-09T16:20:47Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f0698d148
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f64587a1e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dae966a9b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cbb2697215
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 32bcb93527
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed a narrow Active Memory hardening pass in This follow-up fixes three low-risk issues without changing intended feature behavior:
Focused validation passed: tmp=$(mktemp)
printf '%s\n' '["active-memory/index.test.ts"]' > "$tmp"
OPENCLAW_VITEST_INCLUDE_FILE="$tmp" CI=1 pnpm exec vitest run --config /Users/thoffman/openclaw4/vitest.extensions.config.ts --reporter=verbose --testTimeout=30000
rm -f "$tmp"Result: I intentionally did not change the broader policy surfaces in this pass (shared-session verbose semantics, remote fallback policy, or the broader eligibility contract). This commit is just the bounded hardening work that should not break existing Active Memory behavior. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd7999047b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
* Refine plugin debug plumbing * Tighten plugin debug handling * Reduce active memory overhead * Abort active memory sidecar on timeout * Rename active memory blocking subagent wording * Fix active memory cache and recall selection * Preserve active memory session scope * Sanitize recalled context before retrieval * Add active memory changelog entry * Harden active memory debug and transcript handling * Add active memory policy config * Raise active memory timeout default * Keep usage footer on primary reply * Clear stale active memory status lines * Match legacy active memory status prefixes * Preserve numeric active memory bullets * Reuse canonical session keys for active memory * Let active memory subagent decide relevance * Refine active memory plugin summary flow * Fix active memory main-session DM detection * Trim active memory summaries at word boundaries * Add active memory prompt styles * Fix active memory stale status cleanup * Rename active memory subagent wording * Add active memory prompt and thinking overrides * Remove active memory legacy status compat * Resolve active memory session id status * Add active memory session toggle * Add active memory global toggle * Fix active memory toggle state handling * Harden active memory transcript persistence * Fix active memory chat type gating * Scope active memory transcripts by agent * Show plugin debug before replies
* Refine plugin debug plumbing * Tighten plugin debug handling * Reduce active memory overhead * Abort active memory sidecar on timeout * Rename active memory blocking subagent wording * Fix active memory cache and recall selection * Preserve active memory session scope * Sanitize recalled context before retrieval * Add active memory changelog entry * Harden active memory debug and transcript handling * Add active memory policy config * Raise active memory timeout default * Keep usage footer on primary reply * Clear stale active memory status lines * Match legacy active memory status prefixes * Preserve numeric active memory bullets * Reuse canonical session keys for active memory * Let active memory subagent decide relevance * Refine active memory plugin summary flow * Fix active memory main-session DM detection * Trim active memory summaries at word boundaries * Add active memory prompt styles * Fix active memory stale status cleanup * Rename active memory subagent wording * Add active memory prompt and thinking overrides * Remove active memory legacy status compat * Resolve active memory session id status * Add active memory session toggle * Add active memory global toggle * Fix active memory toggle state handling * Harden active memory transcript persistence * Fix active memory chat type gating * Scope active memory transcripts by agent * Show plugin debug before replies
* Refine plugin debug plumbing * Tighten plugin debug handling * Reduce active memory overhead * Abort active memory sidecar on timeout * Rename active memory blocking subagent wording * Fix active memory cache and recall selection * Preserve active memory session scope * Sanitize recalled context before retrieval * Add active memory changelog entry * Harden active memory debug and transcript handling * Add active memory policy config * Raise active memory timeout default * Keep usage footer on primary reply * Clear stale active memory status lines * Match legacy active memory status prefixes * Preserve numeric active memory bullets * Reuse canonical session keys for active memory * Let active memory subagent decide relevance * Refine active memory plugin summary flow * Fix active memory main-session DM detection * Trim active memory summaries at word boundaries * Add active memory prompt styles * Fix active memory stale status cleanup * Rename active memory subagent wording * Add active memory prompt and thinking overrides * Remove active memory legacy status compat * Resolve active memory session id status * Add active memory session toggle * Add active memory global toggle * Fix active memory toggle state handling * Harden active memory transcript persistence * Fix active memory chat type gating * Scope active memory transcripts by agent * Show plugin debug before replies
* Refine plugin debug plumbing * Tighten plugin debug handling * Reduce active memory overhead * Abort active memory sidecar on timeout * Rename active memory blocking subagent wording * Fix active memory cache and recall selection * Preserve active memory session scope * Sanitize recalled context before retrieval * Add active memory changelog entry * Harden active memory debug and transcript handling * Add active memory policy config * Raise active memory timeout default * Keep usage footer on primary reply * Clear stale active memory status lines * Match legacy active memory status prefixes * Preserve numeric active memory bullets * Reuse canonical session keys for active memory * Let active memory subagent decide relevance * Refine active memory plugin summary flow * Fix active memory main-session DM detection * Trim active memory summaries at word boundaries * Add active memory prompt styles * Fix active memory stale status cleanup * Rename active memory subagent wording * Add active memory prompt and thinking overrides * Remove active memory legacy status compat * Resolve active memory session id status * Add active memory session toggle * Add active memory global toggle * Fix active memory toggle state handling * Harden active memory transcript persistence * Fix active memory chat type gating * Scope active memory transcripts by agent * Show plugin debug before replies
Summary
Adds Active Memory, an optional plugin that runs a dedicated memory sub-agent before the main reply. The sub-agent searches memory on the user’s behalf and injects only compact, relevant context into the turn, so users can benefit from remembered preferences, routines, and personal facts without manually asking the main agent to search memory.
Why it matters
Active Memory makes conversations feel more continuous: the agent can proactively recall useful details like food preferences, travel habits, recurring routines, and prior context when they are relevant to the current message. It does this without relying on the main answering agent to remember to call memory tools or build its own recall strategy.
What changed
active-memoryplugin with configurable query modes, recall profiles, model fallback behavior, prompt overrides, and optional transcript persistence./active-memory on|offcontrols for session-scoped toggles, plus--globalconfig persistence for operator-controlled default behavior.Validation
pnpm checkpassed on the latest pushed branch.