Back to Blog
Tutorial

AI Agent Governance in 5 Minutes

February 18, 2026  ·  6 min read  ·  Yusuf Jacobs

Your AI agent has access to databases, APIs, file systems, and user data. But without governance, every tool call is a potential compliance violation. Here's how to fix that in 5 minutes.

Correction — 3 August 2026

Published February 2026. The code below used a class name and API surface that this package does not have, so it could not run as printed — those snippets are corrected in place. The claims about where governance runs are corrected here.

tork-governance is the on-device family and its only entry class is Tork — not TorkGovernance, and not TorkClient, which belongs to the separate cloud package @torknetwork/sdk. tork-governance makes the governance decision on your machine. PII detection, redaction and the returned verdict are computed on-device. With no API key it makes zero network calls: prompts, completions and detected PII values never leave the machine, and nothing appears in your dashboard.

Supply an API key and the SDK additionally reports a metadata-only attestation of each decision — the action taken, PII type labels and counts, a risk classification, policy labels and a salted fingerprint. It never sends input text, output text or PII values. The decision itself is still made on-device and is never delayed or changed by reporting. Those attestations appear in your dashboard and are included in the daily on-chain anchor — each one recorded as a client attestation (capture_mode=edge, attested_by=client), a claim Tork recorded but did not execute and cannot independently verify. Requires tork-governance 0.24.0+ (PyPI) or 0.11.0+ (npm).

A decision reported by an on-device SDK is recorded as a client attestation (capture_mode=edge, attested_by=client): a claim Tork recorded but did not execute and cannot independently verify. A decision made by @torknetwork/sdk is recorded as capture_mode=cloud, attested_by=tork — Tork made that call itself. Both are equally immutable once anchored; they differ in what is immutable. A client attestation freezes your claim. A server-governed receipt freezes Tork's own decision.

Local governance is free and unlimited — decisions made on your own machine are never metered. Evidence is what is metered: attestations, receipts and anchoring.

Why Your Agent Needs Governance

Modern AI agents — whether built with LangChain, CrewAI, AutoGen, or the OpenAI Agents SDK — are incredibly powerful. They can call tools, query databases, send emails, and make API requests autonomously. But “powerful” without “controlled” is just “dangerous”.

Consider a customer support agent with database access. Without governance:

• It could expose customer SSNs, credit card numbers, or medical records in its responses

• A prompt injection could trick it into running destructive SQL queries

• There's no audit trail for compliance teams (HIPAA, GDPR, SOC 2)

• No way to instantly shut it down if something goes wrong

Tork solves all of these problems with a single SDK.

Step 1: Install the SDK

Pick your language. Tork supports 10 published SDKs. These are the on-device family — they decide locally:

# On-device family — decides locally, entry class `Tork`
npm install tork-governance    # JavaScript/TypeScript
pip install tork-governance    # Python
go get github.com/torkjacobs/tork-go-sdk # Go
cargo add tork-governance     # Rust

# Cloud family — Tork decides server-side, entry class `TorkClient`
npm install @torknetwork/sdk

Step 2: Add PII Detection

Wrap your agent's output with Tork's PII scanner. Every response is scanned for 50+ PII types across 24 countries before it reaches the user:

import { Tork } from 'tork-governance';

// Initialise once. No apiKey = zero network calls.
const tork = new Tork();

// Scan agent output before returning to user.
// govern() is synchronous — do not await it.
const result = tork.govern(agentResponse);

if (result.pii.hasPII) {
  // result.output is already redacted
  return result.output;
}

This catches SSNs, credit cards, emails, phone numbers, Medicare numbers, TFNs, NHS numbers, Aadhaar numbers, and dozens more — all computed on the machine running the SDK. With no API key the text never leaves that machine.

Step 3: Enforce Policies

Define what your agent can and cannot do. Policies are JSON rules that Tork evaluates before every tool call.

Correction, 3 Aug 2026: this step and the two that follow (kill switch, HITL approvals) are cloud-path features. They are server-side calls and are not part of the on-device tork-governance package installed in Step 1, whose surface is govern(). Use @torknetwork/sdk for these.

// Check the tool call before it runs: POST /api/v1/governance/check
// (TorkClient has no policy/hitl namespace — these are plain REST calls)
const decision = await torkPost('/governance/check', {
  agent_id: 'support-agent',
  tool_name: 'database_query',
  parameters: { query: sqlQuery },
});

if (!decision.allowed) {
  console.log('Blocked:', decision.reason);
  return; // Tool call never executes
}

// Human approval is a separate, explicit request: POST /api/v1/approvals
const approval = await torkPost('/approvals', {
  agent_id: 'support-agent', tool_name: 'database_query', expires_in_minutes: 30,
}); // { approval_id, status: 'pending', expires_at } — poll GET /approvals/:id

Step 4: Generate Compliance Receipts

Every governance decision generates a cryptographic receipt — an HMAC hash-chained audit entry that records what happened, when, and why. On the on-device package this receipt is returned to your code as a local object (result.receipt). It does not appear in your dashboard and is not anchored on its own: that requires an API key and an SDK version carrying attestation reporting — tork-governance 0.24.0+ (PyPI) or 0.11.0+ (npm), both published 3 Aug 2026 — and the resulting row is recorded as a client attestation, not a Tork-verified decision.

{
  "id": "rcpt_1a2b3c4d",
  "timestamp": "2026-02-18T10:30:00Z",
  "agent": "support-agent",
  "action": "pii_redacted",
  "detections": ["SSN", "EMAIL"],
  "hash": "sha256:a1b2c3...",
  "chain_prev": "sha256:d4e5f6..."
}

Hand these to your auditors for HIPAA, GDPR, SOC 2, PCI-DSS, or any other compliance framework. The hash chain makes them tamper-evident. A genuinely air-gapped deployment cannot produce an anchored receipt. Anchoring requires reaching Tork, and no amount of local cryptography substitutes for that. Local governance still works completely offline — you get the decision and the redaction, but no external evidence.

Step 5: Add a Kill Switch

Because sometimes you just need to stop everything. The emergency shutdown is org- or key-scoped, not per agent: every governance call from your organisation (scope org) or from the calling key (scope key) answers 503 within about five seconds, until you call /resolve.

// Emergency halt — POST /api/v1/emergency-shutdown
const halt = await torkPost('/emergency-shutdown', {
  scope: 'org', // or 'key' — no per-agent target exists
  reason: 'Detected anomalous behaviour',
}); // { shutdown_id, severity, status, scope, activated_at }

// Lift it: POST /api/v1/emergency-shutdown/resolve

Framework Integration

Tork integrates natively with the frameworks you already use. Here's LangChain:

from tork_governance import Tork
from tork_governance.adapters.langchain import TorkCallbackHandler

# No api_key = fully local, zero network calls
tork = Tork()

# One line to govern your entire chain
agent = initialize_agent(
  tools=tools,
  llm=llm,
  callbacks=[TorkCallbackHandler(tork)],
)

Similar adapters exist for CrewAI, AutoGen, Semantic Kernel, DSPy, and 120+ other frameworks.

What You Get

In under 5 minutes, your agent now has:

PII Detection — 50+ types across 24 countries, computed on-device

Policy Enforcement — Block, allow, or escalate any tool call (cloud path)

Compliance Receipts — Immutable audit trail for every decision; local objects on-device, dashboard rows on the cloud path

Kill Switch — Emergency halt via API or dashboard (cloud path)

Human-in-the-Loop — Require approval for sensitive operations (cloud path)

PII detection and the governance decision run wherever you run the on-device SDK, and with no API key your data never leaves that machine — but nothing appears in a dashboard either. A local receipt is a local object. Getting it into your dashboard means reporting it, which needs an API key and tork-governance 0.24.0+ (PyPI) or 0.11.0+ (npm), and is then recorded as a client attestation — a claim Tork stored, not a decision Tork made. The cloud path (@torknetwork/sdk) is the opposite trade: your content goes to Tork, Tork decides, and the receipt is Tork's own.

Try It Now

Head to the interactive demo to test PII detection and policy enforcement in your browser. Or sign up at tork.network/signup to get your API key — free tier, no credit card.

Tork Network Pty Ltd — Sydney, Australia