# Camel AI

Adding persistent memory to Camel AI agents with the SurrealDB Agent Memory SDK.

[Camel AI](https://www.camel-ai.org/) is a multi-agent framework for Python. SurrealDB Agent Memory gives its `ChatAgent`s shared long-term memory across runs and agents. There is no dedicated adapter. The [Python SDK](/docs/agent-memory/integrations/sdks/python.md) (`surrealdb`) supplies the memory operations, either as tools or wrapped around each step.

> [!NOTE]
> This is an integration guide. It wires the SurrealDB Agent Memory SDK into Camel AI; adapt to your installed Camel AI version.

## Installation

> [!NOTE]
> `Spectron` was the project name for SurrealDB Agent Memory. These type names
> will be renamed in a future release.

```bash
pip install camel-ai
pip install --pre surrealdb
```

```bash
export SPECTRON_ENDPOINT="https://api.spectron.example"
export SPECTRON_CONTEXT="acme-prod"
export SPECTRON_API_KEY="sk-spec-..."
```

## Memory as function tools

Expose SurrealDB Agent Memory through CAMEL's `FunctionTool` so an agent can recall and remember on its own:

```python
import os
from camel.agents import ChatAgent
from camel.toolkits import FunctionTool
from surrealdb import Spectron

memory = Spectron(
    endpoint=os.environ["SPECTRON_ENDPOINT"],
    context=os.environ["SPECTRON_CONTEXT"],
    api_key=os.environ["SPECTRON_API_KEY"],
)
scope = ["org/acme/user/alice"]

def remember(text: str) -> str:
    """Store a durable fact for later recall."""
    memory.remember(text, scopes=scope)
    return "stored"

def recall(query: str) -> str:
    """Retrieve relevant memory for a query."""
    return memory.query_context(query, k=8, lens=scope)

agent = ChatAgent(
    system_message="Use recall before answering and remember anything worth keeping.",
    tools=[FunctionTool(remember), FunctionTool(recall)],
)

response = agent.step("What do you know about Alice's role?")
print(response.msgs[0].content)
```

## Recall around a step

Recall relevant memory, prepend it to the system message, run the step, then store the exchange:

```python
block = memory.query_context(user_message, k=8, lens=scope)

agent = ChatAgent(system_message=f"You are a helpful assistant.\n\n## Memory\n{block}")
response = agent.step(user_message)

memory.remember_many(
    [
        {"role": "user", "content": user_message},
        {"role": "assistant", "content": response.msgs[0].content},
    ],
    scopes=scope,
)
```

> [!NOTE]
> Camel AI's own `AgentMemory` (chat-history and vector memory) manages a single agent's context window. SurrealDB Agent Memory complements it with a durable, shared substrate: server-side extraction, hybrid recall, and provenance across agents.

## Scope per user

Pass a `scope` on every call to isolate memory. A scope is a slash path or an array of paths, for example `["org/acme/user/alice"]`. Register paths with `spectron scopes create` before first use.

## Next steps

- [Python SDK](/docs/agent-memory/integrations/sdks/python.md): the full client surface
- [MCP server](/docs/agent-memory/integrations/mcp-server/install.md): if your host speaks MCP instead
