Web

Give agents live internet access — search the web or fetch any URL in one line

Web tools let any agent search the internet or read any webpage, with automatic provider fallback so it works even without an API key.

python
from praisonaiagents import Agent

agent = Agent(
    name="Researcher",
    instructions="Answer questions using current information from the web.",
    web=True,
)
agent.start("What are the latest developments in AI this week?")

The user asks for current information; the agent searches or fetches pages with automatic provider fallback.

Diagram

Web Feature

🤖 Agent

🔍 Search

🌐 Fetch

📡 Providers

Tavily

Brave

DuckDuckGo

📄 Content

Quick Start

  1. Level 1 — Bool (simplest)

    Add web=True and the agent automatically searches the internet when it needs current information.

    python
    from praisonaiagents import Agent
    
    agent = Agent(
        name="Researcher",
        instructions="Answer questions using current information from the web.",
        web=True,
    )
    
    agent.start("What are the latest developments in AI this week?")
  2. Level 2 — String (pick a provider)

    Pass a provider name to route searches through a specific engine.

    python
    from praisonaiagents import Agent
    
    agent = Agent(
        name="Researcher",
        instructions="Answer questions using current information from the web.",
        web="tavily",
    )
    
    agent.start("What are the latest developments in AI this week?")
  3. Level 3 — Config class (full control)

    Use WebConfig to combine search, fetch, provider, and result limits.

    python
    from praisonaiagents import Agent, WebConfig
    
    agent = Agent(
        name="Researcher",
        instructions="Research topics thoroughly.",
        web=WebConfig(
            search=True,
            fetch=True,
            search_provider="tavily",
            max_results=10,
        )
    )
    
    agent.start("Summarize the latest news on quantum computing.")
  4. Alternative — Web tools directly

    Use search_web and web_crawl as standalone tools inside any agent.

    python
    from praisonaiagents import Agent
    from praisonaiagents.tools import search_web, web_crawl
    
    agent = Agent(
        name="Web Agent",
        instructions="Search and read web pages to answer questions.",
        tools=[search_web, web_crawl],
    )
    
    agent.start("Find and summarize the homepage of OpenAI.")

How It Works

The agent decides when to search or fetch based on your query. Results flow back as context for the final answer.

Diagram
Search ProviderFetch ToolSearch ToolAgentUserSearch ProviderFetch ToolSearch ToolAgentUser“Latest AI news?”search_web(“latest AI news”)Query (Tavily → Brave → DuckDuckGo)Title + URL + Snippet × NResults listweb_crawl(top_url)Full page contentSummarized answer

Configuration Options

WebConfig API Reference

Full API reference for WebConfig — search, fetch, providers, max_results

WebConfig Fields

FieldTypeDefaultDescription
searchboolTrueEnable web search
fetchboolTrueEnable web page fetching
search_providerstr"duckduckgo"Provider to use: tavily, brave, exa, youdotcom, duckduckgo, searxng
max_resultsint5Maximum search results returned
search_config`dict \None`NoneProvider-specific search settings
fetch_config`dict \None`NoneProvider-specific fetch settings

Search Provider Priority (auto-fallback)

Diagram

Yes

No

Yes

No

Yes

No

Yes

No

Yes

No

🔍 search_web()

Tavily available?

✅ Use Tavily

Brave available?

✅ Use Brave

Exa available?

✅ Use Exa

You.com available?

✅ Use You.com

DuckDuckGo?

✅ Use DuckDuckGo (free)

✅ Use SearxNG


web_crawl Output

Every fetched page comes back as a dict with four keys, and the content field is Markdown — headings, lists, links, and fenced code blocks survive even when no optional crawl provider is installed.

FieldTypeDescription
urlstrThe URL that was fetched
contentstrMarkdown-formatted page content, capped at 50,000 characters
titlestrParsed <title> of the page (empty string if missing)
providerstrWhich backend handled the fetch: tavily, crawl4ai, spider, or httpx (built-in, no dependency)

A failed fetch adds an error key instead of usable content.

Size limits on the built-in path

The built-in httpx path streams each response, and the urllib fallback does a single bounded read. Both read at most 5 MB of raw bytes before parsing. The returned content is still capped at 50,000 Markdown characters. The byte cap keeps memory bounded, so a very large page (or a never-ending stream) can’t use unlimited memory.

PathRaw byte capMarkdown output cap
httpx (built-in)5 MB, streamed50,000 chars
urllib (fallback)5 MB50,000 chars
tavily / crawl4aiprovider-managedprovider-managed

What survives on the zero-dependency path

The built-in httpx path uses only Python’s standard library, so it works on every install with no API key or extra package.

HTMLBecomes
<h1>..<h6># .. ######
<ul> / <ol> / <li>- list / 1. ordered list (nested indent aware)
<a href="...">text</a>text (relative URLs resolved against the page)
<pre><code>...</code></pre>Fenced code block (fence grows past inner backticks)
<code>...</code> (inline)` code `
<strong> / <em>bold / italic
<title>Returned in the title field
<script> / <style> / <head> / <noscript>Dropped
Diagram

Yes

No

Yes

No

Yes

No

🌐 web_crawl(url)

TAVILY_API_KEY + tavily?

✅ tavily → Markdown

crawl4ai installed?

✅ crawl4ai → Markdown

SPIDER_API_KEY?

✅ spider → Markdown

✅ httpx (stdlib) → Markdown

Example

python
from praisonaiagents.tools import web_crawl

result = web_crawl("https://example.com/docs/intro")
print(result["title"])     # "Intro — Example Docs"
print(result["provider"])  # "httpx"
print(result["content"][:120])
# # Intro
#
# Welcome to the docs. See [the quick start](https://example.com/docs/quickstart) for a tour.
#
# ```python
# from example import Client
# ```

Common Patterns

Research Agent with Sources

Search the web and return cited sources alongside the answer.

python
from praisonaiagents import Agent

agent = Agent(
    name="Research Assistant",
    instructions="Answer questions with sources. Always cite URLs.",
    web=True,
)

agent.start("What is the current state of nuclear fusion research?")

Crawl and Summarize a URL

Fetch a specific webpage and summarize it.

python
from praisonaiagents import Agent
from praisonaiagents.tools import web_crawl

agent = Agent(
    name="Summarizer",
    instructions="Fetch the given URL and write a 3-sentence summary.",
    tools=[web_crawl],
)

agent.start("Summarize https://openai.com/research/overview")

The agent reads the page as Markdown, so headings and code blocks are preserved — the summary can quote them directly.

Multi-Agent Research Pipeline

One agent searches, another writes the report.

python
from praisonaiagents import Agent, Task, PraisonAIAgents

searcher = Agent(
    name="Searcher",
    instructions="Search the web for information on the given topic.",
    web=True,
)

writer = Agent(
    name="Writer",
    instructions="Write a structured report based on research findings.",
)

search_task = Task(
    description="Find the top 5 sources on AI regulation in 2025",
    agent=searcher,
    expected_output="List of sources with summaries",
)

write_task = Task(
    description="Write a 500-word report on AI regulation",
    agent=writer,
    context=[search_task],
    expected_output="Formatted report",
)

agents = PraisonAIAgents(agents=[searcher, writer], tasks=[search_task, write_task])
agents.start()

Best Practices

Use DuckDuckGo for zero-configuration setups

DuckDuckGo requires no API key and no package beyond ddgs. It’s the best choice for local development, prototypes, and open-source projects where you can’t bundle API keys.

Switch to Tavily for production accuracy

Tavily returns higher-quality snippets and supports full-page extraction. Set TAVILY_API_KEY in your environment and the agent will prefer it automatically over free providers.

Limit max_results to control token costs

Each search result adds tokens to the agent’s context. Keep max_results=5 (the default) for most queries. Only increase it when the task genuinely requires broad coverage, such as academic literature surveys.

Combine search and fetch for deep research

search=True finds the best URLs; fetch=True reads the full page content. Use both together when a snippet is not enough — for example, reading full API documentation or news articles.


Related