Agent frameworks

Camel AI

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

Camel AI is a multi-agent framework for Python. SurrealDB Agent Memory gives its ChatAgents shared long-term memory across runs and agents. There is no dedicated adapter. The Python SDK (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.

Note

Spectron was the project name for SurrealDB Agent Memory. These type names
will be renamed in a future release.

pip install camel-ai
pip install --pre surrealdb
export SPECTRON_ENDPOINT="https://api.spectron.example"
export SPECTRON_CONTEXT="acme-prod"
export SPECTRON_API_KEY="sk-spec-..."

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

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 relevant memory, prepend it to the system message, run the step, then store the exchange:

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.

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.

Was this page helpful?