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 Load it and run any agent — the plugin fires on every tool call:The model receives
~/.praisonai/plugins/redact_secrets.py:token=[REDACTED] ok instead of token=sk-SECRET1234567890 ok.2
Block on secret
Create The tool still runs, but the model is told the output was blocked and never sees the leaked value.
~/.praisonai/plugins/block_on_secret.py:How It Works
Theafter_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
RaiseGuardrailBlocked 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
Keep it fast
Keep it fast
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 for passthrough
Return None for passthrough
Return
None (not the unchanged value) when there is nothing to scrub. It signals a no-op clearly and skips the write-back.Prefer block over an empty string
Prefer block over an empty string
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.Plugin vs hook
Plugin vs hook
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.Related
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

