TailraceTailrace

Introduction

How Tailrace governs agent data flows in-process - detect, policy, apply, audit, and restore at egress.

Tailrace is agent data governance for TypeScript. It sits inside your process at model, tool, and MCP boundaries - detecting secrets and PII, applying policy, and restoring tokenized values only where you trust.

No proxy. No sidecar. No required network call on the request hot path.

Live pipeline · Input
agentsupport-bot · workflow sess-7f3a
prompt.ts
1// User message → model boundary (out)
2const prompt = `
3 Email billing@example.com
4 Key sk_test_FAKE
5`;

Agent prompt crosses the model boundary

In-process only · zero network on the hot path · same email + workflow → same token

The pipeline

Every check follows the same path:

  1. Input: A string or JSON object crosses a boundary (model prompt, tool args, MCP payload).
  2. Detect: Tier 0 recognizers find entity spans with JSON-pointer paths.
  3. Policy resolve: For each span: entity × boundary × identity → action.
  4. Apply: block throws · tokenize writes the vault · mask replaces inline · allow passes through.
  5. Audit: Async emit with rule path and content hash; never raw values.

Restore is separate: tailrace.restore() runs only at { kind: "egress", sink } boundaries. Calling restore at a model or tool boundary throws - by design.

Default policy

createTailrace() with no arguments:

EntityAction
Secrets (api_key, jwt, private_key, …)block
Email, phone, credit card, IBAN, SSNtokenize
IP addressallow
Egress sinks (egress:*)detokenize

Secrets cannot be overridden to allow without dangerouslyAllowSecrets: true.

Where Tailrace sits

Your app ──► wrapModel / wrapTools / MCP wrapper ──► tailrace.check ──► provider or tool

                                                      └──► audit (async)

For the Vercel AI SDK, one line wraps the model:

const model = tailrace.model(openai("gpt-4o"));

Next steps

GoalLink
Block a fake key in five minutesQuickstart
Connect Cursor / Claude to docsUse with AI tools
Models, tools, streaming, egressProtect PII in the AI SDK
MCP transportsGovern MCP tool calls
Hono OpenAI passthroughHono integration
ConceptsBoundaries

On this page