> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2-codex-docs-audit-20260719-0149.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory Operations with AgentOSClient

> Full CRUD over a remote user's memories with AgentOSClient: create, list, get, update topics, read memory topics and per-user stats, then delete and verify.

Manage user memories using AgentOSClient.

```python memory_operations.py theme={null}
"""
Memory Operations with AgentOSClient

This example demonstrates how to manage user memories using
AgentOSClient.

Prerequisites:
1. Start an AgentOS server with an agent that has update_memory_on_run=True
2. Run this script: python 03_memory_operations.py
"""

import asyncio

from agno.client import AgentOSClient

# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------


async def main():
    client = AgentOSClient(base_url="http://localhost:7777")
    user_id = "example-user"

    print("=" * 60)
    print("Memory Operations")
    print("=" * 60)

    # Create a memory
    print("\n1. Creating a memory...")
    memory = await client.create_memory(
        memory="User prefers dark mode for all applications",
        user_id=user_id,
        topics=["preferences", "ui"],
    )
    print(f"   Created memory: {memory.memory_id}")
    print(f"   Content: {memory.memory}")
    print(f"   Topics: {memory.topics}")

    # List memories for the user
    print("\n2. Listing memories...")
    memories = await client.list_memories(user_id=user_id)
    print(f"   Found {len(memories.data)} memories for user {user_id}")
    for mem in memories.data:
        print(f"   - {mem.memory_id}: {mem.memory[:50]}...")

    # Get a specific memory
    print(f"\n3. Getting memory {memory.memory_id}...")
    retrieved = await client.get_memory(memory.memory_id, user_id=user_id)
    print(f"   Memory: {retrieved.memory}")

    # Update the memory
    print("\n4. Updating memory...")
    updated = await client.update_memory(
        memory_id=memory.memory_id,
        memory="User strongly prefers dark mode for all applications and websites",
        user_id=user_id,
        topics=["preferences", "ui", "accessibility"],
    )
    print(f"   Updated memory: {updated.memory}")
    print(f"   Updated topics: {updated.topics}")

    # Get memory topics
    print("\n5. Getting all memory topics...")
    topics = await client.get_memory_topics()
    print(f"   Topics: {topics}")

    # Get user memory stats
    print("\n6. Getting user memory stats...")
    stats = await client.get_user_memory_stats()
    print(f"   Stats: {len(stats.data)} entries")

    # Delete the memory
    print(f"\n7. Deleting memory {memory.memory_id}...")
    await client.delete_memory(memory.memory_id, user_id=user_id)
    print("   Memory deleted")

    # Verify deletion
    print("\n8. Verifying deletion...")
    memories_after = await client.list_memories(user_id=user_id)
    print(f"   Remaining memories: {len(memories_after.data)}")


# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    asyncio.run(main())
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[os]" chromadb ddgs openai
    ```
  </Step>

  <Step title="Export your API keys">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Clone Agno">
    Clone the repository and run the remaining commands from its root:

    ```bash theme={null}
    git clone --branch v2.7.4 --depth 1 https://github.com/agno-agi/agno.git
    cd agno
    ```
  </Step>

  <Step title="Start the AgentOS server">
    In another terminal, start the [client example server](/examples/agent-os/client/server) on port 7777:

    ```bash theme={null}
    python cookbook/05_agent_os/client/server.py
    ```
  </Step>

  <Step title="Run the example">
    Run the example from the repository root:

    ```bash theme={null}
    python cookbook/05_agent_os/client/03_memory_operations.py
    ```
  </Step>
</Steps>

Full source: [cookbook/05\_agent\_os/client/03\_memory\_operations.py](https://github.com/agno-agi/agno/blob/v2.7.4/cookbook/05_agent_os/client/03_memory_operations.py)
