Skip to content

fix(active-memory): name the reason when recall is skipped - #138658

Merged
obviyus merged 2 commits into
openclaw:mainfrom
DasX:fix/active-memory-log-recall-skip
Sep 8, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
DasX:fix/active-memory-log-recall-skip

Conversation

@DasX

@DasX DasX commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Related: #138561

What Problem This Solves

Active Memory can skip recall because of tool policy, a locked harness session, a disabled session, session eligibility, or destination policy. Default Gateway logs do not name those decisions, so operators cannot distinguish them from recall that ran without a useful result.

Why This Change Was Made

Each of the five existing exits emits a fixed info-level reason. The branch conditions, return values, recall policy, and optional detailed logging remain unchanged. The existing strict authority boundary remains intact.

Reasons apply per prompt build. Successful recall can also emit session-ineligible for its separate manual helper build, which deliberately avoids recursive automatic recall. That line does not mean the outer user turn performed no memory work. Existing structured trace relationships identify the nested build; the message adds no private identifiers.

The healthy no-recall-intent outcome and defensive missing-authority guard stay at debug level. No new setting, schema, or hook API is added.

User Impact

Default logs expose policy-disabled, harness-session, session-disabled, session-ineligible, and destination-not-allowed without including prompt, memory, session, destination, or credential data in the reason message. This is diagnostic logging only. It does not fix or diagnose the broader recall regression in #138561; that issue remains open.

Evidence

Pinned-main and candidate proof use the same compiled-source Gateway, task-owned Memory Core state, deterministic loopback provider, and real authenticated Gateway requests. The catalog fixture creates a locked session through the supported creation owner; session disabling uses the public /active-memory off command. No direct callback or database-write fixture substitutes for those routes.

  • Baseline: the five skipped prompt builds complete without the corresponding info line.
  • The focused regression fails on baseline because the info logger has zero calls.
  • 426 focused Active Memory tests pass on the candidate, with the duplicate policy-denial setup consolidated into the existing stronger case.
  • Eligible recall reads an actual synthetic memory file and places its result in the main prompt. Default no-intent and debug logging controls retain their behavior.
  • Fresh source-blind acceptance exercised nine additional cases with changed prompts, memory facts and paths, and off/on recovery. Observable checks passed; source-only obligations were separately reviewed.
  • Source review through P2, formatting, scoped lint and source ratchets passed. Exact-head CI and final landing review remain required.

AI-assisted verification and test consolidation. Original implementation by @DasX.

Captured default-log messages from separate real Gateway prompt builds:

INFO active-memory: recall skipped reason=policy-disabled
INFO active-memory: recall skipped reason=harness-session
INFO active-memory: recall skipped reason=session-disabled
INFO active-memory: recall skipped reason=session-ineligible
INFO active-memory: recall skipped reason=destination-not-allowed

Each shown skip build completed its turn. The eligible outer build performed real memory retrieval and supplied context; its separate manual helper produced its own session-ineligible record. The ordinary default no-intent control produced no info skip line. Complete source, fixture, logs, provider requests and acceptance evidence are retained privately with hashes. Public extracts omit prompts, memory contents, session/destination identities and infrastructure metadata.

One exploratory phrasing did not trigger the existing recall-intent heuristic; it is preserved as a separate observation and not counted as automatic-recall proof. This repair does not change that heuristic. Source-history changes also make the two complete requests differ; the introduced patch changes only the logging owner and regression assertions, so this is not a claim of whole-repository byte-equivalence.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-04T22:08:48.974675Z cbf682c PR opened
🔒 Security Review ✅ Completed 2026-09-04T22:15:42.809133Z cbf682c PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: cbf682cb35

ℹ️ 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 Outdated
Comment on lines +217 to +218
if (!toolAuthority) {
api.logger.debug?.(
"active-memory: recall skipped because this prompt has no turn tool authority",
);
logRecallSkipped("no-tool-authority");

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.

P1 Badge Log absent authority at the dispatcher boundary

When a turn actually lacks tool authority, this branch is unreachable through the production hook runner. The plugin is registered with requiresToolAuthority: true, so runBeforePromptBuild filters it out (src/plugins/hooks.ts:1080), while authorized dispatch is skipped when the fingerprint is absent (src/agents/embedded-agent-runner/run/attempt-prompt-build.ts:181-188) and otherwise synthesizes ctx.toolAuthority (src/plugins/hooks.ts:1114-1136). The new test calls the captured handler directly and bypasses this boundary. Consequently the no-tool-authority case still emits nothing; record the reason where authorized dispatch is skipped instead.

AGENTS.md reference: AGENTS.md:L303-L303

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 4, 2026, 11:44 PM ET / September 5, 2026, 03:44 UTC.

ClawSweeper review

What this changes

Adds info-level reasons for five Active Memory recall skips while keeping routine escalation messages at debug level.

Merge readiness

✅ Ready for maintainer review

The narrowed diagnostic change remains useful and is absent from current main. No blocking findings remain; the supplied Gateway output satisfies the prior proof request for the changed logging path.

Priority: P2
Reviewed head: 802f3cab270074da4af2c90372b69d5b97c3d705

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused diagnostic patch with relevant Gateway output, supplemental regression assertions, and no blocking correctness findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The captured after-fix Gateway trace exercises the compiled Active Memory hook through POST /v1/responses and visibly emits session-ineligible with default logging and config.logging unset. The mock model backend is outside the changed logging behavior; tests additionally preserve debug-only escalation, while three other reasons have no runtime demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The captured after-fix Gateway trace exercises the compiled Active Memory hook through POST /v1/responses and visibly emits session-ineligible with default logging and config.logging unset. The mock model backend is outside the changed logging behavior; tests additionally preserve debug-only escalation, while three other reasons have no runtime demonstration.
Evidence reviewed 9 items Introduced patch and merge ownership: The pinned merge-base comparison introduces only logging and associated assertions. The test merge has the recorded base followed by the exact PR head as parents, and its result against that base contains the same two-file change.
Still necessary on current main: Both affected files are unchanged between the pinned merge base and fetched main. Comparing main with the PR head shows the five info calls are still unique to this branch.
Owner boundary and existing alternatives: The complete plugin entrypoint places each new call inside an existing skip branch without changing its condition or result. Session status persistence clears several skipped outcomes and is bypassed for harness skips, so it cannot supply equivalent default-log diagnostics. Existing recall timing/result logging remains separately gated.
Findings None None.
Security None None.

How this fits together

Active Memory runs during prompt preparation and can add recalled context before the model receives a turn. Its existing policy, session, and destination checks decide whether recall proceeds; this change makes selected skips visible in Gateway logs.

flowchart TD
  A[Incoming agent turn] --> B[Host prompt preparation]
  B --> C[Authorized Active Memory hook]
  C --> D{Recall eligibility checks}
  D -->|Selected skip| E[Named info log]
  D -->|Eligible| F[Escalation decision]
  F --> G[Recall or routine debug skip]
  G --> H[Prepared model prompt]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +19, Tests +21. Total +40 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 19 0 +19
Tests 1 21 0 +21
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 40 0 +40

Review metrics

Metric Value Why it matters
Production versus test growth Production +19: 8 executable lines and 11 comment lines; tests +21 Executable growth shares one log format across five existing exits without adding a decision path or public API.
Default logging scope 5 skip exits gain info output; 2 existing debug sites preserved; 0 new settings The change exposes selected skip reasons without promoting ordinary escalation into default logs.

Root-cause cluster

Relationship: partial_overlap
Canonical: #138561
Summary: This PR addresses selected diagnostic gaps in the broader recall report without establishing or repairing its underlying recall failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep diagnostics at the existing plugin exit decisions; the small shared helper is justified because status persistence clears some outcomes and omits harness skips.

Do we have a high-confidence way to reproduce the issue?

Yes for the diagnostic gap: current-main policy and session skip branches return without an info message. Source inspection establishes that path; the reporter’s broader loss of recall remains unexplained.

Is this the best way to solve the issue?

Yes for the narrowed scope: logging at the existing decisions is appropriate, while gating these messages behind optional timing logs would preserve the silence. Missing-authority diagnostics belong to separate host-dispatch work.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 12cdb3e3a4e4.

Labels

Label justifications:

  • P2: This is a bounded diagnostic improvement for silent recall skips, without evidence of an urgent runtime regression introduced by the patch.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The captured after-fix Gateway trace exercises the compiled Active Memory hook through POST /v1/responses and visibly emits session-ineligible with default logging and config.logging unset. The mock model backend is outside the changed logging behavior; tests additionally preserve debug-only escalation, while three other reasons have no runtime demonstration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured after-fix Gateway trace exercises the compiled Active Memory hook through POST /v1/responses and visibly emits session-ineligible with default logging and config.logging unset. The mock model backend is outside the changed logging behavior; tests additionally preserve debug-only escalation, while three other reasons have no runtime demonstration.

Evidence

What I checked:

  • Introduced patch and merge ownership: The pinned merge-base comparison introduces only logging and associated assertions. The test merge has the recorded base followed by the exact PR head as parents, and its result against that base contains the same two-file change. (extensions/active-memory/index.ts:212, b4b4704551b2)
  • Still necessary on current main: Both affected files are unchanged between the pinned merge base and fetched main. Comparing main with the PR head shows the five info calls are still unique to this branch. (extensions/active-memory/index.ts:288, 12cdb3e3a4e4)
  • Owner boundary and existing alternatives: The complete plugin entrypoint places each new call inside an existing skip branch without changing its condition or result. Session status persistence clears several skipped outcomes and is bypassed for harness skips, so it cannot supply equivalent default-log diagnostics. Existing recall timing/result logging remains separately gated. (extensions/active-memory/index.ts:295, 802f3cab2700)
  • Prior dispatcher finding addressed by explicit scope: The host excludes authority-required registrations from ordinary dispatch and constructs authority before authorized dispatch. Embedded, CLI, and compaction callers gate that pass. The PR preserves the defensive debug guard and explicitly leaves absent-authority reporting outside its scope. These are OpenClaw-owned contracts; the changed logging behavior supplies no affirmative dependency on the Codex runtime or protocol. (src/plugins/hooks.ts:1090, 802f3cab2700)
  • Focused regression coverage: The added test requires an info message when authority denies recall tools; the amended ordinary-turn test requires the existing debug message and forbids its info equivalent. Existing tests cover harness exclusions, session toggles, and destination filtering. The captured body reports 427 passing tests; this read-only review did not execute them. (extensions/active-memory/index.test.ts:824, 802f3cab2700)
  • After-fix production logging evidence: Captured body SHA-256 7f5bf128e6d33304ad01dd1f95b349704ebeacee92fc503fb7e01e59a3ed41b3 describes a compiled Gateway at the reviewed head, Linux/Node 26.4.0, isolated state, default logging, and real POST /v1/responses turns with a mock model backend. The supplied trace visibly contains 'active-memory: recall skipped reason=session-ineligible'; the body also reports policy-disabled output and completed responses. Three other reasons lack runtime demonstrations. The snapshot omits 2,788 UTF-16 units, and GitHub access failed, so those omitted portions were not inspected or treated as absent proof. (802f3cab2700)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-04T22:12:11.728Z sha cbf682cb35a0d6cfe70c2c5cd158436b628ee3f2 :: needs real behavior proof before merge. :: [P1] Report absent authority at the dispatch boundary | [P2] Keep routine escalation skips out of default info logs
  • reviewed 2026-09-04T23:45:05.755Z sha cbf682cb35a0d6cfe70c2c5cd158436b628ee3f2 :: needs real behavior proof before merge. :: [P1] Report absent authority at the dispatch boundary | [P2] Honor the logging control for routine escalation outcomes
  • reviewed 2026-09-04T23:59:01.890Z sha 802f3ca :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
The before_prompt_build hook returns early at several points. Five of them
logged nothing at all, so an operator whose recall had stopped could not
tell whether recall ran and found nothing or never ran at all. The absence
of transcripts was the only available signal.

Add a logRecallSkipped helper and call it at the five previously silent
exits with a stable reason: policy-disabled, harness-session,
session-disabled, session-ineligible and destination-not-allowed. Each
names a state the operator configured or can act on, and each is reachable
through the authorized prompt-build pass.

Two existing debug lines keep their level on purpose. The escalation
decision stays at debug because escalate is the default mode and ordinary
prompts resolve to no-recall-intent, so raising it would add a line to
healthy turns. The no-tool-authority guard stays at debug because the host
filters authority-required registrations out of the unauthorized pass and
always constructs an authority object before the authorized pass, so that
branch is defensive only and never runs in production.

The helper is not gated on config.logging, which defaults to false and
would reproduce the invisibility being reported.

Co-Authored-By: Claude Opus 5 <[email protected]>
@DasX
DasX force-pushed the fix/active-memory-log-recall-skip branch from cbf682c to 802f3ca Compare September 4, 2026 23:48
@DasX DasX changed the title fix(active-memory): report recall skip reasons at info level fix(active-memory): name the reason when recall is skipped Sep 4, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 4, 2026
@obviyus obviyus self-assigned this Sep 8, 2026
@obviyus
obviyus merged commit 626ece1 into openclaw:main Sep 8, 2026
95 of 96 checks passed
@obviyus

obviyus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks @DasX!

Proof: Real authenticated Gateway turns now name all five existing skip reasons at the default log level. All 426 focused tests, the exact-head CI run, and the final independent review passed. Nine fresh acceptance cases also verified changed inputs and successful recall after public session off/on commands.

  • Bug: Policy, harness-session, session-disabled, session-ineligible, and destination decisions were silent in default Gateway logs.
  • Fix: Each existing exit emits one fixed reason without adding prompt, memory, session, destination, or credential data to the message.
Before After
Five skipped prompt builds complete without a default-log reason. Each corresponding build emits its named INFO reason and the turn completes.
Eligible recall reads memory and supplies the main prompt; ordinary no-intent stays quiet. Both behaviors remain. A nested manual helper reports its own session-ineligible decision; that does not mean the outer recall failed.

The logging bound is per prompt build. Original whole-turn silence expectations and an exploratory phrasing that did not trigger the existing intent heuristic are preserved in private evidence; neither was counted as passing automatic-recall proof. The successful independent off/on control inspected actual memory-tool output and its inclusion in the main request.

This is diagnostic logging only. It does not resolve the broader recall regression in #138561, which remains open. No external channel or independent model-reasoning claim is made.

Exact-head CI completed successfully with no failed jobs. Contributor credit is preserved; the follow-up only consolidates duplicated test setup. AI-assisted verification.

vincentkoc added a commit that referenced this pull request Sep 8, 2026
* commit '04869ae4899ad0524c3287759798362b0d62fef8': (677 commits)
  fix(release): pin Kova census refresh (#142104)
  fix: doctor read-only database inspections time out on large agent databases (#142179)
  docs: align v2026.9.3 framing with release announcement (#142307)
  fix(ui): discover models when default-model pickers open (#142105)
  fix(ci): keep Docker upgrade seed baseline older than target (#142273)
  refactor(tests): reuse named OAuth credential fixtures (#142272)
  fix(ci): keep mobile release helpers out of source checks (#142115)
  chore(ui): refresh control ui locales (#142147)
  fix(active-memory): explain why recall was skipped (#138658)
  fix(media): preserve converted images with HEIC filenames (#142263)
  docs: add v2026.9.3 release notes (#142277)
  fix(ui): retire picker focus listeners together (#142258)
  fix(ui): keep menu hover colors consistent across themes (#142243)
  fix(release): keep changelog credits within verified history (#142261)
  fix: keep tool-finalizer placeholders private in message-only groups (#138645)
  perf(tui): carry prepared URL membership through rendering (#142262)
  test(ui): await activity cache imports before teardown (#142282)
  fix(qa): align auth and Workshop proofs with runtime contracts (#142280)
  feat(xai): use one curated catalog and concrete setup default (#142136)
  refactor(outbound): reuse prepared sendability facts (#142252)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
Expose fixed default-log reasons at five existing Active Memory skip decisions while preserving branch conditions, prompt and recall behavior, and healthy debug-only escalation logging. Keep the broader recall regression in openclaw#138561 separate.

Verified all five skips through real Gateway-authorized prompt builds, an actual memory_get recall control, default/debug controls, and nine fresh independent cases including off/on recovery. Passed 426 focused tests, scoped formatting/lint, source ratchets and independent source review. The log bound is per prompt build; a successful outer recall may also report its deliberately ineligible manual helper. The test correction consolidates the policy-reason assertion into existing no-side-effect coverage.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: active-memory P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants