Three Ways to Search Agent Memory: Tags, Semantic Queries, and Namespaces


Your agent has been running for a month. It’s stored 500 memories — user preferences, project context, corrections, session summaries. Now it needs to find the right one.

This is the recall problem, and how you solve it matters. MemoClaw gives you three distinct strategies for retrieving memories: semantic search, tag filtering, and namespace isolation. Each serves a different purpose, and the best agents combine all three.

Strategy 1: Semantic Search — Find by Meaning

Semantic search is the default recall mode. You describe what you’re looking for in natural language, and MemoClaw finds memories with similar meaning — even if the exact words don’t match.

memoclaw recall "what programming language does the user prefer"

This might return a memory that says “User switched to Rust for all backend services in February” even though the word “prefer” never appears in the stored text. The vector embeddings capture meaning, not keywords.

When to use semantic search:

  • You know the topic but not the exact phrasing
  • You’re looking for context around a concept
  • Your agent needs to answer open-ended questions about past interactions

When it falls short:

  • You have memories across many unrelated projects and want only one
  • You need all memories of a specific type (e.g., every correction)
  • The query is ambiguous and might match too broadly

Here’s a real example. Your agent stores these three memories:

1. "User prefers Python for data scripts"
2. "The deployment pipeline uses Python 3.11"  
3. "User said: stop suggesting Python, I'm done with it"

A semantic search for “does the user like Python” might return all three. The similarity scores help — memory #3 would likely score highest for this query — but you’re still sifting through noise.

That’s where tags come in.

Strategy 2: Tag Filtering — Find by Category

Tags let you slice memories into explicit categories. When you store a memory, attach tags that describe its type:

memoclaw store \
  --content "User prefers spaces over tabs" \
  --tags "preferences,formatting" \
  --importance 0.8

Later, recall with a tag filter to narrow results:

memoclaw recall "indentation style" --tags "preferences"

This searches only within memories tagged preferences, ignoring project notes, session summaries, and everything else. The semantic search still runs — you’re just scoping it.

A practical tag taxonomy for agents:

TagWhat it captures
preferencesUser likes, dislikes, style choices
correction”Actually, I meant…” moments
project:{name}Project-specific context
systemAgent configuration, capabilities
summarySession or daily summaries
person:{name}Info about people the user mentions

The key insight: tags are explicit and exact. Semantic search is fuzzy by design. When you need precision, filter by tag first, then let semantic search rank within that subset.

# Find the most relevant correction about API design
memoclaw recall "API design decisions" --tags "correction"

This gives you: memories where the user corrected the agent, ranked by relevance to API design. Sharp and focused.

Strategy 3: Namespace Isolation — Find by Context

Namespaces are walls between memory pools. Memories in one namespace are invisible to queries in another.

# Store in a project-specific namespace
memoclaw store \
  --content "This project uses PostgreSQL with pgvector" \
  --namespace "project-alpha" \
  --tags "stack"

# This recall won't find the memory above
memoclaw recall "what database" --namespace "project-beta"

# This one will
memoclaw recall "what database" --namespace "project-alpha"

When to use namespaces:

  • Multiple projects with conflicting context (project A uses MySQL, project B uses Postgres)
  • Separate agents that shouldn’t see each other’s memories
  • Clear boundaries between work and personal context
  • Archiving: move old project memories to a archive-{project} namespace

Namespace patterns that work well:

default          → General user preferences, corrections
project-{name}   → Project-specific technical context  
agent-{name}     → Per-agent personality and state
archive-{name}   → Completed projects (still searchable, just isolated)

The default namespace is used when you don’t specify one. For agents that work across multiple projects, a simple pattern in your agent’s config handles routing:

<!-- In your agent's AGENTS.md or instructions -->
When working on a specific project, use namespace "project-{name}" for all 
store and recall operations. Use the default namespace for general preferences.

Combining Strategies: The Power Move

The real power comes from combining all three. Here’s a realistic scenario:

Your agent is helping with “project-alpha” and the user asks about deployment preferences. The agent needs to check:

  1. Project-specific deployment config (namespace + semantic)
  2. General deployment preferences (different namespace + tags)
  3. Any corrections about deployment (tags)
# Check project-specific context first
memoclaw recall "deployment configuration" --namespace "project-alpha"

# Then check general preferences  
memoclaw recall "deployment preferences" --namespace "default" --tags "preferences"

# And any corrections
memoclaw recall "deployment" --namespace "default" --tags "correction"

Three targeted recalls instead of one broad search. Total cost: $0.015. Each result set is focused and relevant.

Decision Flowchart

When your agent needs to recall something, here’s the quick decision tree:

Do you know which project this is about? → Yes: Add --namespace "project-{name}" → No: Use default namespace

Do you know the category? → Yes: Add --tags "{category}" → No: Skip tags, let semantic search do its thing

Is the query specific or vague? → Specific: Semantic search will nail it → Vague: Add tags to narrow the field

Are you getting too many irrelevant results? → Tighten with tags or switch namespaces → Check if memories are stored with consistent tags (garbage in, garbage out)

Getting the Storage Right

Good recall starts with good storage. A few habits that pay off:

# Bad: no tags, no importance, default namespace for everything
memoclaw store --content "Uses Postgres"

# Good: tagged, scored, namespaced
memoclaw store \
  --content "Project Alpha uses PostgreSQL 16 with pgvector for embeddings" \
  --namespace "project-alpha" \
  --tags "stack,database" \
  --importance 0.7

The extra 10 seconds at storage time saves you noisy recalls later. Think of tags as filing — a little effort up front makes retrieval instant.

All of this works with the free tier (100 API calls per wallet) — enough to build and test your recall strategy before committing. At $0.005 per recall after that, even aggressive multi-strategy searching stays cheap.


MemoClaw provides semantic memory with tag filtering and namespace isolation for AI agents. No API keys needed — get started at memoclaw.com or install the OpenClaw skill.