Skip to main content

API Reference

Memproof exposes a single entry point — the Memproof class — that wires together policy evaluation, risk assessment, event auditing, and adapter-backed storage behind a small async API.
from memproof import Memproof

mp = Memproof(policy="./memproof.yaml")
All memory operations (remember, get, update, forget, search) flow through the same internal pipeline:
  1. The request is validated and a scope/context is built.
  2. A risk score is computed by the RiskEngine.
  3. The PolicyEngine evaluates the configured rules and returns an allow/deny/quarantine/require-approval decision.
  4. If allowed, the operation is forwarded to the configured MemoryAdapter (LangGraph, OpenAI Sessions, MCP, or in-memory).
  5. An immutable TrailEvent is written to the Trailproof audit trail for every step.

Core Classes

ClassDescriptionReference
MemproofPrimary entry point. Wraps the full pipeline behind remember(), get(), update(), forget(), and search().Memproof Class
MemproofConfigPydantic configuration model. Controls adapter selection, audit trail storage, signing, and external service URLs.Configuration
MemoryScopeIdentifies the tenant, project, agent, and optional session/subject a memory belongs to.Models
OperationContextCaptures who is performing an operation, from which source, and when.Models
MemoryRecordThe persisted memory object returned by the adapter.Models
MemoryOperationResponseResponse from remember() and update() — includes the operation ID, status, risk assessment, and policy decision.Models
OperationStatusResponseResponse from forget(), approve(), deny(), and get_operation_status().Models
MemorySearchResponseResponse from search() — contains ranked MemorySearchHit entries.Models
MemproofErrorBase exception. All Memproof errors carry a machine-readable code, a human-readable message, and optional details.Errors

Quick Start

import asyncio
from memproof import Memproof

async def main():
    mp = Memproof(
        policy="./memproof.yaml",
        adapter="in_memory",
    )

    # Store a memory
    result = await mp.remember(
        content="user prefers dark mode",
        scope={
            "tenant_id": "acme",
            "project_id": "assistant",
            "agent_id": "agent-1",
        },
        context={
            "actor_type": "agent",
            "actor_id": "agent-1",
            "source": "langgraph",
            "timestamp": "2026-01-15T10:30:00Z",
        },
        tags=["preference", "ui"],
    )

    print(result.status)         # OperationStatus.committed
    print(result.operation_id)   # unique operation ID
    print(result.memory.content) # "user prefers dark mode"

    # Retrieve it
    record = await mp.get(result.memory.memory_id)
    print(record.content)

    # Search
    search_result = await mp.search(
        query="dark mode",
        scope={
            "tenant_id": "acme",
            "project_id": "assistant",
            "agent_id": "agent-1",
        },
        context={
            "actor_type": "agent",
            "actor_id": "agent-1",
            "source": "langgraph",
            "timestamp": "2026-01-15T10:31:00Z",
        },
    )
    for hit in search_result.hits:
        print(hit.memory.content, hit.score)

asyncio.run(main())

Enumerations

Memproof defines several enums that appear throughout the API:
EnumValuesUsed In
OperationTyperemember, update, forget, search, getOperationStatusResponse
OperationStatusreceived, pending_approval, committed, blocked, quarantined, failedResponses
RiskLevellow, medium, high, criticalRiskAssessment
DecisionActionallow, deny, require_approval, quarantinePolicyDecision
Event typesmemproof.pipeline.received, memproof.pipeline.risk_assessed, memproof.pipeline.policy_decided, memproof.pipeline.approval_requested, memproof.pipeline.provider_attempted, memproof.pipeline.committed, memproof.pipeline.blockedTrailEvent
ActorTypeagent, user, systemOperationContext
See Models for full details on every enum and model.