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 is told what is known about the user, each line with where it came from; when the agent has its answer, the exchange is saved. 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
@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,
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Who signs the Lumen renewal?"}]},
context=User(id=user.id), # from your own sign-in
)
- Before each model call, what is known that bears on the user's last message goes in the system prompt, after your own. In a run with tools, Geniffy is asked once, not once per step.
- When the agent has its answer, the exchange is saved to that user's space.
- If Geniffy can't be reached, the agent goes on without memory, and
on_errorhears about it.
Options: remember=False to only read, instructions to change what the model is told about the memory, and
client / async_client to bring your own geniffy.Geniffy / geniffy.AsyncGeniffy. Async agents
(ainvoke, astream) use the async client.
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
Security
Report a vulnerability to ops@geniffy.com, not in a public issue. See the security policy.
Metadata
Release files for langchain-geniffy 0.1.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.1.0.tar.gz | 11.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_geniffy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / langchain_geniffy-0.1.0.tar.gz
| Download URL | langchain_geniffy-0.1.0.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfc1fe0718b60f72cdbd5c8757c22b11e6492adf48f34f59b0b068fc405be8a9
|
|
BLAKE2b-256 checksum How to use checksums |
462eebda580b0ca6283a92e68098a354d0be0f27125685d26ed5bf283db23fe0
|
| 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 6, 2026.
Transparency logRelease files / langchain_geniffy-0.1.0-py3-none-any.whl
| Download URL | langchain_geniffy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9e149910c4036d1b4c4dfcaf387fdfab572581cb78427c2f45e041909430500
|
|
BLAKE2b-256 checksum How to use checksums |
ab5218dfd0726870dab3abf281e40620aa159be80a794d9d42f3ea6538cf7134
|
| 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 6, 2026.
Transparency log