Skip to main content
Web search and other external tools wrap results in safety markers — the model treats them as data, not instructions.
from praisonaiagents import Agent
from praisonaiagents.tools import duckduckgo

agent = Agent(
    name="Researcher",
    instructions="Research topics safely",
    tools=[duckduckgo],
)

agent.start("Find recent AI safety papers")
# duckduckgo results auto-wrapped in <external_tool_result> markers
The user searches the web; external tool output is wrapped so the model treats it as data.

Quick Start

1

Simple Usage

Built-in search tools are protected automatically:
from praisonaiagents import Agent
from praisonaiagents.tools import duckduckgo

agent = Agent(
    name="Researcher",
    instructions="Research topics safely",
    tools=[duckduckgo],
)

agent.start("Find recent AI safety papers")
2

With Configuration

Mark custom tools as external:
from praisonaiagents import Agent, register_tool

def my_web_lookup(query: str) -> str:
    """Fetch data from an external API."""
    return fetch_from_api(query)

register_tool(my_web_lookup, name="my_web_lookup", trust_level="external")

agent = Agent(
    name="Researcher",
    instructions="Use my_web_lookup for facts",
    tools=["my_web_lookup"],
)

How It Works

Auto-protected built-ins include duckduckgo, web_search, tavily_search, scrape_page, fetch_url, and others in the external tools set. MCP tools can be marked at registration time.
ConditionAction
Trusted toolResult unchanged
External + string ≥ 32 charsWrapped in <external_tool_result>
External + string < 32 charsUnchanged (overhead skip)
External + dict/listJSON-serialised then wrapped

Configuration Options

OptionTypeDefaultDescription
trust_level"trusted" | "external""trusted"Set on register_tool(..., trust_level="external")
MIN_CONTENT_LENGTH_FOR_WRAPPINGint32Minimum string length before wrapping

Best Practices

Web APIs, scraping, MCP servers you do not control, and third-party feeds should use trust_level="external".
Removing <external_tool_result> tags breaks the model’s boundary between data and instructions.
Wrapping cost is minimal; under-marking exposes you to injection.
Combine with Tool Circuit Breaker and input validation for defence in depth.

Tool Circuit Breaker

Automatic tool failure detection and recovery

Security Overview

Complete security features and best practices