openclaw - 💡(How to fix) Fix Feature request: mandatory pre-action memory retrieval hooks [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#59239Fetched 2026-04-08 02:27:03
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0

Code Example

memory:
  preActionRetrieval:
    enabled: true
    triggers:
      - before: exec        # before any shell command
        query: "relevant rules for {command_context}"
      - before: trade        # before trade-related actions
        query: "trading rules and recent lessons"
      - before: format       # before formatting output
        query: "output format preferences"
    sources:
      - supermemory
      - lcm
      - files: ["MEMORY.md"]
    maxTokens: 500
RAW_BUFFERClick to expand / collapse

Title: Feature request: mandatory pre-action memory retrieval hooks

Problem

Current memory architecture (supermemory, LCM, file-based notes) stores information reliably but retrieval is entirely model-initiated. The model decides when to check memory, and under task pressure it consistently skips retrieval — leading to repeated mistakes on things it has already documented.

This is the #1 frustration reported after 67 days of heavy daily use across trading automation, flight bookings, and system administration.

What happens today

  1. Agent learns a lesson (e.g., "BRENTOIL is the correct key, not OIL")
  2. Agent writes it to memory (MEMORY.md, supermemory, daily notes)
  3. Next time the same situation arises, agent barrels forward without checking
  4. Same mistake repeats

The storage layer works. The retrieval trigger doesn't exist.

Proposed solution: mandatory retrieval hooks

Add a configurable pre-action retrieval step in the agent loop — not optional, not model-initiated:

memory:
  preActionRetrieval:
    enabled: true
    triggers:
      - before: exec        # before any shell command
        query: "relevant rules for {command_context}"
      - before: trade        # before trade-related actions
        query: "trading rules and recent lessons"
      - before: format       # before formatting output
        query: "output format preferences"
    sources:
      - supermemory
      - lcm
      - files: ["MEMORY.md"]
    maxTokens: 500

The key insight: retrieval should be architectural, not behavioral. Don't trust the model to remember to check — force it.

Alternatives considered

  • More aggressive system prompts ("ALWAYS check memory before acting") — tried extensively, doesn't work under task pressure
  • Auto-injecting full MEMORY.md into every turn — too expensive, doesn't scale
  • RAG on every message — too noisy, retrieves irrelevant content

The sweet spot is context-aware mandatory retrieval: the system detects what kind of action is about to happen and injects relevant memories before the model proceeds.

Impact

This would be a significant differentiator. Every agent framework has memory storage. None of them solve the "model forgets to check" problem reliably.

extent analysis

TL;DR

Implementing a mandatory pre-action memory retrieval hook in the agent loop can prevent repeated mistakes by ensuring the model checks relevant memories before taking action.

Guidance

  • Introduce a configurable pre-action retrieval step in the agent loop, as proposed in the issue, to force the model to check memories before proceeding with actions.
  • Define specific triggers for memory retrieval, such as before executing shell commands or trade-related actions, to ensure context-aware retrieval.
  • Specify the sources of memory to retrieve from, including supermemory, LCM, and file-based notes, to ensure comprehensive recall.
  • Limit the number of tokens to retrieve to prevent information overload and improve efficiency.

Example

memory:
  preActionRetrieval:
    enabled: true
    triggers:
      - before: exec
        query: "relevant rules for {command_context}"
    sources:
      - supermemory
      - lcm
      - files: ["MEMORY.md"]
    maxTokens: 500

Notes

The proposed solution requires careful configuration to balance the trade-off between ensuring the model checks relevant memories and avoiding information overload.

Recommendation

Apply the proposed workaround by implementing the mandatory pre-action memory retrieval hook, as it addresses the root cause of the problem and provides a significant differentiator from existing agent frameworks.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING