---
title: "Memory for the Claude Agent SDK"
description: "The Claude Agent SDK tracks session state. Add durable, temporal user history through the past.dev API."
canonical: https://past.dev/integrations/claude-agent-sdk
last-updated: 2026-08-31
---
# Add memory to the Claude Agent SDK

Source: https://past.dev/integrations/claude-agent-sdk

The Claude Agent SDK manages context, tools and state for an agent run. File-based memory is available inside the sandbox. Applications that need shared memory across users, sessions and machines require an external service. past.dev provides ingestion and recall through HTTP calls from an SDK tool. Recall returns dated evidence and an explicit status.

## Claude Agent SDK memory scope

The [Claude Agent SDK](https://platform.claude.com/docs/en/agent-sdk/overview) runs an agent loop with tools, hooks, subagents and session management. Within a session, context is handled for you. Anthropic's memory tool persists notes as files the agent reads and writes. Both are scoped to the agent's own working environment.

- Session state ends with the session unless you resume it; there is no cross-user memory model.
- File-based memory stores unstructured prose. It has no built-in entity resolution, validity dates, or change queries.
- File notes do not include a standard validity model for distinguishing current and superseded facts.

Files can retain one developer's coding context. The [claude-mem](/compare/claude-mem) plugin uses this pattern. A product with many users and changing facts may require shared memory through a service.

## The integration: one tool, two endpoints

Define SDK tools that call past.dev. Store observations with their original timestamps and call recall when the agent needs history. The [API reference](/docs/memory-api/api-reference) documents all four endpoints.

```python
import os, requests

BASE = "https://api.past.dev/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['PAST_API_KEY']}"}

def remember(text: str, happened_at: str) -> dict:
    """Store an observation with the time it actually happened."""
    return requests.post(f"{BASE}/ingest", headers=HEADERS, json={
        "content": text,
        "timestamp": happened_at,
    }).json()

def recall(question: str) -> dict:
    """Return ranked, dated evidence and a status value."""
    return requests.post(f"{BASE}/recall", headers=HEADERS, json={
        "query": question,
    }).json()
```

Register `remember` and `recall` as tools in your agent definition and describe when to use them in the system prompt: remember durable facts about the user or the work, recall before answering questions that depend on history.

## How an SDK agent uses recall status

Applications can route on `status`. `Supported` means the evidence establishes the answer. `Conflicted` returns evidence from credible sources that disagree. `NoKnownSupport` means the stored evidence does not establish an answer. `UnknownBecauseDegraded` means retrieval could not complete and should be treated as an unknown result.

Define application behavior for each status. For `Supported`, return the answer with its date and citation. For `Conflicted`, present both sides. For `NoKnownSupport`, state that the stored history does not establish an answer.

## Claude Code and team memory

Claude Code can call the same endpoints through a hook or MCP tool. Agents using the same project key can query shared, dated records for decisions, incidents and conventions.

Start with the [quickstart](/docs/memory-api/quickstart), which reaches a first recall in four calls. For how recall quality is measured, see the [benchmarks](/benchmarks).

## Frequently asked questions

### Does this replace the SDK's built-in memory tool?

No. Keep file memory for the agent's private working notes. Use past.dev for durable facts that must survive sessions, be shared across agents and users, carry dates and sources, and support historical questions.

### Can multiple agents share one memory?

Yes. Memory lives behind the API, so every agent, SDK-based or not, reads the same graph with the same key scoping. That is the difference between memory as a file and memory as infrastructure.

## Related

- [Memory for OpenClaw](https://past.dev/integrations/openclaw)
- [past.dev and claude-mem](https://past.dev/compare/claude-mem)
- [Memory for LangGraph](https://past.dev/integrations/langgraph)
- [What is agent memory?](https://past.dev/what-is-agent-memory)
- [Quickstart](https://past.dev/docs/memory-api/quickstart)