Skip to main content

PiQrypt Verifiable AI Agent Memory bridge for LangChain

Project description

piqrypt-langchain

Standard: AISS v2.0 · Full stack: piqrypt.com

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.1.0.tar.gz (3.9 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.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for piqrypt_langchain_integration-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d85ac10b64b12963301a371b237ebd3794e03a490957be69ffa6d56b3ef56186
MD5 6d0c494c9cf280db51e619bc774e1bd1
BLAKE2b-256 d3371168f73bfc5ed31f8a879d6f278bc88bf6ca6905c17e4b4ed64e2e4bc977

See more details on using hashes here.

Provenance

The following attestation bundles were made for piqrypt_langchain_integration-1.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for piqrypt_langchain_integration-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 190e142628f74c3b9cadf7fe3886b47696dbe4fde63333dcfa70c7da14b9681f
MD5 0f9e1b4fdea80a1b1053e407c25a4bed
BLAKE2b-256 481272dd1c2ed47037cf5fe9d2a222935756d3dd9e820c4f22e5d9a68d763942

See more details on using hashes here.

Provenance

The following attestation bundles were made for piqrypt_langchain_integration-1.1.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