Skip to content

Cortex Plugin

Cortex is an OpenClaw/ClawDBot plugin that gives AI agents persistent memory with personality traits, bond evolution, and full context assembly — all powered by YantrikDB’s 5-index architecture.

While the MCP server gives any MCP client raw access to YantrikDB’s memory tools, Cortex adds an agent personality layer on top: traits that evolve per-user, relationships that grow over time, and a single process_turn() call that handles everything.

Terminal window
pip install yantrik-memory
yantrik-memory init

Or as an OpenClaw plugin:

Terminal window
cd ~/.openclaw/skills
git clone https://github.com/yantrikos/cortex.git
pip install -e cortex
FeatureYantrikDB (raw)Cortex
Memory storagerecord() / recall()remember() / recall() with agent scoping
Personality9 evolving traits per user
Relationships6-stage bond evolution
Context assemblyget_full_context() with mood, intent, guidance
Single entry pointprocess_turn() does everything
Knowledge graphrelate() / entity_profile()relate() / get_entity()
Cognitive maintenancethink()think() (passthrough)
from yantrik_memory import YantrikMemory
mem = YantrikMemory()
# Single entry point — handles everything
context = mem.process_turn(
agent_id="assistant",
user_id="alex",
message="I prefer concise responses. We're using FastAPI.",
)
# context includes:
# - memories: relevant recalled memories with scores
# - traits: {'conciseness': 0.55, 'helpfulness': 0.5, ...}
# - bond: {'level': 'acquaintance', 'score': 0.08}
# - personality_guidance: "Be more concise in responses."
# - mood: {'mood': 'neutral', 'confidence': 0.5}
# - intent: 'casual'

Here’s Cortex running inside OpenClaw. The agent remembers context across turns, learns preferences, and builds a profile.

Turn 1 — Alex introduces himself:

Alex: Hey! I’m Alex. I’m a backend engineer at a startup. We’re building a task management app and I need help setting up the API.

Agent: Hi Alex. What stack are you using? What API help do you need?

Turn 2 — Alex shares preferences:

Alex: We’re using Python with FastAPI. I prefer keeping things simple — no over-engineering.

Agent: (provides a clean, minimal FastAPI project structure)

Turn 3 — Agent remembers the database preference:

Alex: Remember — I always use PostgreSQL for production and SQLite for local dev.

Agent: (provides database setup code using SQLAlchemy with the exact backends Alex specified)

Turn 4 — Alex asks what the agent remembers:

Alex: What do you remember about me?

Agent:

  • Backend engineer at a startup
  • Building a task management app
  • Using Python with FastAPI
  • Prefer simple solutions, no over-engineering
  • Always use PostgreSQL for production, SQLite for local dev

Behind the scenes, YantrikDB tracked:

  • 5 memories stored across the Vector, Graph, and Temporal indexes
  • Traits evolved: helpfulness: 0.55, conciseness: 0.55
  • Bond level: acquaintance after 4 interactions
  • Knowledge graph: Alex → works_at → Startup, TaskApp → uses → FastAPI

9 traits that evolve bidirectionally based on user interactions:

TraitPositive signalsNegative signals
Humor”haha”, “funny”, “lol""be serious”, “no jokes”
Empathy”thank you”, “appreciate""don’t care”, “whatever”
Curiosity”interesting”, “tell me more""boring”, “skip”
Creativity”creative”, “innovative""just do the normal thing”
Helpfulness”helpful”, “perfect""useless”, “not helpful”
Honesty”honest”, “straightforward""misleading”, “fake”
Conciseness”concise”, “to the point""elaborate”, “more detail”
Formality”formal”, “professional""casual”, “chill”
Directness”straight to the point""gentle”, “diplomatically”

Negative signals are weighted 33% heavier to prevent one-way trait inflation. Traits decay toward 0.5 (neutral) with a 30-day half-life.

Relationships grow logarithmically through 6 stages:

StageThresholdDescription
Stranger0.00No established relationship
Acquaintance0.15Basic familiarity
Familiar0.35Regular interaction
Companion0.55Comfortable working relationship
Trusted0.75Deep trust, anticipates needs
Bonded0.90Strong mutual understanding

Milestones are tracked at 1, 5, 10, 25, 50, 100, 250, and 500 interactions. Bonds decay after 60 days of inactivity.

┌─────────────────────────────┐
│ Cortex │ Agent-facing API
│ traits, bonds, context │
├─────────────────────────────┤
│ YantrikDB │ Storage engine
│ Vector · Graph · Temporal │
│ Decay Heap · KV │
└─────────────────────────────┘
Single SQLite file

Cortex is the brain layer. YantrikDB is the memory layer. Together they give agents persistent, evolving intelligence with zero external dependencies.