<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma" -->

---
title: Browser automation with Pydantic AI + Playwright | daily.dev
description: A walkthrough shows how to build a browser-automation agent by combining Pydantic AI with the PlaywrightBrowser capability from pydantic-ai-harness. It covers...
canonical: https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Browser automation with Pydantic AI + Playwright | daily.dev
og:description: A walkthrough shows how to build a browser-automation agent by combining Pydantic AI with the PlaywrightBrowser capability from pydantic-ai-harness. It covers...
og:url: https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma
og:image: https://api.daily.dev/og/posts/5AypIwpma.png
og:image:alt: Browser automation with Pydantic AI + Playwright
og:image:width: 1200
og:image:height: 630
og:locale: 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 QA a website using Playwright?

Use the PlaywrightBrowser capability from pydantic-ai-harness, passing it into a Pydantic AI Agent alongside a FileSystem capability for writing reports. Configure allowed_domains to restrict navigation, block_private_addresses to prevent access to localhost, and max_content_tokens (default 4000) to control how much page text is returned to the model.

_daily.dev surfaces practical guides like this for developers wiring up agentic browser automation._

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

Pass a storage_state to the PlaywrightBrowser instance containing cookies and local storage from an authenticated session. Generate that state by running the Playwright codegen command with --save-storage, logging in manually, then closing the browser; the resulting JSON file should be kept secure and never checked into version control.

_Developers building authenticated automation flows can track this kind of guidance on daily.dev._

### How do I trace and debug what a Pydantic AI agent's browser tool calls are doing?

Instrument the agent with OpenTelemetry by configuring Logfire with instrument_openai and instrument_pydantic_ai calls, which export traces using the Generative AI semantic conventions. Traces can be sent to Pydantic Logfire, Azure App Insights via azure-monitor-opentelemetry-exporter, or a local JSONL file that a coding agent can later audit to improve prompts and parameters.

_daily.dev helps engineers debugging agent observability stay on top of tools like OpenTelemetry and Logfire._

## 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
- [Building Agentic QA Pipelines with Browser Automation and .NET](https://daily.dev/posts/building-agentic-qa-pipelines-with-browser-automation-and-net-dmm5yphvr) · C\# Corner · 4 upvotes · 0 comments
- [Building programmable QA with AI](https://daily.dev/posts/building-programmable-qa-with-ai-funlrqjoa) · thoughbot · 3 upvotes · 0 comments
- [How to Build Reliable Stateful Browser Automation with Playwright](https://daily.dev/posts/how-to-build-reliable-stateful-browser-automation-with-playwright-qqzelgknv) · SitePoint · 0 upvotes · 1 comments
- [AI Browser Agents 2026: Stagehand vs Browser Use](https://daily.dev/posts/ai-browser-agents-2026-stagehand-vs-browser-use-of9lhq6hu) · Alex CloudStar · 0 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)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Browser automation with Pydantic AI + Playwright","url":"https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma"},"datePublished":"2026-08-20T22:01:08.078Z","dateModified":"2026-09-14T09:13:36.755Z","description":"A walkthrough shows how to build a browser-automation agent by combining Pydantic AI with the PlaywrightBrowser capability from pydantic-ai-harness. It covers...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/abad17cbe6c7fbdc7c70eeb5bebbdd48?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/abad17cbe6c7fbdc7c70eeb5bebbdd48?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Pamela Fox","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Pamela Fox","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/9c7963f6b19440b1b6bc15aff07efda7","url":"https://daily.dev/sources/pamelafox"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ai-agents,azure,opentelemetry","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Pamela Fox","item":"https://daily.dev/sources/pamelafox"},{"@type":"ListItem","position":3,"name":"Browser automation with Pydantic AI + Playwright"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/browser-automation-with-pydantic-ai-playwright-5aypiwpma#faq","mainEntity":[{"@type":"Question","name":"How do I give a Pydantic AI agent the ability to browse and QA a website using Playwright?","acceptedAnswer":{"@type":"Answer","text":"Use the PlaywrightBrowser capability from pydantic-ai-harness, passing it into a Pydantic AI Agent alongside a FileSystem capability for writing reports. Configure allowed_domains to restrict navigation, block_private_addresses to prevent access to localhost, and max_content_tokens (default 4000) to control how much page text is returned to the model. daily.dev surfaces practical guides like this for developers wiring up agentic browser automation."}},{"@type":"Question","name":"How can I let a Playwright-based agent access a website that requires login?","acceptedAnswer":{"@type":"Answer","text":"Pass a storage_state to the PlaywrightBrowser instance containing cookies and local storage from an authenticated session. Generate that state by running the Playwright codegen command with --save-storage, logging in manually, then closing the browser; the resulting JSON file should be kept secure and never checked into version control. Developers building authenticated automation flows can track this kind of guidance on daily.dev."}},{"@type":"Question","name":"How do I trace and debug what a Pydantic AI agent's browser tool calls are doing?","acceptedAnswer":{"@type":"Answer","text":"Instrument the agent with OpenTelemetry by configuring Logfire with instrument_openai and instrument_pydantic_ai calls, which export traces using the Generative AI semantic conventions. Traces can be sent to Pydantic Logfire, Azure App Insights via azure-monitor-opentelemetry-exporter, or a local JSONL file that a coding agent can later audit to improve prompts and parameters. daily.dev helps engineers debugging agent observability stay on top of tools like OpenTelemetry and Logfire."}}]}
```

