Skip to content

CAMEL-AI integration

Astrocyte as role-based memory for CAMEL-AI multi-agent role-playing systems.

Module: astrocyte.integrations.camel_ai Pattern: Role-scoped memory — write/read with role attribution and per-role banks Framework dependency: camel-ai (optional)

Terminal window
pip install astrocyte camel-ai
from astrocyte import Astrocyte
from astrocyte.integrations.camel_ai import AstrocyteCamelMemory
brain = Astrocyte.from_config("astrocyte.yaml")
# Role-based memory for multi-agent role-playing
memory = AstrocyteCamelMemory(
brain,
bank_id="simulation",
role_banks={"doctor": "doctor-bank", "patient": "patient-bank"},
)
# Write with role attribution
await memory.write("Patient reports headaches", role="doctor", agent_id="agent-1")
await memory.write("I've had headaches for a week", role="patient")
# Read scoped by role
results = await memory.read("symptoms", role="doctor")
context = await memory.get_context("patient history", role="doctor")
# Synthesize across role's memory
answer = await memory.reflect("What symptoms have been reported?", role="doctor")
# Clear a role's memory
await memory.clear(role="patient")

Memories are tagged with role:{role_name} and camel-ai for filtering. Each role can have its own bank or share a common bank.

MethodAstrocyte call
write(content, role=...)brain.retain() with role metadata + tags
read(query, role=...)brain.recall() scoped to role’s bank
get_context(query, role=...)brain.recall() → formatted string
reflect(query, role=...)brain.reflect() on role’s bank
clear(role=...)brain.clear_bank() on role’s bank

A medical simulation where doctor and patient roles have separate memories:

import asyncio
from astrocyte import Astrocyte
from astrocyte.integrations.camel_ai import AstrocyteCamelMemory
brain = Astrocyte.from_config("astrocyte.yaml")
memory = AstrocyteCamelMemory(
brain,
bank_id="medical-sim",
role_banks={"doctor": "doctor-notes", "patient": "patient-history"},
)
async def main():
# Patient describes symptoms (stored in patient bank)
await memory.write(
"I've had recurring headaches for 2 weeks, mostly in the morning",
role="patient",
)
await memory.write(
"The pain is usually a 6/10, located behind the eyes",
role="patient",
)
# Doctor records observations (stored in doctor bank)
await memory.write(
"Patient presents with tension-type headache pattern",
role="doctor",
agent_id="dr-smith",
)
# Doctor reviews patient history
history = await memory.read("headache symptoms", role="patient")
for hit in history:
print(f" Patient said: {hit['text']}")
# Doctor synthesizes diagnosis
assessment = await memory.reflect(
"Based on patient symptoms, what is the likely diagnosis?",
role="doctor",
)
print(f"Assessment: {assessment}")
# Get formatted context for prompt injection
ctx = await memory.get_context("patient symptoms", role="patient")
print(ctx)
asyncio.run(main())

AstrocyteCamelMemory(brain, bank_id, *, role_banks=None)

Section titled “AstrocyteCamelMemory(brain, bank_id, *, role_banks=None)”
ParameterTypeDescription
brainAstrocyteConfigured Astrocyte instance
bank_idstrShared simulation bank
role_banksdict[str, str]Role name → bank ID for per-role isolation