Skip to main content

PiQrypt Verifiable AI Agent Memory bridge for LangChain

Project description

piqrypt-langchain

Verifiable AI Agent Memory for LangChain.

PyPI Downloads License: MIT PiQrypt

Every tool call, LLM response, chain execution, and agent action — signed, hash-chained, tamper-proof.

pip install piqrypt-langchain

Quickstart — attach once, stamp everything

from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_openai_tools_agent
from piqrypt_langchain import PiQryptCallbackHandler

# One handler — stamps every LLM call, tool call, and chain event
handler = PiQryptCallbackHandler(identity_file="my-agent.json")

llm = ChatOpenAI(model="gpt-4o", callbacks=[handler])
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])

result = executor.invoke({"input": "Analyze Q4 sales and flag anomalies"})

# Export verifiable memory
handler.export_audit("q4-analysis-audit.json")
# $ piqrypt verify q4-analysis-audit.json

Drop-in AgentExecutor

from piqrypt_langchain import AuditedAgentExecutor

# Replace AgentExecutor with AuditedAgentExecutor
executor = AuditedAgentExecutor(
    agent=your_agent,
    tools=your_tools,
    identity_file="my-agent.json"
)

result = executor.invoke({"input": "Your query here"})
executor.export_audit("audit.json")

Wrap individual tools

from langchain.tools import tool
from piqrypt_langchain import piqrypt_tool

@tool
@piqrypt_tool(identity_file="my-agent.json")
def search_web(query: str) -> str:
    """Search the web for information."""
    return your_search_logic(query)

@tool
@piqrypt_tool(identity_file="my-agent.json")
def execute_sql(query: str) -> str:
    """Execute a SQL query."""
    return your_db_logic(query)

Wrap chain functions

from piqrypt_langchain import stamp_chain

@stamp_chain("document_analysis", identity_file="my-agent.json")
def analyze_document(doc: str) -> dict:
    return your_chain.invoke({"input": doc})

What gets stamped

Event When
callback_handler_initialized Handler creation
llm_response After every LLM call
tool_start Before tool execution
tool_end After tool execution
tool_error On tool failure
chain_start Before chain runs
chain_end After chain completes
agent_action Every agent decision
agent_finish Agent completion
executor_invoke AgentExecutor input
executor_complete AgentExecutor output

All events Ed25519-signed, SHA-256 hash-chained.
Raw inputs and outputs never stored — only their SHA-256 hashes.


Verify

piqrypt verify langchain-audit.json
# ✅ Chain integrity verified — 32 events, 0 forks

piqrypt search --type tool_error
# All tool failures with timestamps

Why the callback handler is the best approach

LangChain's callback system is designed exactly for this — attach once at the top level, every nested component fires the same callbacks. One PiQryptCallbackHandler stamps your entire agent pipeline automatically, including:

  • Every LLM call inside chains
  • Every tool invocation
  • Every intermediate chain step
  • Every agent decision

No need to modify individual tools or chains.


Scope

Use case AISS profile
Development / PoC AISS-1 (Free, included)
Non-critical production AISS-1 (Free)
Regulated production AISS-2 (Pro)

Links


PiQrypt — Verifiable AI Agent Memory

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piqrypt_langchain_integration-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piqrypt_langchain_integration-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file piqrypt_langchain_integration-1.0.0.tar.gz.

File metadata

File hashes

Hashes for piqrypt_langchain_integration-1.0.0.tar.gz
Algorithm Hash digest
SHA256 005acc201e70e893d01912d0393b96679351cb2bbe2983b301e6f7a717f40dfd
MD5 c69a28de7a152bda9001910099a2fdbd
BLAKE2b-256 8d8b271de8d77cfccaaca83cd94993f23c6e68b0939bd1d7102e363667ee7142

See more details on using hashes here.

Provenance

The following attestation bundles were made for piqrypt_langchain_integration-1.0.0.tar.gz:

Publisher: publish.yml on PiQrypt/piqrypt-langchain-integration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file piqrypt_langchain_integration-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for piqrypt_langchain_integration-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7e33c007417fee7325525e1677ac40f7e905c9a3a52baaad4a521e71a9ec6d1
MD5 58fd32d950631d6ddedf31fae6b516ba
BLAKE2b-256 11291e6499d5ffd90ec1cfd31bac734a7d43af5bbd7766af82cf24a0c847c68c

See more details on using hashes here.

Provenance

The following attestation bundles were made for piqrypt_langchain_integration-1.0.0-py3-none-any.whl:

Publisher: publish.yml on PiQrypt/piqrypt-langchain-integration

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page