The hook-layer scanner protects agent prompts and tool outputs. The agent↔agent boundary is protected separately by the Inter-Agent Provenance envelope — enabled by default on every
create_subagent_tool call.Quick Start
1
Simple Usage
Built-in search tools are protected automatically:
2
With Configuration
Mark custom tools as external:
add_external_tool is now safe to call at any time. It mutates the module-level EXTERNAL_TOOL_NAMES set in place, so a module that imported the name earlier still sees the addition — the previous frozenset+rebind behaviour could leave importers holding a stale, pre-registration copy. Fixed in PR #4969.How It Works
Auto-protected built-ins includeduckduckgo, web_search, tavily_search, scrape_page, fetch_url, and others in the external tools set. MCP tools can be marked at registration time.
Outbound tool results are wrapped in <external_tool_result>; inbound webhook and hook payloads are wrapped in <external_request_payload> — same idea, opposite direction. See Untrusted Request Fencing for the ingress boundary.
What happens if the trust decision fails
When the trust registry exists but raises while answering a trust lookup, PraisonAI now fails closed: the tool is treated as external and its result is fenced. Under-fencing an external tool is the exact bug the fence exists to prevent, so a broken registry never quietly downgrades a tool to “trusted”. The one exception is “no registry at all” (e.g. a slim build): the hardcoded external list is the whole answer there, so unknown tools stay trusted — otherwise every ordinary function tool would be fenced.
Fixed in PR #4969.
Configuration Options
Programmatic Injection Defense
The auto-wrap above protects tool outputs. To also scan all agent prompts at the hook layer, enable the injection-defense pipeline:BEFORE_TOOL and BEFORE_AGENT that scan inputs through a 6-check pipeline and block critical threats.
One-liner (both defenses)
Best Practices
Mark external data sources as external
Mark external data sources as external
Web APIs, scraping, MCP servers you do not control, and third-party feeds should use
trust_level="external".Do not strip safety markers
Do not strip safety markers
Removing
<external_tool_result> tags breaks the model’s boundary between data and instructions.Prefer external when unsure
Prefer external when unsure
Wrapping cost is minimal; under-marking exposes you to injection.
Layer with other guards
Layer with other guards
Combine with Tool Circuit Breaker and input validation for defence in depth.
Scope hooks in multi-tenant hosts
Scope hooks in multi-tenant hosts
The hook registry is process-global. In multi-tenant servers, hold the returned hook IDs and remove them via
praisonaiagents.hooks.remove_hook on teardown, or add per-request hooks manually instead of using the enable_* one-liner.Related defence. Tool outputs get wrapped in
<external_tool_result> markers (this page). Inbound webhook and hook payloads get the ingress counterpart — wrapped in <external_request_payload>, described in Untrusted Request Fencing. Platform display names and group titles interpolated into the [{sender}] attribution prefix get a different treatment — collapse-and-strip — described in Sender Attribution Sanitisation.Related
Inter-Agent Provenance
The agent↔agent counterpart — sub-agent output labelled as data
Untrusted Request Fencing
The ingress counterpart — webhook and hook payloads fenced as data
Attribution Sanitisation
Neutralise untrusted platform display names in the prompt prefix
Vendor Tools
Where third-party connectors live, and why that is not the same as fencing
Tool Circuit Breaker
Automatic tool failure detection and recovery
Security Overview
Complete security features and best practices

