```python
# 1. Import our WebSurferAgent
from autogen import LLMConfig
from autogen.agents.experimental import WebSurferAgent
from dotenv import load_dotenv
import os
load_dotenv()

# Put your key in the OPENAI_API_KEY environment variable
llm_config = LLMConfig(config_list=[{"api_type": "openai", "model": "gpt-5-nano", "api_key": os.getenv("OPENAI_API_KEY")}])

# 2. Add additional browser configurations for our browser-use tool
browser_use_browser_config = {"browser_config": {"headless": False}, "agent_kwargs": {"generate_gif": True}}

# 3. Create the agent, nominating the tool and tool config
web_researcher = WebSurferAgent(
    name="researcher",
    web_tool="browser_use",
    web_tool_kwargs=browser_use_browser_config,
    llm_config=llm_config,
)

# 4. Run our agent, passing in the tools that our WebSurferAgent has so they can be executed
ag2_news_result = web_researcher.run(
    "Search for the latest news on AG2 AI",
    tools=web_researcher.tools,
)

print(ag2_news_result.summary)
```
