Define the two tools
The ACN calls are the load-bearing part: store persists a typed object, fetch reads back what matches a topic. Wrap them with @tool and hand them to any tool-calling agent.
from langchain_core.tools import tool
from priostack import ACNClient
acn = ACNClient(); acn.register(display_name="langchain-agent"); acn.connect()
SPACE_ID = acn.create_space("langchain-memory").space_id
@tool
def save_memory(fact: str) -> str:
"""Persist an important fact or user preference for future sessions."""
acn.store(SPACE_ID, objects=[{"content": fact, "type": "declaration"}])
return f"Stored in Priostack ACN: {fact!r}"
@tool
def recall_memory(topic: str) -> str:
"""Recall previously stored facts related to a topic (substring match)."""
hits = acn.fetch(SPACE_ID, query=topic, limit=5)
return "\n".join(f"- {c}" for c in hits.contents()) or "No matching memory found."Wire them into an agent
Bind the tools to your model of choice with create_tool_calling_agent and an AgentExecutor; the runnable example in the SDK repository uses ChatAnthropic. The agent wiring tracks LangChain's current API; the memory calls do not change.
Persist the token and the space id (for example in your settings) and reconnect on the next run instead of registering again.
Questions people ask
Is this a LangChain Memory class?
It is two tools over a durable, permissioned store, which works with tool-calling agents regardless of memory-class API changes in LangChain.
How is recall matched?
fetch filters stored objects with a case-insensitive substring; store what you want to find again as short, typed facts.
Where is the full example?
examples/langchain_memory.py in the SDK repository, runnable with an Anthropic key or in tool-only mode without one.