openclaw - 💡(How to fix) Fix [Feature]: Proposal: Context Database as a lightweight recall layer after /new [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#52713Fetched 2026-04-08 01:19:59
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Proposal: use a lightweight disk-based Context Database as the first recall layer after /new, so the agent can recover the correct project context without loading full project memory into the context window.

Root Cause

In my experience, that is less reliable for project continuity because it does not always restore the correct project or documentation path after /new, and it tends to prefer generic memory retrieval over project-oriented recall.

RAW_BUFFERClick to expand / collapse

Summary

Proposal: use a lightweight disk-based Context Database as the first recall layer after /new, so the agent can recover the correct project context without loading full project memory into the context window.

Problem to solve

After /new, project continuity is often lost or weakened. The agent may retain some history, but it does not always return to the correct project state, documentation, or working point.

In multi-project workflows, this increases the risk of context mixing. Another issue is that loading too much memory at session start consumes context window capacity and can reduce usefulness during further work.

In short, memory is needed, but loading everything at once is not a good solution.

Proposed solution

I built a lightweight disk-based Context Database that acts as a recall entry layer after /new.

Instead of loading full project memory at session start, the agent first loads a small context index containing:

  • project and topic summaries
  • relations between topics
  • references to the correct files, directories, reports, and documentation on disk

The intended flow is:

  1. load Context Database after /new
  2. identify the current project or topic
  3. follow references to the relevant detailed sources
  4. use the native memory search as a fallback rather than as the first layer

This keeps startup context small while still allowing the agent to recover the correct project state when needed.

Alternatives considered

One alternative is relying on the default built-in memory search alone.

In my experience, that is less reliable for project continuity because it does not always restore the correct project or documentation path after /new, and it tends to prefer generic memory retrieval over project-oriented recall.

Another alternative is loading much more memory directly into the session prompt, but that increases context cost, pollutes the active working context, and does not scale well for multi-project workflows.

Impact

This approach improves practical continuity between sessions.

In my environment, it allows the agent to:

  • return to the correct project after /new
  • find the correct documentation
  • continue work from the previous stopping point
  • reduce project mixing
  • avoid loading unnecessary history into the context window

I think this could be useful especially for multi-project, documentation-heavy, and disk-based workflows.

Evidence/examples

In practice, I use Context Database as a lightweight project and topic index.

When I ask the agent to go into a specific project and find its documentation, it reliably returns to the correct materials and we can continue work from where we stopped.

The only repeatable issue I still observe is that OpenClaw tends to prefer its built-in memory search first. When the agent is explicitly directed to use the disk-based Context Database, the recall works reliably. This suggests the remaining issue is mainly about memory source priority and recall routing, not about the Context Database idea itself.

Additional information

I am sharing this as an architectural proposal, not as criticism of OpenClaw.

From my point of view, OpenClaw already provides a strong foundation. What I was missing in practical project work was a lightweight recall layer that helps the agent orient itself after /new before using deeper memory mechanisms.

If this direction is interesting, I would be happy to share a more detailed technical write-up or implementation details.

extent analysis

Fix Plan

To implement a lightweight disk-based Context Database as the first recall layer after /new, follow these steps:

  • Create a database schema to store project and topic summaries, relations between topics, and references to relevant files, directories, reports, and documentation on disk.
  • Develop an API to load the Context Database after /new and identify the current project or topic.
  • Implement a fallback mechanism to use native memory search when the Context Database does not contain the required information.
  • Update the agent to prioritize the Context Database over the built-in memory search.

Example code snippet in Python:

import sqlite3

# Create a database connection
conn = sqlite3.connect('context_database.db')
cursor = conn.cursor()

# Create tables for project and topic summaries, relations, and references
cursor.execute('''
    CREATE TABLE IF NOT EXISTS projects (
        id INTEGER PRIMARY KEY,
        name TEXT NOT NULL,
        summary TEXT
    )
''')

cursor.execute('''
    CREATE TABLE IF NOT EXISTS topics (
        id INTEGER PRIMARY KEY,
        project_id INTEGER NOT NULL,
        name TEXT NOT NULL,
        summary TEXT,
        FOREIGN KEY (project_id) REFERENCES projects (id)
    )
''')

cursor.execute('''
    CREATE TABLE IF NOT EXISTS references (
        id INTEGER PRIMARY KEY,
        topic_id INTEGER NOT NULL,
        file_path TEXT NOT NULL,
        FOREIGN KEY (topic_id) REFERENCES topics (id)
    )
''')

# Load Context Database after /new
def load_context_database():
    # Identify the current project or topic
    project_id = get_current_project_id()
    topic_id = get_current_topic_id()

    # Load project and topic summaries, relations, and references
    project_summary = cursor.execute('SELECT summary FROM projects WHERE id = ?', (project_id,)).fetchone()
    topic_summary = cursor.execute('SELECT summary FROM topics WHERE id = ?', (topic_id,)).fetchone()
    references = cursor.execute('SELECT file_path FROM references WHERE topic_id = ?', (topic_id,)).fetchall()

    return project_summary, topic_summary, references

# Fallback to native memory search
def fallback_to_memory_search(query):
    # Implement native memory search logic here
    pass

# Prioritize Context Database over built-in memory search
def search(query):
    context_database_result = load_context_database()
    if context_database_result:
        return context_database_result
    else:
        return fallback_to_memory_search(query)

Verification

To verify that the fix worked, test the following scenarios:

  • After /new, the agent returns to the correct project and loads the relevant documentation.
  • The agent continues work from the previous stopping point.
  • Project mixing is reduced.
  • The context window is not polluted with unnecessary history.

Extra Tips

  • Ensure that the Context Database is updated regularly to reflect changes in the project and topic structure.
  • Consider implementing a caching mechanism to improve performance.
  • Monitor the agent

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

openclaw - 💡(How to fix) Fix [Feature]: Proposal: Context Database as a lightweight recall layer after /new [1 participants]