from kernle.entity import Entity
from kernle.stack import SQLiteStack
from kernle.models.anthropic import AnthropicModel
# Create the core
entity = Entity()
# Bind a model
entity.set_model(AnthropicModel())
# Attach a memory stack
stack = SQLiteStack(db_path="~/.kernle/stacks/mystack/memory.db")
entity.attach_stack(stack, alias="mystack", set_active=True)
# Write memories (with full provenance)
# Note: In strict mode (default), derived_from is required for most memory types.
# Use strict=False for quick experimentation.
entity.episode(
"Optimized the sync pipeline",
"Reduced latency from 300ms to 100ms",
lessons=["Batching network calls is worth the complexity"],
)
entity.belief(
"Batch processing outperforms sequential I/O",
confidence=0.85,
)
# Search
results = entity.search("performance optimization")
for r in results:
print(f"{r.memory_type}: {r.content[:80]}")
# Load working memory
context = entity.load(token_budget=8000)