Skip to content

memory_list/memory_recall returns empty when called without explicit scope parameter #284

@huantian233

Description

@huantian233

Bug Description

memory_list and memory_recall tools return no results when called without an explicit scope parameter, even though memories exist in agent-specific scopes.

Steps to Reproduce

  1. Store memories with scope agent:tg-dm-xxx (agent-specific scope)
  2. Call memory_list without any scope parameter
  3. Result: "No memories found" even though entries exist

Root Cause

In src/scopes.ts, the getAllScopes() method only returns explicitly defined scopes from this.config.definitions:

getAllScopes(): string[] {
  return Object.keys(this.config.definitions);
}

When memory_list is called without a scope parameter, it falls back to:

let scopeFilter = context.scopeManager.getAccessibleScopes(agentId);

For an agent with no explicit agentAccess entry and agentId = undefined, getAccessibleScopes(undefined) calls getAllScopes() which only returns [global], missing all agent:xxx scopes.

The issue is that built-in dynamic scope patterns like agent:${agentId} are not included in getAllScopes() even though getAccessibleScopes(agentId) would return them correctly for a known agentId.

Expected Behavior

Calling memory_list or memory_recall without a scope parameter should return memories from all accessible scopes including agent-specific scopes.

Suggested Fix

One approach: modify getAllScopes() to also include the agent pattern scopes:

getAllScopes(): string[] {
  const defined = Object.keys(this.config.definitions);
  const agentScopes = Object.keys(this.config.agentAccess).map(id => `agent:${id}`);
  return [...new Set([...defined, ...agentScopes])];
}

Or alternatively, fix the fallback logic in memory_list to handle the case where no agentId is resolved.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions