SCM 1.1 runs inside the Python process that owns the agent. The default path does not start an SCM service and does not require an SCM endpoint.
python -m venv .venv
source .venv/bin/activate
pip install scm-memoryfrom scm import SCM
with SCM(user_id="alice") as memory:
added = memory.add_memory("Alice prefers concise technical answers.")
recalled = memory.search_memory("communication preference")
print(recalled["memories"])
memory.sleep("deep")
print(memory.wake_summary()["narrative"])
memory.forget(added["memory_id"])The same user state is restored after process restart from ~/.scm. Override
that location with SCM_DATA_DIR or the data_dir constructor argument.
pip install "scm-memory[langchain]"from langchain.agents import create_agent
from scm import SCM
memory = SCM(user_id="alice")
agent = create_agent(
model=model,
tools=[...],
middleware=[memory.langchain()],
)
agent.invoke({
"messages": [{"role": "user", "content": "My deployment region is Pune."}]
})SCM recalls before the model call and durably captures human messages. Explicit memory tools are also available to the model for facts learned from external tools, user-requested forgetting, and sleep/wake workflows.
from scm import SCM, SCMContext
from scm.langchain import create_scm_agent
memory = SCM(namespace="my-app")
agent = create_scm_agent(model=model, tools=[...], memory=memory)
agent.invoke(
{"messages": [{"role": "user", "content": "I use metric units."}]},
context=SCMContext(user_id="alice", thread_id="thread-1"),
)For production workers, configure PostgreSQL in the environment:
export SCM_DATABASE_URL='postgresql://user:password@database/scm'Identity comes from SCMContext, never from model tool arguments. Same-user
operations serialize while different users can proceed concurrently.
export SCM_DATA_DIR="$HOME/.scm"
export SCM_ENCRYPTION_KEY='base64-or-passphrase-managed-by-your-secret-store'Provider credentials are optional. When a LangChain model is attached, SCM attempts to reuse it for concept extraction and falls back to offline heuristics if structured extraction is unavailable.
REST, MCP, and JavaScript are optional secondary surfaces. See Integrations and Deployment. JavaScript is documented as a REST client, not an embedded runtime.