For the complete documentation index, see llms.txt. This page is also available as Markdown.

Governance & Security

Govern AI in production with middleware, guardrails, prompt-injection defense, human approval, and audit trails.

Enterprises adopt AI when they can control it. BoxLang AI puts governance in a middleware layer that wraps model and tool calls, so you add controls without changing agent logic.

🧅 Middleware

Middleware can observe, modify, retry, reject, suspend, or cancel work around every model and tool call.

Attach it to an agent:

agent = aiAgent(
    name: "assistant",
    middleware: [
        new LoggingMiddleware(),
        new RetryMiddleware( maxRetries: 3 ),
        new GuardrailMiddleware( blockedTools: [ "deleteRecord" ] )
    ]
)

🛡️ Built-In Controls

Concern
Middleware

Observability

LoggingMiddleware, FlightRecorderMiddleware for an audit trail

Reliability

RetryMiddleware, MaxToolCallsMiddleware

Policy

GuardrailMiddleware blocks tools or argument patterns

Approval

HumanInTheLoopMiddleware

Prompt injection

InputSanitizerMiddleware scans inbound content and tool results

Output safety

OutputGuardMiddleware redacts sensitive output offline

AI-assisted review

LLMGuardMiddleware classifies content with an LLM as judge

Security middleware is opt-in and can be tested offline.

🚫 Guardrails

Block tools outright and validate arguments with patterns:

🧑‍⚖️ Human in the Loop

Some actions should never run unsupervised: deleting records, moving money, deploying to production. HumanInTheLoopMiddleware pauses the run and asks a person to approve, reject, or edit the call.

Later, when a person decides:

In CLI mode the prompt appears in the terminal. In web mode the run suspends and resumes when the decision arrives, even days later.

🌐 Gateways

A gateway presents approvals and messages on the right channel: the CLI, signed HTTP webhooks, or a platform module you register. HTTP gateways sign requests with HMAC, bound them by timestamp, deduplicate nonces, and claim decisions atomically.

🔐 More Security Practices

  • Keep API keys in environment variables or a secrets manager. BoxLang+ offers AWS, Azure, and Google secrets modules.

  • Isolate every user's memory with userId and conversationId.

  • Fence untrusted content with aiFence.

  • Give agents least privilege, and expose only the tools they need.

🔍 Go Deeper

Last updated

Was this helpful?