amazon-opensearch-memory
Integrates an AI agent with Amazon OpenSearch Memory (OpenSearch Memory, CLI `aws opensearchmemory`, IAM prefix `osm:`), a managed service that stores conversation events and extracts long-term memories from them. Use only when the user names OpenSearch Memory, an OpenSearch Memory space, or `aws op
- 01Installs
- New
- 02Files scanned
- 6
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 e0b20a6aef1a7319… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Amazon OpenSearch Memory
Overview
Amazon OpenSearch Memory gives agents durable memory. You create a space, declare the memory strategies that decide what is extracted, write conversation turns as events, and search the memories the service extracts from them asynchronously.
All commands use the AWS CLI service opensearchmemory (boto3 client opensearchmemory): each API operation is a hyphenated lowercase command, such as aws opensearchmemory create-space, and accepts --cli-input-json file://request.json. Endpoints are https://osm.<region>.api.aws for spaces and https://<space-id>.osm.<region>.on.aws for events and memories; the SDK picks them automatically. The AWS MCP server is recommended for sandboxed execution and audit logging. If its tools report that the OpenSearch Memory service or an operation is not supported, run the same AWS CLI commands in a local shell instead. Do not substitute Amazon Bedrock AgentCore Memory or OpenSearch Serverless APIs: they are different services.
Prerequisites
- An AWS CLI v2 or boto3 version that includes OpenSearch Memory. Confirm with
aws opensearchmemory help, and confirm thataws opensearchmemory search-memories helplists--search-query. If either is missing, upgrade the AWS CLI before continuing. - Credentials with the
osm:actions you need (see references/security-and-encryption.md). - A Region that offers OpenSearch Memory; check AWS Services by Region. Pass
--regionon every command.
Concepts
| Term | What it is |
|---|---|
| Space | Container for one application's events and memories. ID sp- + 12 hex. States: CREATING, ACTIVE, UPDATING, DELETING, FAILED (a deleted space returns ResourceNotFoundException) |
| Memory strategy | Declared on the space (0-10). Types: SEMANTIC (facts), SUMMARY (session summaries), CUSTOM (your extraction prompt). A space with no strategies stores events only and extracts nothing |
| Event | A conversation turn or batch of turns (or a JSON object, or a document in S3) for one actor and session. Readable immediately |
| Memory | A fact or summary extracted from events asynchronously, or written directly with create-memory |
| Actor / session | actorId identifies the end user; sessionId groups one conversation. Every memory search is scoped to one actor |
Choose the task
| User wants to | Read |
|---|---|
| Create a space, add or change strategies, set retention, delete a space | references/spaces-and-strategies.md |
| Write conversation turns, read events back, write or edit memories directly, delete user data | references/events-and-memories.md |
| Search or list memories, build a search query, filter by time or metadata | references/search.md |
| IAM policies, per-user isolation, customer managed KMS key | references/security-and-encryption.md |
| An error, or memories not appearing | references/troubleshooting.md |
Rules that prevent the most common mistakes
- Extraction is asynchronous.
create-eventreturns once the event is stored.get-eventworks immediately, but a memory search only matches after the strategy's extraction trigger fires and the result is indexed. Poll; do not report failure after one empty search. - Wait for ACTIVE before the first write. Event and memory calls return
ResourceNotFoundException("...collection is not provisioned yet") until the space is ready, sometimes briefly after it reports ACTIVE. Wait for ACTIVE, then retry with backoff. - Wait for a settled state.
update-spaceanddelete-spacereturnConflictExceptionwhile the space is CREATING or UPDATING (andupdate-spacealso while DELETING). Runaws opensearchmemory wait space-active --space-id <id> --region <r>first. update-space --memory-strategiesreplaces the whole set. Read the current strategies withget-spaceand send every strategy you want to keep.- Search needs
--actor-id. Scope by actor with the request parameter, never withsystem_metadata.actor_idinside the query.search-memoriessearches all of the actor's sessions; to work with one session, usesearch-events --session-idsorlist-eventsfor its raw turns, orlist-memories --session-idsto browse its memories. - A search takes a query clause and an optional sort. Pass the OpenSearch query clause itself with
--search-query(API memberquery) and an optional--sort. There are nosize,fromor aggregation parameters: the CLI pages for you, and--max-itemscaps the results (APImaxResults/nextToken). - Deleting an event does not delete its memories. Delete memories with
delete-memory, or delete the whole space. - Route errors on the error code, not the HTTP status. Client errors arrive as HTTP 400 and server errors as HTTP 500.
Quick start
-
Create a space with fact and summary extraction, then wait for it.
aws opensearchmemory create-space --region us-east-1 \ --name support-bot-memory \ --memory-strategies '[{"type":"SEMANTIC","name":"user-facts"},{"type":"SUMMARY","name":"session-summaries"}]' aws opensearchmemory wait space-active --region us-east-1 --space-id <space-id> -
Write a conversation turn for one user and session.
$USER_TEXTholds the user's message, for example "I live in Porto and I am vegetarian."PAYLOAD=$(jq -n --arg text "$USER_TEXT" \ '{conversational:{unified:{source:{object:{messages:[{role:"USER",content:{text:$text}}]}}}}}') aws opensearchmemory create-event --region us-east-1 --space-id <space-id> \ --actor-id user-42 --session-id chat-1 --payload "$PAYLOAD" -
Later, search what was extracted for that user.
$QUERY_TEXTholds the question, for example "where does the user live".QUERY=$(jq -n --arg q "$QUERY_TEXT" '{neural:{memory_vector:{query_text:$q,k:5}}}') aws opensearchmemory search-memories --region us-east-1 --space-id <space-id> \ --actor-id user-42 --search-query "$QUERY"
Before running any command, ask the user for anything missing: Region, space ID or name, actor ID, and strategy names.
Security considerations
- Grant least privilege: only the
osm:actions each principal needs, scoped to specific space ARNs (arn:aws:osm:<region>:<account-id>:space/<space-id>). Give read-only agents only the read actions they use, such asosm:SearchMemories,osm:GetMemoryandosm:ListMemories(plusosm:GetEvent,osm:BatchGetEvent,osm:ListEventsandosm:SearchEventsto read events). - Isolate end users: use one
actorIdper end user and restrict principals with theosm:actorIdcondition key plus aNullcheck. - Use IAM roles with temporary credentials rather than long-term access keys, and follow the IAM security best practices.
- Use a customer managed KMS key for sensitive data. It can only be set at
create-space. Both endpoints use HTTPS, so requests are encrypted in transit. - Do not put secrets or credentials in events, memories or metadata. Metadata is copied into every derived memory and is searchable. Redact personal data before sharing logs or support material.
- Build JSON arguments with a tool (for example
jq -n --arg), not by pasting user text into a string, and validate IDs against the documented patterns. - Confirm with the user before
delete-space,delete-memory,delete-event, or anupdate-spacethat removes strategies or shortens retention. Deletes are permanent. - Review API activity in AWS CloudTrail (event source
osm.amazonaws.com). Space operations are logged as management events by default; event and memory operations are data events, which you enable with an advanced event selector on resource typeAWS::Osm::Space.
Not covered
- Amazon Bedrock AgentCore Memory: use the
amazon-bedrockskill. - Vector, semantic or hybrid search on your own OpenSearch Service domain or Serverless collection: use the
amazon-opensearch-serviceskill.
Guardrail — where this skill's own files live (MCP vs local install)
This skill can be loaded two ways, and they resolve the skill's own bundled files from different places. Determine how the skill was loaded before reading a reference or running a script:
- Loaded through the AWS MCP
retrieve_skilltool: The skill is not installed on the local filesystem. You MUST fetch each reference or script viaretrieve_skillwith thefileparameter (e.g.file="references/architecture.md"orfile="scripts/deploy.py"), and run the script from the returned content. Do NOTfile_readthese paths locally — they do not exist on disk. - Installed locally (e.g.
.kiro/skills/your-skill/or~/.claude/skills/your-skill/): Read and run files from the local skill directory using relative paths.
This distinction applies only to the skill's own packaged files. User data and
session artifacts are always read from and written to the user's working
directory. Never fetch or write customer data through retrieve_skill.
Files
6- SKILL.md
dea5a0ad8610.2 KB - references/events-and-memories.md
480e20a1928.0 KB - references/search.md
383badec3e6.7 KB - references/security-and-encryption.md
2325e3dbaf4.5 KB - references/spaces-and-strategies.md
a73bb4da837.9 KB - references/troubleshooting.md
3559584f0a4.4 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from aws/agent-toolkit-for-aws8
Amazon Aurora MySQL — creates, modifies, and advises on Aurora MySQL clusters specifically (MySQL-compatible engine, Aurora serverless, parallel query). Trigger for Aurora MySQL cluster operations, ACU sizing, I/O-Optimized storage, commitment pricing, or MySQL upgrade planning. Aurora MySQL uses fu
Amazon Aurora PostgreSQL — creates, modifies, and advises on Aurora PostgreSQL clusters specifically (PostgreSQL-compatible engine, Aurora serverless, express configuration, pgvector, Babelfish). Trigger for Aurora PostgreSQL cluster operations, express-configuration quick-start, ACU sizing, I/O-Opt
Builds generative AI applications on Amazon Bedrock. Covers model invocation (Converse API, InvokeModel), RAG with Knowledge Bases, Bedrock Agents, Guardrails, and AgentCore (including the Harness managed agent loop). Applies when invoking models, setting up or migrating Knowledge Bases to Managed,
Runs quantum workflows on AWS / Amazon Braket: circuits and algorithms, QPU/device and ARN discovery, LocalSimulator, tasks, program sets, Hybrid Jobs, S3 results, pricing, account setup, and spending limits. Applies to quantum programs and execution, AHS, OpenQASM, pulse control, reservations, note
Manages Amazon DocumentDB end-to-end — serverless-on-8.0 cluster setup, TLS/VPC/driver config, flexible-schema and vector-search data modeling, MongoDB compatibility assessment, DMS-based migration, slow-query diagnosis, major version upgrades (4.0->5.0->8.0), Well-Architected reviews (41-check wa_r
Creates and automates custom image builds with EC2 Image Builder - Linux, Windows, and macOS AMIs, and container images to ECR. Covers the build IAM role, Amazon-managed and custom components, image recipes, infrastructure and distribution configuration (launch templates, SSM parameters, other Regio
Activate when developers have latent caching needs: slow API responses, database read bottlenecks, DynamoDB throttling or cost, read/write-through caching, RDS/Aurora scaling pressure, Bedrock latency or cost, or adding a cache; activate when working with Redis, Valkey, Memcached, cache-aside patter
Builds, runs, debugs, and operates event-driven applications using EventBridge Event Bus - a managed, centrally governed publish/subscribe event bus that an organization can share across many teams and accounts. Applicable when workloads need event-driven architectures, decoupling, choreography, asy
Related devops skillsscan passed
Use this skill when creating, running, reattaching to, listing, stopping, or removing Docker Sandboxes (the standalone `sbx` CLI that runs AI coding agents in isolated microVMs), even if the user just says they want to "run claude in a sandbox", "isolate an agent from my repo", "give an agent its ow
Use this skill to search archived VSS video or indexed live RTSP camera streams already registered in a configured deployment — by natural-language, similarity, attribute, object-ID, or lexical tag query — and for follow-up questions about displayed search results or their verification. For fresh cl
Post-deploy canary monitoring. Use for: monitor after deploy, canary check. (gstack)
Investigates Google Cloud networking issues by analyzing GCP logs, metrics, and diagnostics. Use when investigating dropped network traffic, packet drops, drop reasons, VPC Flow Logs (including Private Service Connect / PSC, serverless / App Engine Direct VPC, and cost estimation), Cloud NAT, firewa