# Agent memory types on AWS: AgentCore Memory benchmark

Companion artifact for the blog post [7 Agent Memory Types Mapped to AWS](/blog/ai-agent-memory-types-aws-agentcore-2026/).

`bench_memory.py` creates one throwaway Amazon Bedrock AgentCore Memory resource with four built-in long-term strategies:

| Strategy | Namespace template | Memory type it implements |
| --- | --- | --- |
| `semanticMemoryStrategy` | `/facts/{actorId}/` | Semantic (facts) |
| `userPreferenceMemoryStrategy` | `/prefs/{actorId}/` | Semantic (preferences) |
| `summaryMemoryStrategy` | `/summaries/{actorId}/{sessionId}/` | Episodic (session summary) |
| `episodicMemoryStrategy` + reflections | `/episodes/{actorId}/{sessionId}/`, reflections at `/episodes/{actorId}/` | Episodic + procedural |

It writes scripted, synthetic conversations for three test actors (each states two facts and one preference). Then it measures:

- `CreateEvent` and `ListEvents` latency (the working-memory write and reload path)
- seconds until each strategy's first long-term record is listable
- `RetrieveMemoryRecords` latency
- planted-fact recall: does each stated fact or preference come back in the top 3 for its question?
- context size: characters in the session transcript vs. characters in the retrieved records

The Memory resource is deleted in a `finally` block, even when the run fails.

## Run it

Requirements: Python 3.11+, [uv](https://docs.astral.sh/uv/), boto3 1.43.118 or newer (older versions don't support `namespaceTemplates` or the episodic strategy), and credentials allowed to call `bedrock-agentcore:*` on `memory/*`.

```bash
uv run --no-project --with "boto3>=1.43.118" python bench_memory.py --profile <your-profile> --region us-east-1
```

Flags: `--max-wait-seconds` (default 1200) caps how long it waits for long-term extraction, `--poll-seconds` (default 15), `--latency-samples` (default 30).

Output: a JSON file at `out/bench-<UTC timestamp>.json` plus the same JSON on stdout. Expected keys: `create_event`, `list_events`, `retrieve_memory_records` (each with `p50_ms`, `p95_ms`), `seconds_to_first_long_term_record` (per strategy, `null` if nothing appeared before the deadline), `planted_fact_recall_top3`, `context_chars`, `probe_actor_record_counts`, `memory_deleted`.

Cost: one run writes 18 short events and makes a few hundred list and retrieve calls. At the October 2026 us-east-1 list prices this comes to well under $1. Check the [AgentCore pricing page](https://aws.amazon.com/bedrock/agentcore/pricing/) for current rates.

## Gotchas we hit

1. **Old boto3 rejects `namespaceTemplates`.** With botocore from mid-2026 you get `Unknown parameter ... "namespaceTemplates", must be one of: name, description, namespaces`. Pin a current boto3, and use `--no-project` so `uv` doesn't reuse an older virtualenv.
2. **Reflection namespace must sit under the episodic namespace.** `/reflections/{actorId}/` fails with `Reflection namespace ... must be the same as or a hierarchical prefix of the episodic namespace`. Use a prefix of the episode path, e.g. `/episodes/{actorId}/`.

## Our run

See `out/` for the raw JSON of the run quoted in the blog post (region and timestamp are in the file).
