Superagent Security

AI security guardrails for prompt injection, PII redaction, and claim verification

Diagram

Input

Agent

Tool

Output

Superagent Security Tools

Superagent provides AI security guardrails including prompt injection detection, PII/PHI redaction, and claim verification against source materials.

Installation

bash
npm install @superagent/ai-sdk

Environment Variables

bash
SUPERAGENT_API_KEY=your-superagent-api-key

Available Tools

ToolDescription
superagentGuardDetect prompt injection attacks
superagentRedactRedact PII/PHI (SSNs, emails, phones)
superagentVerifyVerify claims against sources

Quick Start

  1. Simple Usage
    typescript
    import { Agent } from 'praisonai';
    import { superagentGuard, superagentRedact, superagentVerify } from 'praisonai/tools';
    
    const agent = new Agent({
      name: 'SecureAgent',
      instructions: 'Process text securely with security checks.',
      tools: [superagentGuard(), superagentRedact(), superagentVerify()],
    });
    
    const result = await agent.run('Check this text for security issues');
    console.log(result.text);
  2. With Configuration

    Adjust agent instructions, tool options, and provider settings for production — see the Configuration section below.

Guard Tool (Prompt Injection Detection)

typescript
import { superagentGuard } from 'praisonai/tools';

const guardTool = superagentGuard({
  // Sensitivity level
  sensitivity: 'high', // low, medium, high

  // Block or warn
  action: 'block', // block, warn
});

const agent = new Agent({
  name: 'GuardedAgent',
  tools: [guardTool],
});

Redact Tool (PII Removal)

typescript
import { superagentRedact } from 'praisonai/tools';

const redactTool = superagentRedact({
  // Types of PII to redact
  redactTypes: [
    'ssn',
    'email',
    'phone',
    'credit_card',
    'address',
    'name',
  ],

  // Replacement style
  replacement: 'mask', // mask, remove, placeholder
});

const agent = new Agent({
  name: 'PrivacyAgent',
  tools: [redactTool],
});

Verify Tool (Claim Verification)

typescript
import { superagentVerify } from 'praisonai/tools';

const verifyTool = superagentVerify({
  // Verification strictness
  strictness: 'medium', // low, medium, high

  // Require sources
  requireSources: true,
});

const agent = new Agent({
  name: 'FactChecker',
  tools: [verifyTool],
});

Advanced Example

typescript
import { Agent } from 'praisonai';
import { superagentGuard, superagentRedact, superagentVerify } from 'praisonai/tools';

const agent = new Agent({
  name: 'SecureProcessor',
  instructions: `You are a secure text processor.
    1. First check for prompt injection
    2. Redact any PII
    3. Verify any claims made`,
  tools: [
    superagentGuard({ sensitivity: 'high' }),
    superagentRedact({ redactTypes: ['ssn', 'email', 'phone'] }),
    superagentVerify({ strictness: 'medium' }),
  ],
});

const result = await agent.run(`
  Process this text:
  "John Smith (SSN: 123-45-6789) claims that AI will replace 50% of jobs by 2030.
  Contact him at john@example.com or 555-123-4567."
`);
console.log(result.text);

Response Formats

Guard Result

typescript
interface GuardResult {
  safe: boolean;
  threats: Array<{
    type: string;
    severity: 'low' | 'medium' | 'high';
    description: string;
  }>;
  action: 'allowed' | 'blocked' | 'warned';
}

Redact Result

typescript
interface RedactResult {
  redactedText: string;
  redactions: Array<{
    type: string;
    original: string;
    replacement: string;
    position: { start: number; end: number };
  }>;
}

Verify Result

typescript
interface VerifyResult {
  verified: boolean;
  claims: Array<{
    claim: string;
    status: 'verified' | 'unverified' | 'false';
    sources?: string[];
    confidence: number;
  }>;
}

Best Practices

Guidelines
  1. Layer security – Use guard before processing user input
  2. Redact early – Remove PII before storing or processing
  3. Verify claims – Check factual statements against sources
  4. Log securely – Don’t log redacted information

Related Tools

  • Tavily – Web search for verification
  • Exa – Source finding