A contextual web navigation agent built with Google's Agent Development Kit (ADK) that can navigate the web using contextual clues to achieve end objectives. The agent supports both cloud-based (Gemini) and local LLM models.
- Contextual Web Navigation: Expert at finding and following contextual clues on web pages
- Flexible LLM Support: Works with both cloud-based (Gemini) and local models (Ollama)
- Browser Automation: Uses Playwright MCP tools for web interaction
- Adaptive Approach: Interprets ambiguous instructions and adapts strategies to reach goals
- Python 3.11 or higher
- Node.js and npm (for Playwright MCP tools)
- Ollama (optional, for local LLM usage)
git clone <repository-url>
cd "Whatsapp Reader"# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activatepip install google-adk litellm python-dotenv# Install Playwright MCP tools globally
npm install -g @playwright/mcpCreate a .env file in the project root:
# For Google Gemini (cloud-based)
GOOGLE_API_KEY="your_google_api_key_here"
# For local LLM (optional)
OLLAMA_API_BASE="http://localhost:11434"The agent is configured by default to use Google's Gemini 2.5 Flash model:
# In agent.py - already configured
model="gemini-2.5-flash"-
Install and Start Ollama:
# Install Ollama (follow instructions at https://ollama.com/) # Pull a model (example with Gemma 3) ollama pull gemma3:12b # Start Ollama server ollama serve
-
Modify the Agent Configuration:
# In agent.py, uncomment the local model line and comment out the Gemini line: # model="gemini-2.5-flash", model=LiteLlm(model="ollama_chat/gemma3:12b"),
-
Set Environment Variable:
export OLLAMA_API_BASE="http://localhost:11434"
adk webadk run Whatsapp_agent.agentfrom google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types
from Whatsapp_agent.agent import root_agent
# Set up session and runner
session_service = InMemorySessionService()
session = session_service.create_session(
app_name="whatsapp_reader",
user_id="user_1",
session_id="session_1"
)
runner = Runner(
agent=root_agent,
app_name="whatsapp_reader",
session_service=session_service
)
# Run the agent
content = types.Content(role='user', parts=[types.Part(text="Navigate to example.com and find the contact information")])
events = runner.run(user_id="user_1", session_id="session_1", new_message=content)
for event in events:
if event.is_final_response():
print("Agent Response:", event.content.parts[0].text)gemini-2.5-flash(default) - Fast and efficientgemini-2.5-pro- More powerful for complex tasksgemini-2.0-flash- Stable version
ollama_chat/gemma3:12b- Google's open-source modelollama_chat/llama3:8b- Meta's Llama 3ollama_chat/mistral:7b- Mistral AI's modelollama_chat/codellama:7b- Specialized for coding tasks
The agent uses Playwright MCP tools for web automation:
browser_navigate- Navigate to web pagesbrowser_screenshot- Take screenshotsbrowser_fill- Fill formsbrowser_click- Click elements
You can filter specific tools by uncommenting the tool_filter line in the agent configuration.
-
Ollama Connection Issues:
- Ensure Ollama is running:
ollama serve - Check if the model is downloaded:
ollama list - Verify API endpoint:
curl http://localhost:11434/api/tags
- Ensure Ollama is running:
-
Playwright MCP Issues:
- Ensure Node.js and npm are installed
- Reinstall Playwright MCP:
npm install -g @playwright/mcp@latest
-
Python UTF-8 Issues (Windows):
$env:PYTHONUTF8 = "1"
-
Tool Calling Issues with Ollama:
- Use
ollama_chat/provider instead ofollama/ - Ensure you're using the latest version of
litellm
- Use
The agent includes debug logging for LiteLLM. To see detailed request/response logs, the debug mode is already enabled in the code:
import litellm
litellm._turn_on_debug()Whatsapp Reader/
├── Whatsapp_agent/
│ ├── __init__.py
│ └── agent.py # Main agent configuration
├── README.md # This file
└── .env # Environment variables (create this)
- Fork the repository
- Create a feature branch
- Make your changes
- Test with both cloud and local models
- Submit a pull request
[Add your license information here]
For issues and questions:
- Check the Google ADK documentation
- Review LiteLLM documentation
- Check Ollama documentation