Skip to main content

Couchbase Agent Memory Python SDK

Docs Python versions

The official Python SDK for Couchbase Agent Memory, an enterprise-ready memory layer for AI agents.

Agent Memory allows AI agents to maintain persistent context and personalize interactions across sessions. It stores conversation history and facts, and handles embeddings, summarization, and semantic retrieval, so you don't need to build session tables or retrieval logic.

The Agent Memory server runs fully managed on Couchbase Capella, or self-managed as a Docker container backed by a Capella or Couchbase Server Enterprise Edition cluster.

Before using the SDK, request a trial of Couchbase Agent Memory.

Prerequisites

  • Python 3.12 or later.
  • A running Agent Memory server, version 1.1.0 or later. To set up a server, see the Agent Memory documentation.

Installation

pip install couchbase-agent-memory

Quickstart

from agentmemory import AgentMemoryClient, ChatMessage

with AgentMemoryClient(base_url="http://localhost:8080") as client:
    user = client.create_user(user_id="customer-42", name="Example Customer")
    session = user.create_session(session_id="conv-100")

    # Store a conversation exchange, tagged with the agent that handled it
    session.add_memory(
        messages=[
            ChatMessage(
                user_content="My order hasn't arrived.",
                assistant_content="I'll look into that. What's your order number?",
            )
        ],
        annotations={"agent": "support-bot"},
    )

    # Store a standalone fact
    session.add_memory(
        facts=["Customer is in the EU timezone."],
        annotations={"agent": "support-bot"},
    )

    # Recall relevant context before the agent's next turn
    results = session.search_memory(query="shipping delay")
    for block in results.memory_blocks:
        print(block.fact or block.message.user_content)

If your server requires authentication, pass a token:

AgentMemoryClient(base_url="<your-server-url>", token="<your-token>")

On managed Agent Memory, the token is an Agent Memory API key that you create in Capella. You must also add your IP address to the server's allowed IP addresses.

On a self-managed server with authentication enabled, the token is a JSON Web Token (JWT) from your OpenID Connect (OIDC) identity provider.

Features

  • Multiple memory types, including conversational, semantic, and profile memory, in a single retrieval system, to enable scalable, context-aware multi-agent systems.
  • Semantic search within a session or across all of a user's sessions.
  • Annotations that tag memory blocks so you can filter recall by exact match.
  • Memory decay through time to live (TTL) settings per block, per session, or server-wide.
  • Time-range filtering that recalls memories by when they were created or stored.
  • Conflict resolution through timestamps on every memory, so your agent can prefer the most recent of conflicting memories.
  • Custom extraction prompts that steer what Agent Memory extracts for each use case.
  • High availability through cluster mode, which runs multiple nodes behind a load balancer to handle more traffic and keep processing memories if a node fails.
  • Enterprise-grade security, with token authentication and Role-Based Access Control.
  • Full traceability for governance and debugging, through structured logs of memory operations and operational metrics.
  • Sync and async clients, with AsyncAgentMemoryClient for asyncio applications.

Framework Integrations

Agent Memory works with any agent framework, including LangGraph, CrewAI, LlamaIndex, and Strands Agents. Call search_memory() before each agent turn to add relevant context to the prompt, and add_memory() after the turn to store the exchange.

Hermes Agent

The SDK includes a memory-provider plug-in for Hermes Agent 0.7.0 (v2026.4.3) or later. The plug-in recalls relevant memories before each turn and captures each exchange in the background.

To install the plug-in:

pip install "couchbase-agent-memory[hermes]"
agentmemory-hermes install

Then activate and configure the plug-in in Hermes Agent. Hermes Agent supports only 1 external memory provider at a time. If you use another provider, turn it off before you activate this plug-in.

For further instructions, see Install the Agent Memory Plug-in for Hermes Agent.

Documentation

For more details about this SDK, see:

Licensing and Support

Couchbase Agent Memory use and enterprise support is exclusively available by licensing Couchbase AI Data Plane, which also entitles use and enterprise support of Couchbase Agent Catalog and Couchbase MCP Server.

Licensed customers can raise issues through the Couchbase support portal.

Privacy

For information about how Couchbase collects, protects, and processes information, see the Couchbase Privacy Policy.

Metadata

Release files for couchbase-agent-memory 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for couchbase-agent-memory 1.1.0
File Interpreter ABI Platform Actions
couchbase_agent_memory-1.1.0-py3-none-any.whl Python 3 none any Details for couchbase_agent_memory-1.1.0-py3-none-any.whl

Release files / couchbase_agent_memory-1.1.0-py3-none-any.whl

Download URL couchbase_agent_memory-1.1.0-py3-none-any.whl
Size 65.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d8210faee4fad3403be8f30a16940227ebbaef376949c0f9ff1d900ac02ce92
BLAKE2b-256 checksum
How to use checksums
e9a38648c1a25fe516528b46541e74035a534083874ceffd45a2edaeaa395d0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for couchbase-agent-memory 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page