What the agent does
A server-rendered Blazor app has no endpoint an orchestrator can ask whether it is alive, and the home page is a poor substitute: it renders a layout, loads static assets and tells you nothing about the database. The agent reads how the app starts before adding anything. In an app like 10.0/BlazorWebAppMovies in dotnet/blazor-samples, Program.cs registers AddDbContextFactory<BlazorWebAppMoviesContext> over UseSqlServer, calls SeedData.Initialize before the pipeline is configured, and then adds UseStatusCodePagesWithReExecute("/not-found"), UseHttpsRedirection, UseAntiforgery, MapStaticAssets and MapRazorComponents<App>() with interactive server rendering. There is no call to AddHealthChecks or MapHealthChecks anywhere, and the project file references five packages, none of them for health checks.
It adds two endpoints with different jobs. /health/live runs no checks and answers 200 whenever the process can serve a request, so an orchestrator restarts the app only when it is stuck. /health/ready runs the checks tagged ready, here one database check added with AddDbContextCheck<BlazorWebAppMoviesContext> from the Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore package, pinned to the same 10.0 line as the EF Core packages already in the project. The split matters for this app in particular: a liveness probe that touched SQL Server would restart every replica during a database outage, which fixes nothing and drops every user's circuit.
Three details in this Program.cs decide whether the endpoints behave under a real probe. A database check against a server that has gone away waits for the SQL client's connection timeout, far longer than a probe allows, so the agent sets a short Timeout on the check's registration. UseStatusCodePagesWithReExecute re-runs error responses that have no body through /not-found, so the agent confirms the 503 from the readiness endpoint carries the health check's own body and is not replaced by the app's not-found page. And UseHttpsRedirection will redirect a plain HTTP probe once an HTTPS port is configured, so the pull request says which scheme the probe must use.
Then it runs the app against a real database, because the check is only worth merging if it has been seen to fail. The sandbox has no Docker, so the agent installs it with sudo apt-get install -y docker.io and starts dockerd, runs Microsoft's SQL Server image for Linux, applies the three migrations in Migrations with dotnet ef database update, and starts the app with the connection string in ConnectionStrings__BlazorWebAppMoviesContext. It requests both endpoints, stops the database container, requests them again, and starts it once more. It also opens /movies in the sandbox's browser to confirm the grid still renders with the new endpoints mapped.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "codex",
"input": "Add health check endpoints to this Blazor Web App and open a pull request. Read the .csproj, Program.cs, appsettings.json, Data/SeedData.cs, the DbContext and Properties/launchSettings.json first, and search for any existing AddHealthChecks or MapHealthChecks. Register health checks with one database check for the app's DbContext, tagged ready, using the EF Core health checks package on the same version line as the project's other EF Core packages, and give that check a timeout of a few seconds. Map /health/live with a predicate that runs no checks and /health/ready with a predicate for the ready tag, before MapRazorComponents. Do not change the seeding, the render modes or the existing middleware order. To verify, install Docker in the sandbox, start SQL Server from Microsoft's Linux image, apply the migrations with dotnet ef database update, and run the app with the connection string from the ConnectionStrings environment variable. Request both endpoints with the database up, stop the database container and request them again, then start it and request them a third time; record status code, body and response time each time, and confirm an unhealthy response is the health check's own body and not the app's not-found page. Open /movies in the browser to confirm the app still works. Put the commands and what each request returned in the pull request description, with the probe paths and scheme an orchestrator should use.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that changes two files: the project file gains one package reference, and Program.cs gains the registration and two MapHealthChecks calls. The description holds a small table with three rows, database up, database stopped and database back, and for each endpoint the status code, the body and how long the response took. That table is the proof that the readiness endpoint turns unhealthy within the timeout and recovers without a restart, and that the liveness endpoint stays healthy throughout.
A reviewer checks that the liveness predicate really excludes every check, that the endpoints are mapped where authorization added later will not accidentally cover them, and that no connection string or password from the test database ended up in a committed file. They also decide what the agent only states: whether the endpoints should be reachable from the public port or bound to a separate management port, and what probe intervals fit their platform.
One thing the pull request says plainly: this app queries the database during startup, in SeedData.Initialize, so with the database down at boot the process exits before either endpoint exists. The health checks cover an outage after startup. Making startup tolerant of a missing database is a separate change the description offers as a follow-up.
Run it on every terminal hand-off
This is a change a developer knows is needed and never gets to, usually remembered the day before a first deploy. From an MCP client in the terminal, a create_session call with this prompt and the repository starts the run in its own sandbox and returns at once, so the developer keeps working on the feature in hand.
wait_for_sessions waits up to 50 seconds per call and returns the answer once the turn has ended; get_session_changes shows the diff without leaving the terminal. If the probe paths should differ from the ones in the prompt, send_session_message wakes the same sandbox, with the database container's image already pulled, and the agent changes them and repeats the three requests.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
The part of this job that takes time is not the six lines in Program.cs. It is standing up SQL Server, applying migrations, and stopping the database on purpose to watch the endpoint change, on a machine where LocalDB, the database this app's appsettings.json points at, exists only on Windows. The agent does that in a sandbox of its own, with Docker installed there, and the status codes and timings it recorded are in the run's transcript for anyone who wants to check the table.
A health endpoint that has never been observed failing is a guess. Because the run stops the database and records what the endpoint did, the reviewer merges something whose failure behaviour is known, including how long an unhealthy answer takes, which is the number a probe timeout has to be set against.
Frequently asked questions
Does the readiness check work with AddDbContextFactory?
Yes. Registering a context factory also makes the context itself resolvable from a scope, which is what the EF Core health check asks for. The agent confirms it by running the app and calling the endpoint, not by assuming it.
Should the health endpoints check the SignalR circuit?
No. A circuit belongs to one user's connection, and a probe has no circuit to inspect. Liveness answers whether the process serves requests; whether interactive rendering works is covered by opening a page in a browser, which the run does once as a sanity check.
Can the endpoints be kept off the public port?
Yes. MapHealthChecks returns an endpoint builder, so the endpoints can be restricted to a host and port with RequireHost, and the app then listens on a second port for probes. The agent leaves this out by default and adds it when the prompt names the port.
Will it return JSON with each check's status?
The default response is a plain-text status. If the prompt asks for JSON, the agent adds a response writer that lists each check with its status and duration, and keeps exception text out of the body so a probe response never leaks a connection string.
More Blazor jobs
The same job on other stacks
- Add Health Checks to a chi API (chi)
- Add a Health Check Endpoint to a Cloudflare Worker (Cloudflare Workers)
- Add a Health Check Endpoint to a CodeIgniter 4 App (CodeIgniter)