Web Tools
Expand a shortened URL to its destination.
"""
Web Tools
=============================
Demonstrates web tools.
"""
from agno.agent import Agent
from agno.tools.webtools import WebTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(tools=[WebTools()])
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent.print_response("Tell me about https://tinyurl.com/57bmajz4")This tool follows redirects with HTTP HEAD requests and returns only the destination URL. Change the request to “Expand this shortened URL” to match that behavior. To summarize the destination’s content, also provide a page-reading tool such as WebsiteTools().
Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno openaiExport your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"Run the example
Save the code above as web_tools.py, then run:
python web_tools.pyFull source: cookbook/91_tools/web_tools.py