What the agent does
The agent reads how the frontend talks to the other services. In a Go service laid out like the frontend of GoogleCloudPlatform/microservices-demo, src/frontend/main.go opens one grpc.ClientConn per dependency through mustConnGRPC, which calls grpc.NewClient with insecure.NewCredentials() and the otelgrpc stats handler. That helper creates a three-second context.WithTimeout and then never uses it, which is harmless with grpc.NewClient, since that constructor does not dial, but reads as if connections were bounded when nothing is. Every call in src/frontend/rpc.go, getCurrencies, getProducts, getProduct, getCart, insertCart, convertCurrency, getShippingQuote, getRecommendations, passes the context it was given, and src/frontend/handlers.go gives each one r.Context(), which ends only when the browser disconnects. So a stalled productcatalogservice holds a home-page request open for as long as the client waits, and getRecommendations, which calls getProduct once per recommended id, multiplies that wait.
The deadline goes where the call is made. The agent adds a callTimeout constant to rpc.go and a helper that derives a child context with context.WithTimeout and returns its cancel, and uses it in every method there, so each RPC is bounded on its own and a slow currency conversion cannot eat the budget of the cart read after it. placeOrderHandler in handlers.go calls PlaceOrder on the checkout service directly, and that call fans out to six more services inside src/checkoutservice/main.go, so it gets a longer constant of its own. The same pattern lands in the checkout service: its getUserCart, prepOrderItems, quoteShipping, convertCurrency, chargeCard, shipOrder, emptyUserCart and sendOrderConfirmation helpers all take the incoming ctx, which already carries the frontend's deadline over the wire as gRPC propagates it, and each now gets its own shorter bound under it. The unused timeout in both mustConnGRPC functions is removed, with a comment saying grpc.NewClient connects lazily.
An expired deadline has to read as what it is. renderHTTPError in handlers.go writes whatever status the caller passes, and every handler passes http.StatusInternalServerError today. The agent adds a small function that checks status.Code(err) and returns http.StatusGatewayTimeout for codes.DeadlineExceeded and codes.Unavailable, and the handlers use it, so a dashboard can tell a dependency that timed out from a bug in the frontend. The error page template still shows the message, which for a wrapped error from errors.Wrap in getShippingQuote keeps the context the code already adds.
Proof is a test with a slow server. src/frontend/validator/validator_test.go is the only test in the frontend today, and .github/workflows/ci-pr.yaml runs go test for shippingservice, productcatalogservice and frontend/validator. The agent adds src/frontend/rpc_test.go in package main, starts an in-memory gRPC server over bufconn that implements ProductCatalogService from the generated genproto package with a GetProduct that sleeps past the timeout, points a frontendServer at it, calls getProduct and asserts the call returns within the bound with codes.DeadlineExceeded; a second case answers at once and asserts success. It then adds frontend to the workflow's package list beside frontend/validator, runs go test ./... in src/frontend and src/checkoutservice, and runs go vet in both.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add deadlines to every outbound gRPC call in the frontend and checkout services. Read src/frontend/main.go, src/frontend/rpc.go, src/frontend/handlers.go, src/checkoutservice/main.go, src/frontend/validator/validator_test.go and .github/workflows/ci-pr.yaml first. Give each call in rpc.go its own context.WithTimeout from a named constant, a longer one for PlaceOrder, and the same per-call bounds in the checkout service's helpers. Remove the unused timeout in both mustConnGRPC functions with a comment. Map codes.DeadlineExceeded and codes.Unavailable to a 504 in the handlers. Add src/frontend/rpc_test.go with a bufconn ProductCatalogService that sleeps past the deadline, add the frontend package to the Go test loop in ci-pr.yaml, run go test and go vet in both services, quote the results and open a pull request.",
"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
What comes back is a pull request that changes src/frontend/rpc.go, src/frontend/handlers.go, src/frontend/main.go and src/checkoutservice/main.go, adds src/frontend/rpc_test.go, and adds one entry to the package loop in .github/workflows/ci-pr.yaml. No manifest or proto changes: the deadlines are constants in code, and the proto's service names are read from the generated package.
The description holds the go test and go vet output for both services, the two timeout values with one sentence each on why they were chosen, and a list of every call site with its new bound, so a reviewer can see that none was missed. The repository's Continuous Integration - Pull Request workflow runs the Go and C# unit tests on the branch, now including the frontend package.
Before merging, a reviewer decides whether the bounds should be environment variables set in kubernetes-manifests/frontend.yaml rather than constants, and whether a DeadlineExceeded on the adservice call should show an empty ad slot rather than an error page, since chooseAd already tolerates an error from getAd. The agent keeps the constants and the existing ad behaviour and names both.
Run it on every GitHub issue labelled reliability
In the Project that holds the repository, create an automation with a general form of this page's prompt and a github trigger on issues.labeled with reliability in its labels. The issue text is placed after the prompt, so the prompt says to read the issue that follows, find the service it names, bound every outbound call there the way the frontend's rpc.go does, add a slow-server test and open a pull request that links the issue.
An engineer who sees the home page hang during a product catalog restart files the issue, and the run opens the pull request with the test output in it. The next issue, for the Node or Python services that call productcatalogservice with their own clients, starts its own run, and the trigger fires only for a label added by a repository owner, member or collaborator.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
Showing that a deadline works means a server that is slow on purpose, a test that measures the wait, and both Go modules built and vetted, which is more than a laptop review of a diff usually does. The sandbox builds the services, runs the slow fake and keeps the timings, so the pull request opens with the proof in it.
The run's record keeps each call site the agent changed and the test that bounds it, so a reviewer reads the list rather than searching the diff for a missed call. Across the other Go services in the same repository, checkoutservice, productcatalogservice and shippingservice, the same request runs at once, one sandbox each.
Frequently asked questions
Why per-call deadlines rather than one on the whole request?
A single deadline on r.Context() would let the first slow call spend all of it and leave the later calls in the same handler with nothing. A bound per call means each dependency gets the same budget and a page fails on the one that is slow, which the error page then names.
Does the checkout service need its own bounds if the frontend already set one?
gRPC carries the frontend's deadline to the checkout service in the request metadata, so the incoming ctx in PlaceOrder already expires with it. The service still adds a shorter bound per helper so that one slow dependency, say payment, does not consume the whole order's budget before email is attempted.
What does the user see when a deadline passes?
The same error template as today, with a 504 instead of a 500 and the wrapped error text naming the call. The agent leaves the template alone and notes that an ad lookup that times out already falls back to no ad in chooseAd.
Will the new test slow CI?
The slow fake sleeps just past the test's timeout, which the test sets to a fraction of a second, so the case ends as soon as the deadline fires. The agent quotes the go test duration for the package.
More jobs like this: Turn a Linear label into a PR
- Add Health Checks to an ASP.NET Core App from a Linear Issue (ASP.NET Core)
- Add Health Checks to a Docker Compose Setup (Docker Compose)
- Add Health Checks to a Phoenix App (Phoenix)
- Add Health Checks to a Symfony App (Symfony)
- Add Helm Test Hooks to a Chart from a Linear Issue (Helm)
- Add a Horizontal Pod Autoscaler to an App on GKE (GKE)