Skip to main content

Persistent memory + rollback + audit trail for LangChain agents using Novyx Core

Project description

novyx-langchain

PyPI version Python versions License Downloads

Persistent memory + rollback + audit trail for LangChain agents.

The ONLY LangChain memory provider with Magic Rollback, cryptographic audit trails, and compliance-grade trace logging.

from novyx_langchain import NovyxMemory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI

memory = NovyxMemory(api_key="nram_xxx", session_id="user-123")
chain = ConversationChain(llm=ChatOpenAI(), memory=memory)

response = chain.invoke({"input": "My name is Alice"})

# NEW in v2.0: Rollback mistakes
memory.rollback("2 hours ago")

# Cryptographic audit trail
audit = memory.audit(limit=50)

What's New in v2.0

  • ๐Ÿ”™ Magic Rollback - Undo memory mistakes with time-travel (memory.rollback("2 hours ago"))
  • ๐Ÿ“œ Cryptographic Audit Trail - SHA-256 hashing, tamper detection, built into all tiers
  • ๐Ÿ” Trace Audit - Compliance-grade logging with RSA signatures (Pro+)
  • ๐Ÿš€ Unified API - All features in one package powered by Novyx Core

Features

Core Features (All Tiers)

  • Semantic retrieval - Finds relevant context, not just recent messages
  • LangGraph native - First-class checkpointer support with rollback
  • Multi-tenant - Built for production SaaS applications
  • < 100ms latency - Fast semantic search via Novyx Core
  • Cryptographic audit - SHA-256 hashing on all writes (retention varies by tier)

Pro+ Features

  • Magic Rollback - Time-travel debugging for memory
  • Trace audit - RSA-signed compliance logging
  • Extended retention - 30+ day audit retention
  • Audit export - CSV/JSON export of full audit trail
  • Anomaly detection - Real-time alerts on suspicious patterns

Installation

pip install novyx-langchain

For LangGraph support:

pip install "novyx-langchain[langgraph]"

Quick Start

1. Get an API Key

Sign up at novyxlabs.com to get your API key.

2. Basic Memory with Rollback

from novyx_langchain import NovyxMemory
from langchain.chains import ConversationChain
from langchain_openai import ChatOpenAI

# Create persistent memory
memory = NovyxMemory(
    api_key="nram_tenant_xxx",
    session_id="user-123",
    k=10,  # Retrieve top 10 relevant memories
)

# Use with any LangChain chain
chain = ConversationChain(
    llm=ChatOpenAI(model="gpt-4"),
    memory=memory,
)

# Conversations persist automatically
response = chain.invoke({"input": "Remember that I prefer dark mode"})

# Made a mistake? Roll back!
memory.rollback("1 hour ago")

# View audit trail
audit = memory.audit(limit=50)
for entry in audit:
    print(f"{entry['timestamp']}: {entry['operation']}")

3. LangGraph Checkpointer with Rollback

from langgraph.graph import StateGraph, END
from novyx_langchain import NovyxCheckpointer

# Create checkpointer
checkpointer = NovyxCheckpointer(api_key="nram_tenant_xxx")

# Build your graph
builder = StateGraph(AgentState)
builder.add_node("agent", agent_node)
builder.add_node("tools", tool_node)
builder.set_entry_point("agent")
builder.add_edge("agent", END)

# Compile with persistence
graph = builder.compile(checkpointer=checkpointer)

# Run with thread_id
config = {"configurable": {"thread_id": "conv-123"}}
result = graph.invoke({"messages": [HumanMessage("Hello!")]}, config)

# NEW: Rollback checkpoint to any point
checkpointer.rollback_to_checkpoint(
    thread_id="conv-123",
    checkpoint_id="abc123"
)

4. Integrity-Protected Memory

from novyx_langchain import NovyxIntegrityMemory

# Cryptographic audit trail built-in (no extra credentials needed)
memory = NovyxIntegrityMemory(
    api_key="nram_tenant_xxx",
    session_id="user-123"
)

chain = ConversationChain(llm=llm, memory=memory)

# All writes are cryptographically audited
response = chain.invoke({"input": "Store sensitive context"})

# Verify audit integrity
verification = memory.verify_audit()
if verification['valid']:
    print(f"โœ… Verified {verification['total_entries']} audit entries")
else:
    print(f"โš ๏ธ Integrity issues: {verification['errors']}")

5. Compliance Mode (Pro+)

from novyx_langchain import NovyxTracedMemory

# Automatically traces all memory operations
memory = NovyxTracedMemory(
    api_key="nram_tenant_xxx",
    session_id="user-123",
    agent_id="my-agent",
    trace_reads=False,  # Optional: trace read operations (verbose)
)

chain = ConversationChain(llm=llm, memory=memory)

# Every memory operation is automatically logged with RSA signature
response = chain.invoke({"input": "Remember my credit card ends in 1234"})

# Complete trace (auto-completed on cleanup)
result = memory.complete_trace()
print(f"Trace signature: {result['signature'][:32]}...")
print(f"Total steps: {result['total_steps']}")

# Verify trace integrity
verification = memory.verify_trace()
if verification['valid']:
    print(f"โœ… Verified {verification['steps_verified']} trace steps")

API Reference

NovyxMemory

Main memory class, compatible with ConversationBufferMemory.

NovyxMemory(
    api_key: str,              # Novyx API key
    session_id: str,           # Unique session identifier
    k: int = 10,               # Number of memories to retrieve
    semantic_search: bool = True,  # Use semantic (vs recency) retrieval
    return_messages: bool = False,  # Return Message objects vs string
    min_relevance: float = 0.3,    # Minimum relevance score
)

Core Methods:

  • load_memory_variables(inputs) - Load relevant memories
  • save_context(inputs, outputs) - Save conversation turn
  • clear() - Clear session memory
  • search(query, limit) - Semantic search
  • store_memory(content, tags, importance) - Store custom memory

NEW in v2.0 - Rollback & Audit:

  • rollback(target, dry_run=False) - Rollback to timestamp/relative time (Pro+)
  • rollback_preview(target) - Preview rollback changes (Pro+)
  • audit(limit, operation) - Get audit trail entries
  • audit_export(format) - Export audit log (Pro+)
  • usage() - Get current usage vs limits

NovyxChatMessageHistory

For use with RunnableWithMessageHistory:

from langchain_core.runnables.history import RunnableWithMessageHistory
from novyx_langchain import NovyxChatMessageHistory

def get_session_history(session_id: str):
    return NovyxChatMessageHistory(
        api_key="nram_xxx",
        session_id=session_id,
    )

chain_with_history = RunnableWithMessageHistory(
    chain,
    get_session_history,
)

NovyxCheckpointer

LangGraph checkpoint persistence:

NovyxCheckpointer(
    api_key: str,              # Novyx API key
    namespace: str = "langgraph",  # Namespace for isolation
)

Methods:

  • put(config, checkpoint, metadata) - Store checkpoint
  • get_tuple(config) - Get checkpoint
  • list(config) - List checkpoints
  • clear_thread(thread_id) - Clear thread checkpoints

NEW in v2.0 - Rollback:

  • rollback_to_checkpoint(thread_id, checkpoint_id, dry_run=False) - Rollback to specific checkpoint (Pro+)
  • rollback_thread(thread_id, target, dry_run=False) - Rollback thread to relative time (Pro+)

NovyxIntegrityMemory

Memory with cryptographic audit trail:

NovyxIntegrityMemory(
    api_key: str,              # Novyx API key
    session_id: str,
    verify_on_read: bool = False,  # Verify audit on every read
    audit_checks: bool = True,     # Enable automatic audit checks
    # ... same options as NovyxMemory
)

Additional Methods:

  • verify_audit() - Verify cryptographic integrity
  • get_audit_summary(limit) - Get audit summary stats
  • export_audit(format, output_file) - Export audit trail (Pro+)
  • rollback_with_verification(target, dry_run) - Rollback + verify (Pro+)

NovyxTracedMemory (Pro+)

Compliance-grade memory with automatic trace logging:

NovyxTracedMemory(
    api_key: str,              # Novyx API key (must be Pro+ tier)
    session_id: str,
    agent_id: str = "langchain-agent",  # Agent identifier for tracing
    trace_reads: bool = False,  # Trace read operations (verbose)
    # ... same options as NovyxMemory
)

Additional Methods:

  • complete_trace() - Complete trace with RSA signature
  • verify_trace() - Verify trace integrity
  • get_trace_status() - Get current trace status

Examples

Multi-Tenant Setup

def get_memory_for_user(user_id: str, tier: str = "free") -> NovyxMemory:
    return NovyxMemory(
        api_key=f"nram_{tenant_id}_xxx",  # Tenant-specific key
        session_id=f"user-{user_id}",
        k=20 if tier == "pro" else 10,  # More memories for Pro users
    )

# Each user has isolated memory
alice_memory = get_memory_for_user("alice", tier="pro")
bob_memory = get_memory_for_user("bob", tier="free")

Rollback After Error

memory = NovyxMemory(api_key="nram_xxx", session_id="user-123")

# Store some memories
chain = ConversationChain(llm=llm, memory=memory)
response = chain.invoke({"input": "My password is hunter2"})  # Oops!

# Preview rollback
preview = memory.rollback_preview("1 minute ago")
print(f"Will restore {preview['artifacts_modified']} memories")

# Execute rollback
result = memory.rollback("1 minute ago")
print(f"Rolled back to {result['rolled_back_to']}")

Audit Compliance

memory = NovyxIntegrityMemory(api_key="nram_xxx", session_id="user-123")

# Run your agent
# ... agent operations ...

# Get audit summary
summary = memory.get_audit_summary(limit=100)
print(f"Total operations: {summary['total_operations']}")
print(f"Creates: {summary['by_type']['CREATE']}")
print(f"Deletes: {summary['by_type']['DELETE']}")
print(f"Integrity valid: {summary['integrity_valid']}")

# Export for compliance
memory.export_audit(format="csv", output_file="audit_2026-02.csv")

Trace Audit for Compliance

memory = NovyxTracedMemory(
    api_key="nram_xxx",
    session_id="user-123",
    agent_id="customer-support-bot"
)

# All operations are automatically traced
chain = ConversationChain(llm=llm, memory=memory)

for user_input in customer_conversation:
    response = chain.invoke({"input": user_input})

# Complete trace with RSA signature
result = memory.complete_trace()
print(f"Trace ID: {result['trace_id']}")
print(f"Signature: {result['signature']}")
print(f"Signed at: {result['signed_at']}")

# Verify later for compliance
verification = memory.verify_trace()
print(f"Trace valid: {verification['valid']}")

Comparison

novyx-langchain is the ONLY LangChain memory provider with rollback, cryptographic audit trails, and compliance-grade trace logging.

Feature novyx-langchain Mem0 Zep Supermemory ConversationBufferMemory
Semantic search โœ… โœ… โœ… โœ… โŒ
Magic Rollback โœ… (Pro+) โŒ โŒ โŒ โŒ
Cryptographic audit trail โœ… (All tiers) โŒ โŒ โŒ โŒ
Compliance trace logging โœ… (Pro+) โŒ โŒ โŒ โŒ
LangGraph native โœ… โŒ โŒ โŒ โŒ
Multi-tenant โœ… โœ… โœ… โŒ โŒ
Self-hostable โœ… โŒ โœ… โœ… N/A
Open source โœ… โŒ โŒ โœ… โœ…
< 100ms latency โœ… โœ… โœ… โ“ โœ…
Tamper detection โœ… โŒ โŒ โŒ โŒ
Policy enforcement โœ… (Pro+) โŒ โŒ โŒ โŒ

Why Choose Novyx?

  1. Only provider with rollback - Undo mistakes with time-travel
  2. Only provider with audit trails - Cryptographic verification on all tiers
  3. Only provider with compliance logging - RSA-signed trace audit for regulated industries
  4. LangGraph native - First-class checkpoint support with rollback
  5. Open source - Full transparency and self-hosting option
  6. Multi-tenant - Built for production SaaS from day one

Pricing

Tier Price Memories API Calls Rollbacks Audit Trace Audit
Free $0 5,000 5,000/mo 10/month 7 days โŒ
Starter $12/mo 25,000 25,000/mo 30/month 14 days โŒ
Pro $39/mo Unlimited 100,000/mo Unlimited 30 days โœ…
Enterprise $199/mo Unlimited Unlimited Unlimited 90 days โœ… + Priority

Breaking Changes in v2.0

Removed

  • NovyxIntegrityMemory no longer requires integrity_api_key and integrity_secret - audit is now built into Core

Changed

  • All classes now use the unified Novyx SDK (novyx>=2.0.0)
  • NovyxRAMClient is now a wrapper around the Novyx SDK (backward compatible)
  • Audit features are built into all tiers (with retention limits)

Added

  • NovyxMemory.rollback() - Magic Rollback
  • NovyxMemory.audit() - Audit trail access
  • NovyxCheckpointer.rollback_to_checkpoint() - Checkpoint rollback
  • NovyxTracedMemory - Compliance-grade trace logging (Pro+)
  • All new methods for rollback, audit, and trace features

Migration from v0.1.x

# v0.1.x
from novyx_langchain import NovyxIntegrityMemory

memory = NovyxIntegrityMemory(
    api_key="nram_xxx",
    integrity_api_key="int_xxx",  # REMOVED in v2.0
    integrity_secret="secret",     # REMOVED in v2.0
    session_id="user-123"
)

# v2.0
from novyx_langchain import NovyxIntegrityMemory

memory = NovyxIntegrityMemory(
    api_key="nram_xxx",  # Audit is now built-in!
    session_id="user-123"
)

License

MIT License - see LICENSE for details.

Links

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

novyx_langchain-2.9.3.tar.gz (33.4 kB view details)

Uploaded Source

Built Distribution

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

novyx_langchain-2.9.3-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file novyx_langchain-2.9.3.tar.gz.

File metadata

  • Download URL: novyx_langchain-2.9.3.tar.gz
  • Upload date:
  • Size: 33.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for novyx_langchain-2.9.3.tar.gz
Algorithm Hash digest
SHA256 725ae28b54994c1912d318cc093e0e07651fb9bad53692b33b9580b1b51101d7
MD5 2d5ac7ad245ea8084fd2c90ef29a685b
BLAKE2b-256 7e4cca9fbb33248240259220058a784654c11a346ca2539fcb53789afab3b0fa

See more details on using hashes here.

File details

Details for the file novyx_langchain-2.9.3-py3-none-any.whl.

File metadata

File hashes

Hashes for novyx_langchain-2.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 84c9fdef6204b0e0e0d9c74d5dbe643104d6d6ccc49f264cb48753f3caa50603
MD5 dc8b3e7c394f2e623ebd49954ab33d56
BLAKE2b-256 f0999ea50ee86facf5730b50d059caaab665a6b736c6aae85b452b0ca5bc65fe

See more details on using hashes here.

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