Web Search
Search the internet in real-time with AI-powered search
The web_search and fetch_webpage tools enables Letta agents to search the internet for current information, research, and general knowledge using Exa’s AI-powered search engine.
On Letta Cloud, these tools work out of the box. For self-hosted deployments, you’ll need to configure an Exa API key.
Web Search
Adding Web Search to an Agent
Usage Example
Your agent can now choose to use web_search when it needs current information.
Self-Hosted Setup
For self-hosted Letta servers, you’ll need an Exa API key.
Get an API Key
- Sign up at dashboard.exa.ai
- Copy your API key
- See Exa pricing for rate limits and costs
Configuration Options
Tool Parameters
The web_search tool supports advanced filtering and search customization:
Available Categories
Use the category parameter to focus your search on specific content types:
Return Format
The tool returns a JSON-encoded string containing:
Best Practices
1. Guide When to Search
Provide clear instructions to your agent about when web search is appropriate:
2. Combine with Archival Memory
Use web search for external/current information, and archival memory for your organization’s internal data:
See the Archival Memory documentation for more information.
3. Craft Effective Search Queries
Exa uses neural search that understands semantic meaning. Your agent will generally form good queries naturally, but you can improve results by guiding it to:
- Be descriptive and specific: “Latest research on RLHF techniques for language models” is better than “RLHF research”
- Focus on topics, not keywords: “How companies are deploying AI agents in customer service” works better than “AI agents customer service deployment”
- Use natural language: The search engine understands conversational queries like “What are the environmental impacts of Bitcoin mining?”
- Specify time ranges when relevant: Guide your agent to use date filters for time-sensitive queries
Example instruction in memory:
4. Manage Context Window
By default, include_text is False to avoid context overflow. The tool returns highlights and AI-generated summaries instead, which are more concise:
Common Patterns
Research Assistant
News Monitor
Customer Support
Troubleshooting
Agent Not Using Web Search
Check:
- Tool is attached:
"web_search"in agent’s tools list - Instructions are clear about when to search
- Model has good tool-calling capabilities (GPT-4, Claude 3+)
Missing EXA_API_KEY
If you see errors about missing API keys on self-hosted deployments:
When to Use Web Search
Fetch Webpage
Tool Parameters
Return Format
The tool returns webpage content as text/markdown.
With Exa API (if configured):
Fallback (without Exa): Returns markdown-formatted text extracted from the HTML.
How It Works
The tool uses a multi-tier approach:
- Exa API (if
EXA_API_KEYis configured): Uses Exa’s content extraction - Trafilatura (fallback): Open-source text extraction to markdown
- Readability + html2text (final fallback): HTML cleaning and conversion
Self-Hosted Setup
For enhanced fetching on self-hosted servers, optionally configure an Exa API key. Without it, the tool still works using open-source extraction.