Skip to main content

Agent Memory

Agent Memory gives your agents persistent state across sessions. Three tiers cover different use cases — from ephemeral scratch pads to searchable long-term knowledge.

Memory tiers

TierPersistenceUse caseSearch
ScratchTTL-based (auto-expires)Session context, temp resultsKey lookup
DurablePermanent until deletedPreferences, config, factsKey lookup
SemanticPermanent + vector-indexedKnowledge base, RAG contextSimilarity search

All tiers are encrypted at rest with the org's KEK via envelope encryption (same pattern as vault secrets).

Quickstart

Enable memory on an agent

curl -X PATCH "https://api.1claw.xyz/v1/agents/$AGENT_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "memory_enabled": true }'

Store and retrieve

import { createClient } from "@1claw/sdk";

const client = createClient({
baseUrl: "https://api.1claw.xyz",
apiKey: process.env.ONECLAW_AGENT_API_KEY,
});

// Write scratch memory (auto-expires in 1 hour)
await client.memory.put(agentId, "session", "last-query", {
value: "What is the weather in NYC?",
ttl_seconds: 3600,
});

// Write durable memory
await client.memory.put(agentId, "preferences", "timezone", {
value: "America/New_York",
});

// Write semantic memory (auto-embedded for vector search)
await client.memory.put(agentId, "knowledge", "api-limits", {
value: "The 1Claw free tier allows 1000 requests per month and 3 vaults.",
});

// Read
const { data } = await client.memory.get(agentId, "preferences", "timezone");
console.log(data.value); // "America/New_York"

// Semantic search
const { data: results } = await client.memory.search(agentId, {
namespace: "knowledge",
query: "how many vaults can I create?",
top_k: 5,
});
results.entries.forEach((e) => console.log(e.key, e.score));

API endpoints

MethodPathDescription
GET/v1/agents/{id}/memoryList namespaces
GET/v1/agents/{id}/memory/{namespace}List entries in namespace
PUT/v1/agents/{id}/memory/{namespace}/{key}Upsert entry
GET/v1/agents/{id}/memory/{namespace}/{key}Get entry
DELETE/v1/agents/{id}/memory/{namespace}/{key}Delete entry
POST/v1/agents/{id}/memory/searchSemantic search

Namespaces

Memory is organized into namespaces — logical groupings like session, preferences, knowledge, etc. Agents can be restricted to specific namespaces via memory_namespace_allowlist:

curl -X PATCH "https://api.1claw.xyz/v1/agents/$AGENT_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "memory_namespace_allowlist": ["session", "preferences", "knowledge"] }'

When the allowlist is empty (default), the agent can use any namespace.

Scratch memory (TTL)

Scratch entries auto-expire after their TTL. Use for:

  • Session context that shouldn't outlive a conversation
  • Temporary computation results
  • Rate-limit tracking or cooldown flags
await client.memory.put(agentId, "session", "conversation-context", {
value: JSON.stringify({ topic: "refactoring", files: ["main.ts"] }),
ttl_seconds: 1800, // scratch tier defaults when ttl is set
});

A background worker reaps expired entries every 60 seconds.

Semantic-tier entries are automatically embedded (1536-dimensional vectors via pgvector). Search returns entries ranked by cosine similarity:

{
"entries": [
{ "key": "api-limits", "value": "The 1Claw free tier...", "score": 0.92 },
{ "key": "pricing-faq", "value": "Pro plan includes...", "score": 0.85 }
]
}

Use for RAG (Retrieval-Augmented Generation), knowledge bases, or any scenario where natural-language lookup is more useful than exact key matching.

MCP tools

ToolDescription
put_memoryWrite a memory entry
get_memoryRead a memory entry
list_memoryList entries in a namespace
delete_memoryDelete a memory entry
search_memorySemantic similarity search

Limits

ConstraintValue
Max value size64 KB
Max entries per agent10,000
Max namespaces per agent100
Vector dimensions1536

Encryption

All memory values are encrypted with a per-entry DEK (data encryption key) via envelope encryption — the same mechanism used for vault secrets. The DEK is wrapped with the org's shared KEK in Cloud KMS. At rest, memory values are AES-256-GCM ciphertext.

Agent config fields

FieldTypeDescription
memory_enabledbooleanEnable/disable memory for this agent (default: false)
memory_namespace_allowliststring[]Restrict namespaces the agent can access (empty = all)
default_llm_providerstringLLM provider for embeddings (optional)
default_llm_modelstringModel for embeddings (optional)

Dashboard

The agent detail page shows a Memory card with:

  • Namespace browser (tree view)
  • Entry viewer with value preview
  • Write/delete controls
  • Search interface for semantic namespaces

Next steps

  • Cloud Runtimes — deploy an agent that uses memory across restarts
  • Automations — trigger memory cleanup on a schedule
  • Shroud — route LLM embeddings through the proxy