# abisheakp197/langchain-nti architecture

> Architecture diagram of the GitHub repository abisheakp197/langchain-nti, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abisheakp197/langchain-nti
- Repository: https://github.com/abisheakp197/langchain-nti

## Overview

langchain-nti is a LangChain callback integration that applies NTI security checks around tool execution. The principal workflow is: an agent starts a tool, the callback submits the action for policy evaluation, and strict mode blocks a denied action; on completion, optional response-signature verification checks the tool output. The callback also exposes signing and voter registration. The README documents capability enforcement, BFT consensus, Merkle audit, and agent-mesh persistence as TrustEngine responsibilities. Those internals are not sampled, so their detail and wiring are shown only as documented capabilities.

Main entry points: [`langchain_nti/callback.py`](https://github.com/abisheakp197/langchain-nti/blob/main/langchain_nti/callback.py) (Callback handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["LangChain integration"]
  node_callback["Callback handler<br/>[callback.py]"]
  node_verification["Output verification<br/>[callback.py]"]
end

subgraph group_security["NTI security"]
  node_engine["TrustEngine"]
  node_capabilities["Capability enforcement"]
  node_consensus["BFT consensus"]
  node_audit["Merkle audit trail"]
  node_mesh["Agent mesh state"]
  node_pqc["PQC keypair"]
end

node_agent(("LangChain agent"))
node_tool["LangChain tool"]

node_agent -->|"starts tool"| node_callback
node_callback -->|"evaluates action"| node_engine
node_engine -->|"enforces"| node_capabilities
node_engine -->|"handles"| node_consensus
node_engine -->|"records"| node_audit
node_engine -->|"persists state"| node_mesh
node_callback -->|"creates or accepts"| node_pqc
node_callback -->|"signs and verifies"| node_pqc
node_callback -->|"registers voter keys"| node_engine
node_callback -->|"blocks denied action"| node_tool
node_tool -->|"returns output"| node_callback
node_callback -->|"optionally checks"| node_verification

click node_callback "https://github.com/abisheakp197/langchain-nti/blob/main/langchain_nti/callback.py"
click node_verification "https://github.com/abisheakp197/langchain-nti/blob/main/langchain_nti/callback.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_callback,node_verification toneBlue
class node_engine,node_capabilities,node_consensus,node_audit,node_mesh,node_pqc toneAmber
class node_agent,node_tool toneIndigo
```

## Components

### LangChain integration

- [Callback handler](https://github.com/abisheakp197/langchain-nti/blob/main/langchain_nti/callback.py): `langchain_nti/callback.py`
- [Output verification](https://github.com/abisheakp197/langchain-nti/blob/main/langchain_nti/callback.py): `langchain_nti/callback.py`

### NTI security

- **TrustEngine**
- **Capability enforcement**
- **BFT consensus**
- **Merkle audit trail**
- **Agent mesh state**
- **PQC keypair**

### Other components

- **LangChain agent**
- **LangChain tool**

## Connections

- LangChain agent → Callback handler: starts tool (evidence: `README.md`)
- Callback handler → TrustEngine: evaluates action (evidence: `README.md`)
- TrustEngine → Capability enforcement: enforces (evidence: `README.md`)
- TrustEngine → BFT consensus: handles (evidence: `README.md`)
- TrustEngine → Merkle audit trail: records (evidence: `README.md`)
- TrustEngine → Agent mesh state: persists state (evidence: `README.md`)
- Callback handler → PQC keypair: creates or accepts (evidence: `langchain_nti/callback.py`)
- Callback handler → PQC keypair: signs and verifies (evidence: `langchain_nti/callback.py`)
- Callback handler → TrustEngine: registers voter keys (evidence: `langchain_nti/callback.py`)
- Callback handler → LangChain tool: blocks denied action (evidence: `README.md`)
- LangChain tool → Callback handler: returns output (evidence: `README.md`)
- Callback handler → Output verification: optionally checks (evidence: `langchain_nti/callback.py`)
