Make a recipe for your application
A recipe pays off when the same step comes up in many runs and you can say how to check it. Saving a file in a particular application, reading one value out of a window, or importing a table are all examples. A playbook step that an agent works out afresh each time costs model calls and can come out differently. A recipe does it the same way and returns a receipt.
Keep a step in the playbook when it needs judgement, or when you cannot name a check for it. An agent that follows a Markdown step is a recipe too, at the first level, and it is a sound place to begin.
Authoring runs in a terminal inside a session and needs no model in the runtime. Working out how an application behaves usually falls to an agent, ideally a capable one, and the people running the recipes later can use a lighter one. If you would rather not write code, the bundled playbook Write your own playbook asks you about the job, explores the applications and leaves a playbook and the recipes it needs in your profile.
The steps
Section titled “The steps”- Work out the route in the application, and write down what you find in a guide.
- Record a run with
recipes run --trace, and draft an operation from it. - Write the operation: inputs, checks, limits.
- Build the package and check it.
- Run it from each starting state you can produce, and keep the receipts.
- Install it.
A package
Section titled “A package”A package is a folder for one application. The folder holds these files.
apps/<app>/ README.md the guide: routes, traps, how to check each result operations.py the operations, written as typed Python recipe_types.py the types the operations name recipe.json built from the two files above; do not edit it <steps>.md one Markdown file per instructional recipeREADME.md is the app guide that every package needs. Write it for an agent that has just opened it. Say what the application is, which version you tested, the routes that worked, the traps (what blocks, what merges, what reformats), and how to check each result. Leave the task’s objective out, because the guide is about the application and several playbooks can share it.
operations.py holds the operations. recipe_types.py holds the types they name, and the build reads it without running it. recipe.json is generated by kasm-session-runtime recipes build. Hand-written recipe.json packages still load, and recipes build --from-json DIR converts one to typed form.
A package folder may hold regular files and folders only. A link anywhere in it makes the loader reject the package.
Record a run and draft from it
Section titled “Record a run and draft from it”Run what you have by hand through the runtime with --trace. It prints the receipt on standard output as usual, and one line per recipe on standard error showing the outcome, time, calls and any question asked.
kasm-session-runtime recipes run --trace exif.read_metadata < arguments.json > receipt.jsonkasm-session-runtime recipes draft --from-trace receipt.jsondraft prints a package skeleton. It names an operation after the trace’s root, lists the methods the trace used, and leaves a placeholder for each question that was asked. It has no locators, no changes and no checks, and its headed_runs is 0, so it is an outline to write from and not a recipe to install.
The operation
Section titled “The operation”An operation is a decorated function. The decorator says what the code cannot, the signature gives the inputs, and the return type gives the output. This excerpt is from the bundled exif package.
@operation( "exif.read_metadata", description="Read the embedded metadata of one local file.", pre={"file": "on disk"}, post={"metadata": "read"}, pre_check=[File("{path}", timeout_s=2)], post_check=[File("{path}", timeout_s=2)], effects="None. Reads one file; nothing is written, changed or sent anywhere.", timeout_s=20, max_calls=2, provenance={ "app_version": "ExifTool 13.59", "runtime_version": "packages-v1-5db08351", "tested_on": "2026-10-11", "headed_runs": 1, },)def read_metadata(path: "AbsolutePath") -> "ReadMetadataResult": ...| Part | What it does |
|---|---|
| First argument | The operation’s ID. Choose one under your package’s prefix |
description |
One sentence on what it does and what it checks |
pre, post |
Plain labels for the states before and after. Readers see them in describe, and nothing verifies them |
pre_check, post_check |
The conditions the runtime tests. {path} is replaced with the input. The constructors are State, Window, NoWindow, File, Url, Dom, Process, NoProcess and Screen |
effects |
What the operation changes |
application |
The application it binds to. It must be running exactly once |
timeout_s |
The operation’s own time allowance, from 1 to 60 seconds |
max_calls |
How many calls the body may make, from 1 to 64 |
skip_if_satisfied |
Lets the runtime skip the body when post_check already holds for these inputs. The post_check must mention an input |
provenance |
The application and runtime versions tested, the date and the count of watched runs that ended verified. Required |
| Parameters | Become the input format. A parameter with a default is optional |
| Return annotation | A TypedDict in recipe_types.py. It becomes the output format |
The check that matters most is post_check. It has to read the result from somewhere other than the call that made it, such as the file on disk or the field’s own contents. A check that only repeats what the call reported cannot tell a result from a failure.
A package that starts with no provenance does not load. A fresh draft has headed_runs of 0, and the index marks it experimental until you record real runs.
The body
Section titled “The body”The body is Python in a small interpreter with no files, network or environment. It calls the runtime through three functions at the top of operations.py, call, run and decide, which recipes guide authoring/reference gives in full. call invokes a runtime method, run invokes another recipe, and decide asks a question.
The body should observe first, then act, and read the result back before it returns. Raising an error ends the run as refused when nothing has changed and unverified when something has. The caller sees which of the two happened. Return success only after a check has confirmed the result.
Two rules keep recipes safe to repeat. Find controls by role and name each time, and never record a handle or a coordinate from your own run. Ask a question with decide when the code cannot decide, such as a sign-in or a licence. A question marked for a person goes to them in the sidebar, and the question’s ID comes from the data and not from a counter.
A composite is an operation whose body is mostly run calls. It lists the operations it calls under uses, and each child gets its own receipt frame with its own limits. A child that ends unverified or needs_decision ends the parent with the same outcome.
Build and check
Section titled “Build and check”Run both after every edit.
kasm-session-runtime recipes build ~/.local/share/kasm-session-runtime/recipeskasm-session-runtime recipes check ~/.local/share/kasm-session-runtime/recipesbuild [DIR] writes recipe.json for each typed package under DIR, or under the current folder when you leave it out, and prints a JSON report. It reads your files and never runs them. recipes check [DIR] loads the whole catalogue, bundled and image layers plus yours, and prints "ok": true or a list of problems. Neither needs a session token. Both exit 0 on success and 1 when they find problems. A package that fails the check does not load.
check also names bundled operations that your package replaces under overrides, and the operations that depend on them under affects. It reports manifest_stale when recipe.json no longer matches the source, which a new build clears.
The bundled packages are the best examples. exif is one operation with a sandboxed helper. slack and maltego show composites and questions for a person.
Test it
Section titled “Test it”Run the operation headed, with recipes run --trace, from each state you can produce: the starting state you expect, the result already in place, a dialog in the way, and the state changing during the run. Use disposable material. Keep every receipt. Count in headed_runs only the runs you watched end verified.
Then give an agent of the tier you intend people to use the objective and the package, and watch it. It should run recipes index before it looks at the screen, call your recipes for the covered steps, answer a needs_decision through --resume, hand a person’s question to the person, and report the outcome the receipt gave. If it does not, fix the guide or the package.
Install it
Section titled “Install it”Save the package under ~/.local/share/kasm-session-runtime/recipes/. Create catalogue.json there, holding {"revision": "<your label>"}, if the folder is new. The package then appears in recipes index with layer: user.
A persistent Kasm profile keeps the folder for later sessions. To give the package to a team, an administrator places it in the workspace image under /usr/share/kasm-session-runtime/recipes, in the same layout. Install recipes and playbooks describes that route, and the recipe worker an image needs for executable recipes.
Packages are trusted by where they are installed, so a package in your folder runs at once. An operation in your folder with the same ID as a bundled one replaces it for every composite that calls it, and keeps replacing it after the runtime updates. Pick new IDs under your own prefix unless replacing is the point. Deleting your copy restores the bundled one.
- Recipes lists the outcomes and the bundled packages your recipe sits beside.
- Write a playbook lists your recipe under
uses, so the agent starts with it. - Reference: recipes has the receipt and package formats.