Skip to content

feat: default active memory QMD recall to search - #65068

Merged
Takhoffman merged 4 commits into
mainfrom
codex/active-memory-qmd-search-default-pr
Apr 12, 2026
Merged

Takhoffman merged 4 commits into
mainfrom
codex/active-memory-qmd-search-default-pr

Conversation

@Takhoffman

@Takhoffman Takhoffman commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add an active-memory-specific QMD search mode override
  • default Active Memory to QMD search for lower-latency recall while keeping inherit available
  • add tests covering the new default and the inherit path

Refs #64829

Testing

  • pnpm vitest run extensions/active-memory/index.test.ts src/memory-host-sdk/host/backend-config.test.ts

@aisle-research-bot

aisle-research-bot Bot commented Apr 12, 2026 •

Copy link
Copy Markdown

🔒 Aisle Security Analysis

We found 1 potential security issue(s) in this PR:

# Severity Title
1 🟡 Medium Unbounded session transcript read + JSON parse loop can cause resource exhaustion
1. 🟡 Unbounded session transcript read + JSON parse loop can cause resource exhaustion
Property Value
Severity Medium
CWE CWE-400
Location extensions/active-memory/index.ts:1123-1174

Description

The function readActiveMemorySearchDebug() reads the entire agent session transcript JSONL file into memory and then iterates backwards parsing JSON for each line until it finds a toolResult entry for memory_search.

  • Input/control: sessionFile is produced by an embedded agent run and can grow with conversation/tool output size.
  • Issue: fs.readFile(sessionFile, "utf8") loads the whole file, then .split("\n") allocates additional memory, and the loop performs potentially O(number_of_lines) JSON.parse() operations.
  • Impact: A large transcript (e.g., many turns or large tool outputs) can cause high memory usage and CPU consumption during recall execution, potentially enabling denial-of-service.

Vulnerable code:

raw = await fs.readFile(sessionFile, "utf8");
const lines = raw.split("\n").map((line) => line.trim()).filter(Boolean);
for (let index = lines.length - 1; index >= 0; index -= 1) {
  const parsed = JSON.parse(lines[index]);
  ​// ...
}

Recommendation

Avoid loading/parsing the full transcript for debug extraction.

Mitigations (choose one or combine):

  1. Prefer structured return data: use readActiveMemorySearchDebugFromRunResult(result) first and only fall back to reading the file when absolutely necessary.

  2. Cap work: limit bytes read and/or number of lines parsed.

Example (cap file size and only scan last N lines):

const MAX_BYTES = 1_000_000; // 1MB
const MAX_LINES_TO_SCAN = 500;

const st = await fs.stat(sessionFile);
if (st.size > MAX_BYTES) return undefined;

const raw = await fs.readFile(sessionFile, "utf8");
const lines = raw.split("\n");
for (let i = lines.length - 1, scanned = 0; i >= 0 && scanned < MAX_LINES_TO_SCAN; i--, scanned++) {
  const line = lines[i].trim();
  if (!line) continue;
  ​// JSON.parse and inspect
}
  1. Stream/tail: implement a streaming JSONL reader or tail the file from the end to avoid full-buffer allocations.

These changes prevent a single large transcript from consuming excessive CPU/RAM during recall.


Analyzed PR: #65068 at commit 2bc80bf

Last updated on: 2026-04-12T01:35:38Z

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Apr 12, 2026
@greptile-apps

greptile-apps Bot commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a qmd.searchMode config option to the Active Memory plugin and defaults it to "search" (fast lexical recall) rather than inheriting the main memory config's QMD mode. The "inherit" sentinel is available for users who want the previous pass-through behavior. Logic, types, manifest schema, and tests all align correctly.

Confidence Score: 5/5

Safe to merge — behavioral change is intentional, documented in the manifest help text, and covered by tests.

All findings are P2 or lower. The core logic in applyActiveMemoryConfigOverrides is correct: it spreads cfg.memory and cfg.memory?.qmd so no fields are silently dropped, and the "inherit" sentinel path returns cfg unchanged. Tests cover both the new default and the inherit path.

No files require special attention.

Reviews (1): Last reviewed commit: "feat(active-memory): default QMD recall ..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c921065657

ℹ️ 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".

Comment thread extensions/active-memory/index.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core size: M and removed size: S labels Apr 12, 2026
@Takhoffman
Takhoffman merged commit 885209e into main Apr 12, 2026
42 checks passed
@Takhoffman
Takhoffman deleted the codex/active-memory-qmd-search-default-pr branch April 12, 2026 01:56
trudbot pushed a commit to trudbot/openclaw that referenced this pull request Apr 12, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
TOMUIV pushed a commit to TOMUIV/openclaw that referenced this pull request Apr 14, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
* feat(active-memory): default QMD recall to search

* feat(active-memory): surface search debug telemetry

* fix(active-memory): avoid forking qmd managers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant