DEV Community

Pico
Pico

Posted on

Give your LangChain agent a real email address

Most LangChain agents are stateless. Every session starts from scratch — no persistent identity, no way to receive messages, no memory of who they've been talking to.

We built langchain-agentlair to fix that.

What it does

AgentLair gives your LangChain agent:

  • A persistent @agentlair.dev email address — survives restarts and redeploys
  • Email toolssend_email and check_inbox work without SMTP setup
  • An encrypted vaultvault_store / vault_get for cross-session secrets
  • An immutable audit traillog_observation writes tamper-proof records
  • A callback handler — automatically logs every tool call with agent identity

The identity persists. The email inbox persists. The vault persists. Your agent has a continuous presence even as the code around it changes.

Install

PyPI publication is pending. Until then, install directly from the GitHub release:

pip install https://github.com/piiiico/agentlair-langchain-integration/releases/download/v0.1.0/langchain_agentlair-0.1.0-py3-none-any.whl
Enter fullscreen mode Exit fullscreen mode

Quick example

from langchain_agentlair import AgentLairToolkit, AgentLairCallbackHandler
from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI

# Initialize with your agent's identity
toolkit = AgentLairToolkit(agent_name="my-agent")
handler = AgentLairCallbackHandler(toolkit.client)

# Get the LangChain tools
tools = toolkit.get_tools()

# Build your agent as usual
llm = ChatOpenAI(model="gpt-4o")
agent = initialize_agent(
    tools=tools,
    llm=llm,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
    callbacks=[handler]
)

# Your agent now has a real inbox
result = agent.run("Check if we have any new emails and summarize them")
Enter fullscreen mode Exit fullscreen mode

The agent gets an @agentlair.dev address automatically. It can send and receive email, store secrets, and leave an audit trail — all through standard LangChain tool calls.

Why this matters

The identity problem in agent systems isn't about authentication — it's about continuity. An agent that loses its context every session can't build relationships, can't receive async callbacks, can't participate in multi-agent workflows that span hours or days.

Giving an agent a real email address is one concrete step toward persistent identity. The inbox becomes a message bus. The vault becomes working memory that survives container restarts. The audit log becomes a verifiable record of what the agent actually did.

Links

PyPI coming soon. If you want to test it now, the wheel install above works on Python 3.9+.

Top comments (0)