---
title: "Browser automation with Pydantic AI + Playwright"
url: https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma
source_url: https://blog.pamelafox.org/2026/08/browser-automation-with-pydantic-ai.html
type: article
source: "Pamela Fox"
published: 2026-08-20T22:01:08.078Z
updated: 2026-08-20T22:44:46.956Z
tags: ["ai-agents", "azure", "opentelemetry"]
reading_time: 8
upvotes: 1
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Browser automation with Pydantic AI + Playwright

**[Pamela Fox](https://daily.dev/sources/pamelafox)** · 8 min read · 1 upvotes · 0 comments

## Summary

A walkthrough shows how to build a browser-automation agent by combining Pydantic AI with the PlaywrightBrowser capability from pydantic-ai-harness. It covers connecting to Microsoft Foundry models via Entra ID authentication, configuring Playwright options (allowed domains, timeouts, content limits, headless mode), building an agent that performs manual QA passes on a website and writes Markdown reports, instrumenting the agent with OpenTelemetry traces exported to Pydantic Logfire and Azure App Insights, and handling authenticated websites via saved session storage state. Full sample code is available on GitHub.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://blog.pamelafox.org/2026/08/browser-automation-with-pydantic-ai.html>

## Questions this post answers

### How do I give a Pydantic AI agent the ability to browse and interact with a website?

Integrate the PlaywrightBrowser capability from pydantic-ai-harness into a Pydantic AI agent's capabilities list. Configure options like allowed_domains to restrict navigation, block_private_addresses to prevent access to local networks, max_content_tokens to control page text size, and action/navigation timeouts, then let the agent call Playwright tools automatically during a run.

_daily.dev surfaces practical guides like this for teams wiring browser automation into AI agents._

### How can a Playwright-based agent access a website that requires login?

Pass a storage_state to the PlaywrightBrowser instance containing cookies and local storage captured from an authenticated session. Generate that state file by running the Playwright codegen command against the target site, logging in, and saving it with --save-storage, then load that JSON file when constructing the browser so the agent inherits the logged-in session.

_Developers building authenticated automation flows can track patterns like this via daily.dev._

### How do you monitor what an AI agent did during a Playwright browsing session?

Instrument the agent with OpenTelemetry by configuring Logfire with instrument_openai and instrument_pydantic_ai calls, which export traces following the Generative AI semantic conventions. Traces can be sent simultaneously to Pydantic Logfire, a local JSONL file, and Azure Application Insights via additional span processors, revealing which pages were visited, which commands ran, and token usage.

_daily.dev helps engineers stay current on observability approaches for debugging AI agent behavior._

## Similar posts on daily.dev

- [Building Browser-Using AI Agents in Python](https://daily.dev/posts/building-browser-using-ai-agents-in-python-wzikpcbci) · Machine Learning Mastery · 1 upvotes · 0 comments

---

Tags: [#ai-agents](https://daily.dev/tags/ai-agents), [#azure](https://daily.dev/tags/azure), [#opentelemetry](https://daily.dev/tags/opentelemetry)

[View this post on daily.dev](https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma)
