Repository navigation
fix(active-memory): skip payload-less memory_search toolResults in tr… - #68773
Conversation
Greptile SummaryThis PR removes the Confidence Score: 5/5Safe to merge — the change is minimal, correct, and covered by a new regression test. The one-line removal of ?? {} directly fixes the described bug and does not affect any other code path. The new test validates the exact failure scenario. No P0/P1 findings. No files require special attention. Reviews (1): Last reviewed commit: "fix(active-memory): skip payload-less me..." | Re-trigger Greptile |
|
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Keep this PR open. Current main still has the Best possible solution: Keep this PR open and land it, or an equivalent patch, after normal maintainer validation. The best code path is to remove the What I checked:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 189c91eae6e1. |
…anscript debug lookup
[asRecord(details?.debug) ?? {}] made the `!debug && !warning && !action && !error`
guard dead, so readActiveMemorySearchDebug returned on the newest `memory_search`
toolResult even when it had no debug fields, shadowing older entries that did.
Drop the `?? {}` so the skip guard walks back to the real debug record, and add
a regression test that writes a real transcript `.jsonl` with one empty and one
populated entry.
8ca5efe to
7058b51
Compare
|
Merged in bdb75bd after representative verification with the Active Memory test, targeted formatting, and diff whitespace checks. I added the Unreleased changelog entry before merge. |
openclaw#68773) Verified: - pnpm install --frozen-lockfile - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check origin/main..HEAD - gh pr checks 68773 --repo openclaw/openclaw --required Co-authored-by: SimbaKingjoe <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
openclaw#68773) Verified: - pnpm install --frozen-lockfile - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check origin/main..HEAD - gh pr checks 68773 --repo openclaw/openclaw --required Co-authored-by: SimbaKingjoe <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
openclaw#68773) Verified: - pnpm install --frozen-lockfile - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check origin/main..HEAD - gh pr checks 68773 --repo openclaw/openclaw --required Co-authored-by: SimbaKingjoe <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
openclaw#68773) Verified: - pnpm install --frozen-lockfile - pnpm test extensions/active-memory/index.test.ts - pnpm exec oxfmt --check --threads=1 extensions/active-memory/index.ts extensions/active-memory/index.test.ts CHANGELOG.md - git diff --check origin/main..HEAD - gh pr checks 68773 --repo openclaw/openclaw --required Co-authored-by: SimbaKingjoe <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
fix(active-memory): skip payload-less memory_search toolResults in transcript debug lookup
Summary
readActiveMemorySearchDebugusedasRecord(details?.debug) ?? {}, which forced an empty object{}when thedebugfield was missing. This made the subsequent guard!debug && !warning && !action && !erroralways falsy (because{}is truthy), so the function would return early on the newestmemory_searchtoolResult even when it had no debug payload, shadowing older entries that did contain real debug data.?? {}fallback. Nowdebugisundefinedwhen the field is absent, allowing the guard to correctly skip processing and walk back to find the most recent result that actually has debug data.debugremains identical. No other memory or tool execution logic is affected.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
asRecord(details?.debug) ?? {}intentionally defaulted missingdebugto an empty object, but the guard that followed was designed to skip only whendebugis falsy (undefinedornull). An empty object{}is truthy, so the guard never triggered.memory_searchresults. Existing tests only verified happy paths where every result had adebugfield.?? {}was likely added to avoidundefinedchecks later, but it inadvertently broke the guard’s semantics.Regression Test Plan (if applicable)
extensions/active-memory/index.test.ts(new test case added)memory_searchtool results: first result with validdetails.debug, second result withdetails: {}(no debug). The function should return the debug data from the first result, not skip both.readActiveMemorySearchDebugwith a controlled transcript array isolates the exact regression without needing the full memory pipeline or external storage.User‑visible / Behavior Changes
None. This only affects internal debug logging used by developers.
Diagram (if applicable)
N/A
Security Impact (required)
Repro + Verification
Environment
Steps
.jsonlwhere:memory_searchtool result withdetails.debug = { backend: "qmd", hits: 3 }memory_searchtool result withdetails: {}(no debug)readActiveMemorySearchDebugon this transcript.Expected
The function returns the debug object from entry A (the older entry with real data).
Actual (before fix)
The function returns
undefined(or early‑exits without processing), because entry B’s?? {}created an empty object and the guard failed to skip.Evidence
Human Verification (required)
details: {}) followed by a populated one → correct older debug returned.memory_searchresults → returnsundefined.detailsobject, missingdetailsfield,debugset tonull,debugset to an array (unlikely but handled gracefully).readActiveMemorySearchDebug). The change is isolated to this helper function.Review Conversations
Compatibility / Migration
Risks and Mitigations
None.