Running at scale and in CI
A scenario needs no one watching, so a CI job or a script can run it and read the result. This page is for the job that requests the sessions, starts the runs and gathers what they leave behind.
One session, several scenarios
Section titled “One session, several scenarios”kasm-session-runtime run a.yaml b.yaml runs the files in one session, one after another. They share the session and the deadline, and there is no reset between them, so each file starts with its own cdp_navigate or other setup step.
Each file writes to $KASM_RUNTIME_OUT/<name>/. The top level holds summary.json, with the worst-of verdict and one entry per file, and a DONE that is written after it. The exit code follows the worst verdict: 0 for pass and pass-with-concerns, 1 for app-failed, 2 for test-error. The 01-cdp-chrome example in the toolkit runs a passing and a failing scenario this way.
One scenario per session
Section titled “One scenario per session”To run many scenarios at once, give each its own Kasm session. For each one, the job does the following through the Kasm API:
- Requests a session for the workspace image with
request_kasm, and waits until it is running. - Uploads the scenario file, and any fixture it needs, into the session.
- Starts
kasm-session-runtime runin the session through the API’s exec call. - Waits for the run to finish. The output directory’s
DONEfile is written last and holds the verdict. - Downloads the output directory.
- Destroys the session.
Steps 1, 2 and 5 need a Kasm API key and secret. Upload and download also need a Kasm user’s login cookie. The 08-parallel-agentic-goals example has a working orchestrator, written in Python, that runs these steps for a set of scenarios with a cap on concurrent sessions.
Deciding pass and fail
Section titled “Deciding pass and fail”| Result | What a CI job usually does |
|---|---|
Exit 0, pass |
Pass |
Exit 0, pass-with-concerns |
Pass, or fail the job if your policy treats concerns as failures. The concerns are in reasons in report.json |
Exit 1, app-failed |
Fail: the application, or a check against it, failed |
Exit 2, test-error |
Fail and look at the setup: display, output directory, deadline, interruption, escalation |
pass-with-concerns includes a plan that fell back to a loop with no model to run it. See Plans and postconditions.
An orchestrator that starts a run and reads the report later waits for DONE first. The runtime removes a DONE left from an earlier run when it starts, and withholds the new one if the report could not be written.
Collecting reports
Section titled “Collecting reports”Keep each session’s output directory. report.md is the page to open for a failure: the reason is on its first line, and screenshots/99-failure.png shows the screen when it failed. A job that tracks results over time reads report.json, whose timings hold the seconds spent in each stage and in the model. Artifacts from CI jobs are worth expiring after a few days, since each run holds screenshots.
Limits
Section titled “Limits”- Two runs that write to the same output directory cannot both be live. The second exits 2 and writes nothing, so give each session or scenario its own directory.
KASM_RUNTIME_DEADLINE_S(600 by default) covers the whole invocation, and the last 30 seconds go to diagnosis and the report. Set it from the longest scenario in the job.- A scenario with a
goal:or a visual check calls a model. If sessions share one model server, their calls queue on it, so more sessions at once do not make the model-driven parts faster. Keep the number running at once within what the server can serve. Scripted steps and replayed plans make no model call and are not limited by this.