What the agent does
The agent reads what the project already runs. In a service laid out like grafana/quickpizza, .github/workflows/ci.yaml builds the Go binary with make build, starts it with ./bin/quickpizza &, installs k6 with grafana/setup-k6-action, and runs every script under k6/foundations, k6/internal and k6/browser through k6/run-tests.sh. That script passes --no-thresholds and --summary-mode=disabled to every run, with a comment saying some threshold examples fail, and fails only on a non-zero exit or an error-level line in the JSON log. So the foundations scripts that declare http_req_failed: ['rate<0.01'] and http_req_duration: ['p(95)<500', 'p(99)<1000'] are run as tutorials, and nothing in CI fails when the server gets slow.
It then writes one new script, k6/smoke/smoke.js, that is not a tutorial. From quickpizza-openapi.yaml and k6/internal/01.quickpizza.js it takes the calls a deploy must survive: GET /ready and GET /healthz, POST /api/users/token/login with the default user, POST /api/pizza with the same restrictions body the foundations scripts send and the token abcdef0123456789 header they use, and GET /api/quotes. The script uses a handful of VUs for about thirty seconds, a setup() that fails fast when GET BASE_URL is not 200, as 05.thresholds.js does, a check per response, and thresholds on http_req_failed, http_req_duration and checks.
The duration thresholds are taken from the script's own run against the binary in the sandbox, with headroom, and the pull request says what was measured. The point is a floor that a regression crosses, not a benchmark. A new step in ci.yaml, placed right after the server starts and before the foundations run, calls k6 run -e BASE_URL=http://localhost:3333 k6/smoke/smoke.js directly rather than through run-tests.sh, so the thresholds count and the summary prints. run-tests.sh and the tutorial scripts are left exactly as they are.
The agent builds the binary with make build-go in its sandbox, starts it, runs the smoke script against it, and runs make format-check and make test-go to show nothing else moved. The README's list of folders under k6/ gains a line for smoke, and the .github/workflows/README.md table notes that ci.yaml now has a threshold-enforced smoke run beside the tutorial runs.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add a k6 smoke test that fails CI on thresholds. Read .github/workflows/ci.yaml, k6/run-tests.sh, k6/foundations/05.thresholds.js, k6/internal/01.quickpizza.js, quickpizza-openapi.yaml, Makefile and README.md first. Write k6/smoke/smoke.js: a few VUs for about thirty seconds against GET /ready, GET /healthz, POST /api/users/token/login as the default user, POST /api/pizza with the restrictions body and token the foundations scripts use, and GET /api/quotes, with a setup that fails when the base URL is not 200, a check per response, and thresholds on http_req_failed, http_req_duration and checks. Build the binary with make build-go, start it, run the script, and set the duration thresholds from what you measure with headroom. Add a CI step right after the server starts that runs k6 run -e BASE_URL=http://localhost:3333 k6/smoke/smoke.js without --no-thresholds, leave run-tests.sh and the tutorial scripts unchanged, document the new folder in README.md and .github/workflows/README.md, run make format-check and make test-go, and open a pull request quoting the k6 summary.",
"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 adds k6/smoke/smoke.js, one step in ci.yaml, and two README lines. The description quotes the end-of-test summary from the agent's own run, with each threshold and whether it passed, and names the measured values the duration thresholds were set from.
The run's record keeps the build, the server start, the k6 output and the Go tests, so a reviewer can see the response times the thresholds were derived from rather than take the headroom on trust.
Before merging, a reviewer settles two things: whether the durations measured on the sandbox should be loosened for a shared CI runner, and whether the smoke step should also run in the example_* demo workflows, which the repository marks as not part of the real pipeline. The agent leaves those alone.
Run it on every release branch
Once the script is in, the job of keeping it honest is periodic. An automation in the Project with a schedule trigger, cron set to a weekday morning in the trigger's timezone, runs a prompt that builds the current main, runs k6/smoke/smoke.js with the summary written out, and compares the p95 against the threshold with the headroom the pull request recorded, posting its answer as the run's result when the gap has closed.
A team with several services starts one run per repository with one POST /o/{org}/sessions each, this prompt as input and the repository in resources, with a request_id that is a UUID v5 of the repository's full name so a retry returns the run it already started. Each run reads its own CI workflow and OpenAPI file, so a service that starts its server differently gets a step that fits.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A smoke test is only useful when its thresholds are set from a real run against the real binary, and only safe when it runs where CI runs the server. Both need a build, a running process and k6 in one place. The agent has all three in its own sandbox and keeps the output, so the numbers in the pull request are the numbers it saw.
The change is a script and a workflow step, so review is a diff and a quoted summary rather than a local build of your own. Across several services the job runs in parallel, one sandbox and one pull request each, each with thresholds measured on that service.
Frequently asked questions
Why not just drop --no-thresholds from run-tests.sh?
Because the foundations scripts are tutorials: 05.thresholds.js and its siblings declare thresholds to show the feature, and the comment in run-tests.sh says some of them fail by design. Enforcing them would turn teaching material into a flaky check. One script written for the job, run directly, is the honest version.
How long does the step add to CI?
About the script's duration plus startup: the agent sizes it at a few VUs for around thirty seconds, which is the smallest run that gives a p95 worth comparing. It runs before the foundations, internal and browser suites, so a broken deploy fails early.
What about the demo workflows that use run-k6-action?
The example_tests.yaml family runs against a published Docker image and the workflows README marks them as demos, not CI. The agent does not touch them. The smoke step goes in ci.yaml, which runs the binary built from the pushed source, the one that matters.
Does the script need the users.json data or an extension?
No. It logs in as the default user that 01.quickpizza.js already relies on and sends the fixed token the foundations scripts send, so it runs on plain k6 from setup-k6-action with no xk6 build and no data file.
More jobs like this: Hand off a long task
- Add Social Card Images to a Gatsby Blog (Gatsby)
- Add Social Cards to a Hugo Site (Hugo)
- Add Social Preview Cards to a MkDocs Material Site (MkDocs)
- Add Soft Delete to an Actix Web API (Actix Web)
- Add Soft Delete to an ASP.NET Core App (ASP.NET Core)
- Add Soft Delete to an Axum API (Axum)