One signed binary. Every feature compiled in. Free to run. Install Crowkis →
← back to the Roost
guidesJune 17, 2026· 5 min read

Giving an agent memory from Python: CMEM in practice

The memory commands from application code, store facts, recall them semantically, and watch consolidation retire the stale ones. A worked example in Python.

Agent memory is a few commands, and from Python it's a few method calls. The pattern: extract durable facts from a conversation, store them scoped to (agent, user), and recall them by meaning on the next turn, letting consolidation keep the picture current.

store, consolidate, recall
from crowkis import CrowkisClient

mem = CrowkisClient(host="127.0.0.1", port=6379)
AGENT, USER = "support", "u_42"

# learn three things across a conversation
mem.cmemset(AGENT, USER, "prefers email over phone")
mem.cmemset(AGENT, USER, "moved to Berlin in March")
mem.cmemset(AGENT, USER, "no longer in Munich")   # retires the old location

# recall by meaning, top-3, recency-blended
facts = mem.cmemget(AGENT, USER, "where does this customer live?", k=3)
print(facts[0])   # -> "moved to Berlin in March"

Because memory consolidates, you don't have to hunt down and delete the stale fact, storing the contradicting one retires it automatically. The recall is ranked by relevance blended with recency, so the current answer surfaces first.

extract facts, and honour erasure
# pull durable facts straight out of a transcript (deterministic, no model call)
mem.cmemextract(AGENT, USER, transcript_text)

# bi-temporal: what did we believe on April 1st?
mem.cmemasof(AGENT, USER, "address", at="2026-04-01")

# right to be forgotten
mem.cmemforget(AGENT, USER, "payment details")
In plain words: Tell the agent facts, ask by meaning, and let it retire what changed. Storing 'moved to Berlin' quietly forgets 'lives in Munich', no manual cleanup.