Skip to content

memory_search fails in non-default agent session while CLI --agent search works; current session resolves inconsistently #93199

Description

@chaboncarpentier-blip

Summary

In a non-default agent session (agent:explore:main), the built-in memory_search tool appears to use the wrong/ambiguous current-session context and fails, even though the same agent's memory index and embeddings are healthy and openclaw memory search --agent explore works.

This makes memory recall unreliable for non-default agents and is especially confusing because different built-in session tools disagree about what the current session is.

Environment

  • OpenClaw: 2026.6.6
  • OS: macOS arm64
  • Channel: webchat
  • Affected agent: explore
  • Memory provider for explore: custom provider M6 -> resolved as openai-compatible
  • Embedding model: nvidia/nv-embed-v1

What I verified

1) The actual current conversation is in explore

Using session tools:

  • sessions_history(sessionKey="current") returns:
    • sessionKey: "agent:explore:main"

So the live conversation really belongs to the explore agent.

2) session_status(current) disagrees

  • session_status(sessionKey="current") reports:
    • Session: main

So at least one built-in tool resolves/displays current differently from sessions_history.

3) explore memory backend is healthy

openclaw memory status --deep --agent explore reports:

  • Provider: openai-compatible (requested: M6)
  • Model: nvidia/nv-embed-v1
  • Indexed: 59/59 files · 673 chunks
  • Embeddings: ready
  • Semantic vectors: ready
  • Vector dims: 4096

4) CLI memory search for explore works

Command:

openclaw memory search --agent explore --query "M6 embeddings" --max-results 5 --json

This successfully returns hits from memory/2026-06-15.md in the explore workspace.

5) Built-in memory_search tool fails in the same conversation

Calling the built-in tool with the same topic:

{"corpus":"memory","maxResults":5,"minScore":0.1,"query":"M6 embeddings"}

returns:

{
  "results": [],
  "disabled": true,
  "unavailable": true,
  "error": "memory_search timed out after 15s",
  "warning": "Memory search is unavailable due to an embedding/provider error.",
  "action": "Check embedding provider configuration and retry memory_search."
}

This error is misleading because the embedding/provider configuration for explore is already healthy and the CLI search succeeds.

Expected behavior

In a live session whose actual session key is agent:explore:main:

  • memory_search should resolve the active agent as explore
  • it should use the explore workspace/index/provider
  • it should return the same class of results that openclaw memory search --agent explore returns
  • session_status(current) should not collapse or misreport that session as plain main

Actual behavior

  • sessions_history(current) says the current session is agent:explore:main
  • session_status(current) says Session: main
  • built-in memory_search fails/times out in that same session
  • direct CLI search for --agent explore works fine

Why this looks like a bug

From the installed runtime code, the memory tool path appears intended to resolve the agent from the tool session key:

  • resolveMemoryToolContext() in dist/tools-C_JRyDeX.js
  • resolveSessionAgentIds() in dist/agent-scope-MrLta7Pq.js

resolveSessionAgentIds() should resolve agent:explore:main to agent explore.

So this looks like one of these:

  1. memory_search is not receiving the correct agentSessionKey / runSessionKey in this live webchat route
  2. the current-session alias/fallback machinery is collapsing a non-default agent main session into default main
  3. session_status(current) and memory_search are not using the same current-session resolution rules

Reproduction outline

  1. Create/use a non-default agent, e.g. explore
  2. Configure working memory embeddings for that agent
  3. Verify:
    • openclaw memory status --deep --agent explore
    • openclaw memory search --agent explore --query "..."
  4. In a live conversation for that agent, check:
    • sessions_history(sessionKey="current")
    • session_status(sessionKey="current")
  5. Call built-in memory_search
  6. Observe:
    • sessions_history(current) resolves to agent:explore:main
    • session_status(current) may report main
    • built-in memory_search fails or times out while CLI --agent explore search works

Impact

This breaks reliable memory recall for non-default agents and makes diagnosis confusing, because the failure message suggests an embedding/provider problem even when the real issue is session/agent context resolution in the tool runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions