Geniffy for LangChain
Give a LangChain agent a memory of each of your users. Add one piece of middleware, and before every call the model gets the user's briefing: where things stand, what is due, the rules that apply, what happened, and what is known that bears on their message. When the agent has its answer, the run is saved, tool calls included, into one memory for the whole conversation. When nothing is known, the model is told so, and says so instead of guessing.
pip install langchain-geniffy
Set GENIFFY_API_KEY from API keys in the Geniffy app. Keep it on your server.
The middleware
from dataclasses import dataclass
from langchain.agents import create_agent
from langchain_geniffy import GeniffyMemory
from langgraph.checkpoint.memory import InMemorySaver
@dataclass
class User:
id: str
agent = create_agent(
"anthropic:claude-opus-5-5",
system_prompt="You are a helpful assistant.",
middleware=[GeniffyMemory(space=lambda runtime: f"user_{runtime.context.id}")],
context_schema=User,
checkpointer=InMemorySaver(), # or your database's checkpointer
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Who signs the Lumen renewal?"}]},
{"configurable": {"thread_id": chat.id}}, # the conversation
context=User(id=user.id), # from your own sign-in
)
- Before each model call, the user's briefing goes in the system prompt, after your own: where things stand, what is due or was promised, the rules that apply, what happened, then what is known that bears on their last message, each line dated. In a run with tools, Geniffy is asked once, not once per step.
- When the agent has its answer, the run is saved to that user's space: what they said, each tool the agent called and what it returned, and the answer. A conversation is one memory however long it gets, and each run sends only what is new. Where saving got to is kept in the agent's state, so with a checkpointer nothing is sent twice, across restarts and on every server, and a save that fails goes with the next run.
- If Geniffy can't be reached, the agent goes on without memory, and
on_errorhears about it.
Options:
project: the project the agent works on, a string or a function of the runtime. The briefing keeps to it, and what is saved is labelled with it.session: the conversation, a string or a function of the runtime, for an app that keeps the history itself instead of in a checkpointer. With neither, each run is a memory of its own.briefing=Falsereads only what bears on the user's last message;budget_charsis the most the briefing adds to the prompt (6,000 characters unless you say).remember=Falseto only read, andinstructionsto change what the model is told about the memory.client/async_clientto bring your owngeniffy.Geniffy/geniffy.AsyncGeniffy. Async agents (ainvoke,astream) use the async client.
An account without the briefing switched on is given what bears on the user's last message instead, and the briefing is tried again ten minutes later.
Tools
To let the agent decide when to look something up or save it:
from langchain_geniffy import geniffy_tools
agent = create_agent(
"anthropic:claude-opus-5-5",
tools=geniffy_tools(space=lambda runtime: f"user_{runtime.context.id}"), # recall and remember
context_schema=User,
)
The tools read the user from the runtime, so the model never sees or chooses whose memory it reads.
Retriever
from langchain_geniffy import GeniffyRetriever
docs = GeniffyRetriever(space="user_1042", k=5).invoke("the Lumen renewal")
docs[0].metadata # {"id": ..., "kind": "people", "about": "Priya Nair", "said_at": "...", "source": "Call with Priya", ...}
One space per user
space is required: the user this is for, as a string or a function of the agent's runtime. Each space is a
memory of its own, and nothing else can read it. space=None is your own memory, never your users' data. A
blank space, or None from your function, is refused, so a user with no id never lands in your own memory. When
a user deletes their account, forget them with Geniffy().forget_space(...) from the
geniffy SDK.
Develop
pip install -e ".[test]" && pytest # through LangChain's own create_agent, with a scripted model and the
# real geniffy client against a stand-in for the API
Security
Report a vulnerability to ops@geniffy.com, not in a public issue. See the security policy.
Metadata
Release files for langchain-geniffy 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langchain_geniffy-0.2.0.tar.gz | 18.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_geniffy-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.2 kB
Release files / langchain_geniffy-0.2.0.tar.gz
| Download URL | langchain_geniffy-0.2.0.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7060b3e538ad7e5a6e42547d0dedba7ffe7790265e40d4aafafd1104bf7f04a2
|
|
BLAKE2b-256 checksum How to use checksums |
541c439e2da222d7bb9ce72dd325344b5aa19421a2ae4d609346db908d34a763
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency logRelease files / langchain_geniffy-0.2.0-py3-none-any.whl
| Download URL | langchain_geniffy-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
52ca8c1f9a3f674a13a2d97c5408d47c2b58531207e03b77b481afdad6b8bb87
|
|
BLAKE2b-256 checksum How to use checksums |
67fbac81ae4fcd4efc6780730331982dbbda522d8a56c2a4cb562fcf5e898d77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.
Transparency log