Skip to main content

JWT & RBAC

Protect agent endpoints with JWT authentication and role-based access control. The jwtAuth middleware verifies tokens and attaches the decoded payload to req.user, while role checks ensure only authorized users can invoke specific agents.

API Key Authentication

Pass API keys per request using RunOpts.apiKey. This lets each tenant or caller supply their own model provider credentials at runtime without hardcoding them in the agent.

PII Guard

Scrub sensitive data from messages before they reach the LLM. PiiGuard detects SSNs, emails, phone numbers, credit cards, and IP addresses, replacing them with typed placeholders or redacting entirely.
Integrate the guard into an agent so all LLM-bound messages are automatically sanitized:

Input Guardrails

Block dangerous or off-topic input before the agent processes it. Input guardrails run synchronously before the first LLM call and can reject the request with a descriptive error.

Output Guardrails

Inspect and filter agent responses before they reach the end user. Output guardrails catch PII leakage, profanity, or policy violations in the model’s response.

Human-in-the-Loop Approval

Pause agent execution and wait for a human to approve or deny high-risk tool calls. Configure which tools require approval, set timeouts, and handle the approval callback.

Sandbox Execution

Run untrusted code in an isolated sandbox with resource limits. Restrict memory, CPU time, network access, and filesystem paths to prevent malicious or runaway code from affecting the host.

Combined Security Example

A production-hardened agent that layers multiple security controls: input/output guardrails, PII scrubbing, human approval for sensitive operations, sandboxed code execution, retry logic, and structured logging.