Step 2: real Playwright integration for fetch-page-title#3
Merged
rockfordlhotka merged 1 commit intomainfrom Apr 21, 2026
Merged
Step 2: real Playwright integration for fetch-page-title#3rockfordlhotka merged 1 commit intomainfrom
rockfordlhotka merged 1 commit intomainfrom
Conversation
Replaces the HttpClient + regex implementation with a Playwright Chromium
navigation through Foragent.Browser. Milestone 2 from the project spec (§9.1).
- Foragent.Browser becomes a real library: IBrowserSession + IBrowserSessionFactory
(public contracts) backed by PlaywrightBrowserHost (IHostedService owning
one shared Chromium per process) and PlaywrightBrowserSessionFactory (fresh
IBrowserContext per session per spec §3.5). AddForagentBrowser() extension
wires the lot.
- ForagentTaskHandler no longer takes HttpClient; it pulls an IBrowserSession
from the factory, disposes it after use. Handler contract to A2A is unchanged.
- Unit tests in Foragent.Agent.Tests use a StubBrowserSessionFactory — no
Chromium spin-up. Integration tests in Foragent.Browser.Tests exercise the
real PlaywrightBrowserSessionFactory against an in-process Kestrel host
serving canned pages (plain title, missing title, HTML entities, JS-rendered
title, redirects, 404, session isolation). Tests install Chromium on demand.
- InternalsVisibleTo("Foragent.Browser.Tests") on Foragent.Browser so tests
drive the real factory/session without promoting those types to public.
- Dockerfile switches to aspnet:10.0 base (Playwright's own v1.50.0-noble
image ships only .NET 8) and installs Chromium + system deps at image-build
time via `dotnet exec --runtimeconfig ... Microsoft.Playwright.dll install
chromium --with-deps`. Dropped the /app named volume that was masking the
new image contents.
- framework-feedback.md appended with step-2 observations.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the HttpClient + regex implementation of
fetch-page-titlewith a real Chromium navigation throughForagent.Browser. Milestone 2 from the project spec (§9.1).Foragent.Browserbecomes a real library:IBrowserSession+IBrowserSessionFactory(public contracts) backed byPlaywrightBrowserHost(IHostedServiceowning one shared Chromium per process) andPlaywrightBrowserSessionFactory(freshIBrowserContextper session, spec §3.5).AddForagentBrowser()extension wires the lot.ForagentTaskHandlerno longer takesHttpClient; it pulls anIBrowserSessionfrom the factory and disposes it after use. Public A2A contract unchanged.Foragent.Agent.Testsuse aStubBrowserSessionFactory— no Chromium. Integration tests inForagent.Browser.Testsexercise the real factory against an in-process Kestrel host serving canned pages (plain title, missing title, HTML entities, JS-rendered title, redirects, 404, session isolation). Chromium is installed on demand into~/.cache/ms-playwright.InternalsVisibleTo("Foragent.Browser.Tests")onForagent.Browserso integration tests drive the real factory/session without promoting implementation types to public.Dockerfileusesmcr.microsoft.com/dotnet/aspnet:10.0(the Playwrightv1.50.0-nobleimage ships only .NET 8) and installs Chromium + OS deps at image-build time viadotnet exec --runtimeconfig Foragent.Agent.runtimeconfig.json Microsoft.Playwright.dll install chromium --with-deps. Dropped the/appnamed volume that was masking the fresh image contents.docs/framework-feedback.mdappended with step-2 observations.Test plan
dotnet build --configuration Release— clean, 0 warningsdotnet test— 15/15 pass (7 unit tests + 7 Playwright integration tests + 1 placeholder)docker compose build foragentsucceedsLaunching Playwright Chromium+Chromium launched (version 133.x)POST http://localhost:5210/withfetch-page-titleagainsthttps://example.comreturnsExample Domainend-to-end (HTTP → auth → bus → handler → Playwright navigation → reply back through bus → HTTP response)Known limitations (carried to later milestones)
EchoChatClientstill present — Foragent v2 still doesn't do LLM reasoning.🤖 Generated with Claude Code