Documentation Index
Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
Use this file to discover all available pages before exploring further.
Basic Browser Agent
Navigate and extract information from web pages.
import asyncio
from definable.agent import Agent
from definable.browser import BrowserToolkit, BrowserConfig
async def main():
config = BrowserConfig(headless=False)
async with BrowserToolkit(config=config) as toolkit:
agent = Agent(
model="gpt-4o",
toolkits=[toolkit],
instructions="Use browser_snapshot before interacting with any page.",
)
result = await agent.arun("Go to news.ycombinator.com and list the top 3 stories")
print(result.content)
asyncio.run(main())
pip install 'definable[browser]'
playwright install chromium
Connect to Existing Browser
Attach to an already-running Chrome instance:
# Launch Chrome with remote debugging
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
--remote-debugging-port=9222 --no-first-run
config = BrowserConfig(cdp_url="http://127.0.0.1:9222")
async with BrowserToolkit(config=config) as toolkit:
agent = Agent(model="gpt-4o", toolkits=[toolkit])
result = await agent.arun("What page am I on?")
Persistent Profile
Keep cookies and login state across runs:
config = BrowserConfig(user_data_dir="/tmp/my-browser-profile")
result = await agent.arun("""
Go to https://example.com/signup
Fill in the email field with "[email protected]"
Fill in the password field with "secure123"
Click the submit button
""")
Combined with MCP
from definable.mcp import MCPToolkit, MCPConfig
async with BrowserToolkit(config=config) as browser:
async with MCPToolkit(config=MCPConfig(...)) as mcp:
agent = Agent(
model="gpt-4o",
toolkits=[browser, mcp],
)