openclaw - 💡(How to fix) Fix LCM should support agent-scoped conversation isolation [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#56169Fetched 2026-04-08 01:44:12
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
closed ×1locked ×1

Root Cause

Multi-agent workflows are common:

  • Specialized agents (architect, assistant, coordinator)
  • Each has different context and role
  • Cross-contamination breaks agent identity and memory coherence

Fix Action

Fix / Workaround

Workaround (current)

Code Example

Agent A (architect): searches for "login implementation"
Gets results from Agent B (assistant) and Agent C (coordinator)
Memory pollution: wrong context, wrong role

---

CREATE TABLE conversations (
  conversation_id INTEGER PRIMARY KEY,
  session_id TEXT NOT NULL,
  title TEXT,
  bootstrapped_at TEXT,
  created_at TEXT NOT NULL DEFAULT datetime('now'),
  updated_at TEXT NOT NULL DEFAULT datetime('now')
);

---

ALTER TABLE conversations ADD COLUMN agent_id TEXT;
RAW_BUFFERClick to expand / collapse

Problem

In multi-agent setups, all agents share the same LCM database (~/.openclaw/lcm.db), but there's no way to filter conversations by agent ID.

Current behavior:

  • Each agent has its own workspace (e.g., /root/.openclaw/workspace-agent-name)
  • But all conversations are stored in a single conversations table without an agent_id field
  • When using lcm_grep(allConversations: true), agents can see all other agents' conversations

Example:

Agent A (architect): searches for "login implementation"
→ Gets results from Agent B (assistant) and Agent C (coordinator)
→ Memory pollution: wrong context, wrong role

Current schema

CREATE TABLE conversations (
  conversation_id INTEGER PRIMARY KEY,
  session_id TEXT NOT NULL,
  title TEXT,
  bootstrapped_at TEXT,
  created_at TEXT NOT NULL DEFAULT datetime('now'),
  updated_at TEXT NOT NULL DEFAULT datetime('now')
);

No agent_id field exists.

Proposed solution

Option 1: Add agent_id to conversations table

ALTER TABLE conversations ADD COLUMN agent_id TEXT;

Then update lcm_grep / lcm_expand to:

  • Default to current agent's conversations only
  • Support allConversations: true to search across all agents (opt-in)
  • Add optional agentId parameter for explicit filtering

Option 2: Separate LCM databases per agent

Store LCM at ~/.openclaw/agents/<agent_id>/lcm.db instead of global ~/.openclaw/lcm.db.

Why this matters

Multi-agent workflows are common:

  • Specialized agents (architect, assistant, coordinator)
  • Each has different context and role
  • Cross-contamination breaks agent identity and memory coherence

Workaround (current)

Disable allConversations: true and rely only on file-based memory (memory/*.md), but this loses the power of LCM's conversation history search.

extent analysis

Fix Plan

To address the issue of agents seeing each other's conversations, we will implement Option 1: Add agent_id to conversations table.

Step-by-Step Solution:

  1. Alter the conversations table to include an agent_id field:

ALTER TABLE conversations ADD COLUMN agent_id TEXT;

2. **Update `lcm_grep` and `lcm_expand` functions** to:
   - Default to searching the current agent's conversations only.
   - Support an `allConversations: true` parameter to search across all agents.
   - Add an optional `agentId` parameter for explicit filtering.
3. **Modify the conversation insertion logic** to include the `agent_id` when creating new conversations.

#### Example Code Snippets:
```sql
-- Example of updated lcm_grep function
CREATE FUNCTION lcm_grep(
  query TEXT,
  allConversations BOOLEAN DEFAULT FALSE,
  agentId TEXT DEFAULT NULL
)
RETURNS TABLE(conversation_id INTEGER, session_id TEXT, title TEXT) AS $$
BEGIN
  IF allConversations THEN
    RETURN QUERY SELECT conversation_id, session_id, title FROM conversations WHERE title LIKE query;
  ELSEIF agentId IS NOT NULL THEN
    RETURN QUERY SELECT conversation_id, session_id, title FROM conversations WHERE agent_id = agentId AND title LIKE query;
  ELSE
    -- Assuming get_current_agent_id() returns the ID of the current agent
    RETURN QUERY SELECT conversation_id, session_id, title FROM conversations WHERE agent_id = get_current_agent_id() AND title LIKE query;
  END IF;
END;
$$ LANGUAGE plpgsql;

Verification

To verify the fix, perform the following steps:

  • Insert conversations with different agent_id values.
  • Use lcm_grep with allConversations: true to ensure all conversations are returned.
  • Use lcm_grep without allConversations: true to ensure only the current agent's conversations are returned.
  • Use lcm_grep with the agentId parameter to filter conversations by a specific agent.

Extra Tips

  • Ensure the get_current_agent_id() function is implemented to correctly retrieve the ID of the current agent.
  • Consider adding indexes on the agent_id column for improved query performance.
  • Review and update any other functions or logic that interact with the conversations table to account for the new agent_id field.

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