Skip to content
Draft, pre-release documentation

A postcondition says what must be true after a step: the URL changed, a window opened, a process started, a button became enabled. A plan is a list of steps that each carry at least one postcondition. The runtime replays a plan with no model call, checks each postcondition as it goes, and hands over to the runtime’s loop only if one fails.

A task the loop worked out once can then run the same way every time. Let the loop solve it, compile the run into a plan, review the plan, commit it to the scenario, and later runs replay it.

Two lanes. Once, with a model: the runtime's loop works the task out, compile-plan turns the run into a plan, a person reviews the YAML and commits it to the scenario as a plan: block. Every later run, with no model: the plan's steps replay one after another, each followed by its postcondition check, and the run ends in a report. When a postcondition fails, the loop, with a model, takes over from that step.Once, with a modelRun the loop oncea model works the task outCompile the plancompile-plan reads the runReview the YAMLa person reads each stepCommit to the scenarioa plan: blockthe plan replaysEvery later run, no modelStep 1declared actionpostcondition holdsStep 2declared actionpostcondition holdsStep 3declared actionpostcondition holdsReportverdict, evidencea postcondition fails:the loop takes over from that stepThe loop, with a modelfinishes the task from there
The top lane runs once and needs a model. The bottom lane is every later run: the plan's declared steps, each followed by its postcondition check, with no model call. Only a failed check brings the model back, for that step onwards.

Each entry in a post: list sets exactly one kind. Every kind except screen is polled, every 250 ms by default, for up to timeout_s seconds (default 10). A condition that never holds fails the step, and the report records what was observed.

Kind Holds when Needs a model
url: "<substring>" The tab’s location.href contains the substring No
dom: "<js boolean>" The expression is true in the page No
state: "<element> [not] <state>" The application reports the control in that state, over AT-SPI No
window: "<substring>" A window whose title or class contains it exists No
no_window: "<substring>" No such window exists No
process: "<substring>" A process whose command line contains it is running No
no_process: "<substring>" No such process is running No
file: "<path>" The path exists in the session No
screen: "<expectation>" The model judges the expectation true on a settled screenshot Yes

screen is judged once, takes no timeout_s, and is the weakest evidence in the list. Use it where nothing else can observe the effect. With no model configured, a screen condition is recorded as not judged and does not fail the step.

A post: list is accepted on a step under steps:, where it is optional and replaces an action followed by a separate wait; on a step under plan:, where at least one entry is required; and on a tool the scenario declares under tools:. Each evaluated condition is written to the step’s post array in report.json as {kind, arg, held, detail, ms}.

steps:
- action: cdp_navigate "http://127.0.0.1:8901/login.html"
post:
- url: "/login.html"

A scenario with a plan runs in three phases: steps: (setup, which must pass), then plan:, then goal: only if the plan did not complete.

plan:
- action: cdp_fill "#username" "demo-user"
post:
- dom: "document.querySelector('#username').value === 'demo-user'"
- action: cdp_click "button.login"
post:
- url: "#/dashboard"
goal: "Sign in with the credentials provided and confirm the dashboard has loaded."

The runtime rejects these at load: a plan without a goal:, which is the fallback; a plan step without an action and at least one post: entry; an observe step inside a plan; and a plan of more than 40 steps, counted apart from steps:.

A plan that completes has run every action and checked every postcondition. report.plan records {steps, completed, failed_step, reason} either way, so a run that fell back is distinguishable from one that never had a plan.

A plan step fails when its action fails on the application’s side or its postcondition does not hold. The run does not end there. The runtime records the failed row, notes the step and the reason in the report, skips the remaining plan steps, and enters the runtime’s loop from wherever the plan left the screen. The loop’s first input action must look at the screen first, as after any other change. A lost browser connection or a missing display still ends the run as test-error.

What happens next depends on whether a model is configured.

With a model endpoint With no model endpoint
The loop Works towards the goal: from the current screen Is entered, marked degraded and returns at once
The failed step Recorded in report.plan Recorded in report.plan
The verdict The final checks decide, with the loop’s verdict added as in Goal steps The final checks decide. A concern is added: “agentic loop degraded – goal not verified; deterministic probes own this verdict”
Exit code 0, 1 or 2 by verdict 0 with pass-with-concerns when the process and window checks are clean

With no model, a failed plan step does not fail the run. The scenario exits 0, and the only signs are the pass-with-concerns verdict, the concern in reasons, and plan.completed: false with failed_step in report.json. A job that must stop on a plan fallback tests for those: treat pass-with-concerns as failure, or read plan.completed. If another deterministic check fails as well, the verdict is app-failed.

Terminal window
kasm-session-runtime compile-plan <run output dir> [--scenario base.yaml]

compile-plan reads report.json and trace.jsonl from a finished run of a goal: scenario and prints a plan: block. With --scenario, it prints the base scenario with the plan appended and checks that the result loads; the base scenario needs a goal: and no plan. It never edits a file in place: the output is YAML for a person to read and commit. It runs offline, with no session and no model.

It refuses a run whose model verdict was not goal-met and exits 1, because a plan compiled from an unfinished run would replay the unfinished part and pass on its own postconditions. --allow-incomplete overrides this.

Each tool call in the transcript becomes one plan step.

The loop called The plan gets
cdp_click_described cdp_click_described "<resolved name>", using the element name from the result, never the per-page handle the loop passed
cdp_click on a declared target cdp_click "<selector>", when --scenario supplies the target
click_element click_element "<name>"
press_key key "<chord>"
click click "<target>" or click center. Nothing for a click with another button, a count or modifiers
scroll, drag Nothing: a scripted step has neither
type_text, cdp_fill Nothing: the transcript does not record typed values. Add these by hand with a variable reference
click_grounded Nothing: a click located on screen has no deterministic postcondition

Each step’s postcondition is inferred from what happened next, in this order: the page’s URL changed; a cdp_wait the loop ran held; a later cdp_url read a new URL; a filtered cdp_list_interactive found something; a check_expectation held (this compiles to a screen condition); failing all of those, the next action’s target is on the page. If a step has none, the output marks it TODO and compile-plan exits 1. Replace each TODO by hand.

A plan is specific to the page it was compiled from and does not generalise across parameters. When the application changes, a postcondition fails, the run falls back to the loop, and the report names the step where the page had moved.

The 08-parallel-agentic-goals example runs one scenario against several pages, one Kasm session each. Phase 1 runs the loop on each page with a model. The script then runs compile-plan on each downloaded report, writes the compiled scenarios to out/plans/, and phase 2 replays them with no model call. Each phase 2 report says whether its plan completed or fell back, and at which step. Running at scale and in CI covers the fan-out.

Agent JIT compilation (Winston et al., ICML 2026) found that most web-agent failures are a tool called in the wrong state, and that most of an agent’s wall clock is per-step inference. From it we took postconditions declared on steps and plans compiled from earlier runs. We left out its planner, which has a model write code that calls tools. The runtime keeps a closed vocabulary of actions, and its compiler is deterministic and produces YAML a person can review.