Docs navigation

LangChain

Two layers, both optional: the callback handler traces every LLM call automatically; the trust-platform calls add identity, policy, and the tamper-evident chain around your tools.

Python

import os
from proofledger import (
    enable, register_agent, create_langchain_handler,
    log_tool_call, log_workflow_step, evaluate_policy,
)
from langchain_core.tools import tool

enable(
    api_key=os.environ["PROOFLEDGER_API_KEY"],
    agent_name="research-agent",
    owner="platform",
    framework="langchain",
    model="gpt-4.1",
    policy_mode="enforce",
)
register_agent()

# Layer 1 — automatic LLM run tracing
handler = create_langchain_handler(agent_id="research-agent")

# Layer 2 — signed, policy-checked trust events around tools
@tool
def search_web(query: str) -> str:
    """Search the web."""
    result = do_search(query)
    log_tool_call("web_search", workflow_id=WF,
                  input_summary=query[:200], output_summary=f"{len(result)} hits")
    return result

WF = "wf_research_001"
log_workflow_step(WF, event_type="task_received",
                  action="Research competitor pricing")

agent_executor.invoke(
    {"input": "Compare pricing for the top 3 competitors"},
    config={"callbacks": [handler]},
)

log_workflow_step(WF, status="completed", action="Report delivered")

TypeScript (LangChain.js)

import { ProofLedger, createLangChainHandler } from "@proofledger/sdk";

ProofLedger.enable({
  apiKey: process.env.PROOFLEDGER_API_KEY,
  agentName: "research-agent",
  framework: "langchain",
});
await ProofLedger.registerAgent();

const handler = createLangChainHandler({ agentId: "research-agent" });
await chain.invoke(input, { callbacks: [handler] });

// Gate a risky tool before executing it:
const { decision } = await ProofLedger.evaluatePolicy({
  toolName: "db_write", sensitiveAction: true,
});
if (decision !== "allow") throw new Error("Blocked by ProofLedger policy");

Production

Register web_search and your other tools in the Tools & MCP registry and approve them — in enforce mode, unregistered tools are blocked on first call.