Skip to main content
Plugins rewrite or block what a tool returns before the model ever sees it — so a leaked API key from a fetch tool or a PII field from a database lookup is scrubbed at the plugin layer, without changing the tool.

Quick Start

1

Redact secrets

Create ~/.praisonai/plugins/redact_secrets.py:
Load it and run any agent — the plugin fires on every tool call:
The model receives token=[REDACTED] ok instead of token=sk-SECRET1234567890 ok.
2

Block on secret

Create ~/.praisonai/plugins/block_on_secret.py:
The tool still runs, but the model is told the output was blocked and never sees the leaked value.

How It Works

The after_tool hook fires once the tool returns, before the result reaches the model — on both chat() and achat().

Common Patterns

Regex secret scrubbing

Replace anything matching a secret pattern before it reaches the model.

Allowlist-only fields

Return only the fields you trust from a structured tool result.

Block with the exception form

Raise GuardrailBlocked from deep inside a validator that already raises.

Tool-name filtering

Scope the scrub to one tool and skip the rest — the cheapest possible passthrough.

Best Practices

after_tool runs on every tool call. Use compiled regexes and cheap string checks — no network calls or heavy parsing on the hot path.
Return None (not the unchanged value) when there is nothing to scrub. It signals a no-op clearly and skips the write-back.
When a result is unsafe to show at all, PluginDecision.deny("reason") tells the model why. Returning "" hides the reason and can confuse the model into retrying.
Use a Plugin subclass for a reusable, distributable scrub. Reach for a function-style HookRegistry hook when the rule is one-off and lives next to the agent.

Plugins

Full plugin bridge and lifecycle reference

Hooks

Function-style hooks and HookRegistry

Hook Events

Complete AFTER_TOOL event reference

Inbound Message Gate

Sibling gate on inbound messages