The authoring loop
This page is for agents, and for people who direct them. It describes the order to call the tools in and what each answer means. MCP tools lists every tool with its arguments.
The loop
Section titled “The loop”- Find or make the project.
list_projects, thenlist_environments. A new application needscreate_projectandcreate_environment. - Look at what is there.
list_routesandlist_variablesshow the names steps can use.list_workflowsandlist_tagsshow what exists, so you reuse a folder or tag name instead of inventing a near-duplicate. - Save the workflow.
save_workflowreads every step and returns each one’s status and reading. - Fix what needs a change, and read the readings. Save again until
okis true. - Run it.
start_runreturns at once. Callget_rununtilstatusisfinished. - When a step did not pass, read why.
get_rungives the first step that did not pass withwhy.get_step_evidenceshows what Belay chose as the target and, on request, the screenshot. - Change the workflow or report the failure. Then run again.
get_step_guide says what a step can do: every action and every check, with sentences Belay understands, and what is not supported yet. Read it once before you write steps. It gives the same text as Actions, Checks, and the other pages under Writing steps.
validate_workflow reads a definition as saving would, without saving or running anything. Use it to try wordings.
On a live page
Section titled “On a live page”A live page lets an agent write steps against the application itself instead of saving and running blind. Each sentence is performed on the page as soon as it is sent, and the answer says what happened.
-
Open it.
start_sessionwith a saved workflow’sworkflow_idand anenvironment_id. Withbefore_step_id, the steps before that one run and the page is held there, so that step is next. Without it, every step runs and the page is held after the last, ready for steps added at the end. The answer comes once the page is held, withsessionId, where the page is (position, the last step that passed on it), and the steps so far.include_screenshot: trueadds the page as it is held, to write the first step against. -
Send steps.
perform_stepswith a list insteps. Each item is one of:{"sentence": "..."}: a new step, performed where the page is (after the last step that passed on it). It joins the steps when it passes.{"step_id": "s3"}: a step already there, performed as written.{"step_id": "s3", "sentence": "..."}: that step rewritten, then performed.
The steps are performed in order, and the call stops at the first that does not pass. Each answer has the step’s
reading, itsoutcome, what it acted on or read and how sure Belay was (target,check), and for a step that did not pass,whyand anysuggestions. Belay finds an element from the step’s description, so a step whose words are not an element’s exact name still passes, as it does in a run when a label changes. Its answer says which element Belay matched inadapted, and the call’snextnames the step. If that is the element you meant, the step is good as written. If you meant another, take the step back withrewind_sessionanddiscard, and send a sentence that names the one you meant. -
Fix what did not pass. A new sentence that did not pass is not kept, and its answer has no
stepId: send a rewrite as a new sentence. A step that was already there keeps its new sentence and is the page’sstoppedAt: rewrite it by itsstep_id. If the step changed the page before it failed,rewind_sessionwith abefore_step_idputs the page back: a fresh page, with the steps before that one run again. To take back steps you performed and do not want, such as a click made only to look around, adddiscard: true: that step and every step after it leave the steps, and the page is held after the last one that remains. The first step cannot be discarded. -
End and save.
end_sessionwithsave: truesaves the steps to the workflow exactly as they are on the live page, then closes it. The answer hasokand each step’s status, as a save’s does, and the workflow keeps its name, folder, and tags. If the save is refused, the page stays open. Withoutsave, nothing is saved: the steps come back as adefinition, to change and pass tosave_workflowyourself. Thenstart_runto see the whole workflow pass.
A sentence that needs a change is not performed and is not added; its answer carries needs, reason, and any replacement, as a save’s does. The steps on a live page are the workflow’s own steps and the new sentences that passed on the page, so nothing you only tried is among them.
Preview first
Section titled “Preview first”perform_steps with preview: true takes one step and stops before acting: an action says what it would act on, a check says whether it would pass, and the page does not move. A previewed new sentence is not kept: to perform it, send it again without preview. A step that was already there keeps a new sentence it was previewed with; perform it by its step_id. Preview a step when you are unsure what it will act on, and before a step that changes something in the application that cannot be undone, such as a payment, a deletion, or a sent message.
A new workflow
Section titled “A new workflow”A live page belongs to a saved workflow. To start a new one, save its first step with save_workflow, usually a step that goes to a page, then start_session with no before_step_id. That step runs and the page is held after it. Then send the new sentences.
A draft begun in the editor is its maker’s alone, and no tool finds it, including the maker’s own agent: start_session, get_workflow, and list_workflows answer as if it were not there. A live page open in the editor on a draft is not the agent’s either: get_session says one is open there, on a workflow that isn’t saved yet, and get_session, perform_steps, rewind_session, and end_session refuse it until the draft is a workflow. It still counts as the one live page you hold, so start_session is refused while it is open, unless take_over closes it.
Put the variables the steps will use in that first save, or in the project. A live page cannot add a variable.
The rules of a live page
Section titled “The rules of a live page”- You hold one live page at a time, opened from the editor or by an agent. A
start_sessionwhile you hold one is refused with itssessionId, its workflow, and when it was last used.take_over: truecloses it and opens the new one; that is refused while it is in the middle of a step. - One call at a time. A call that arrives while another is being answered is refused; wait for the answer.
- A live page an agent opened closes by itself after 10 minutes with nothing sent, and steps that were not saved go with it.
end_sessionwhen you are done. - A rewind, and the run after you save, perform the steps again. The application remembers what the first pass did, so a step that adds a customer adds a second one. Write steps that still pass the second time.
get_sessionsays where the page is and lists the steps so far, eachdone,stopped, orahead. With nosession_idit finds the live page you hold.include_screenshotadds the page’s latest image, as it does onstart_sessionandrewind_session. Onperform_stepsit adds the image that explains the last answer, or withimage: "page"the page as those steps left it, which is what you write the next step against.- A live page does not count against the month’s runs. See Limits.
Without a live page
Section titled “Without a live page”To try the first steps of a workflow without one, run it with stop_after_step_id.
The definition
Section titled “The definition”A workflow’s definition is a JSON object:
{ "schemaVersion": 1, "description": "A helmet can be added to the cart.", "variables": { "customerName": "Robin Lee" }, "steps": [ { "id": "s1", "instruction": "Go to the shop page." }, { "id": "s2", "instruction": "Click the Add to cart button on the \"Trail Helmet\" card." }, { "id": "s3", "instruction": "Check that the cart shows \"Trail Helmet\"." } ]}- Each step’s id is its own: it starts with a letter, then letters, digits,
-, and_. Keep a step’s id when you edit its sentence. variablesare the workflow’s own. They win over the project’s variables of the same name.- Routes belong to the project. This example’s first step needs a route named
shop(save_route), or the path in the step:Go to /shop.A definition that carriesroutesis refused. - Do not include
baseUrl; the environment owns it. Do not include anidfor the workflow; it is theworkflow_idargument.
The workflow’s name is a separate argument. Make it a plain title people can read in a list, such as “Checkout refuses a bad email”.
Reading the answer to a save
Section titled “Reading the answer to a save”Each step comes back with a status.
understood has a reading: one sentence saying what Belay will do or check. Read every one. If a reading checks less than the step says, rewrite the step. A reading that says a check is judged from a picture is right for a visual claim, and a warning sign for anything you meant to compare exactly.
needs a change has needs (the kind, in words), refusal (the kind, as a fixed name to branch on), reason, and often a replacement: the steps to write in its place.
- A replacement with no
notedoes everything the original said. Use it as it is. - A replacement with a
notechecks less, and the note says what it drops. Ask the person before using it. - A
questionoffers two meanings, each with its own replacement. Choose the one the person meant, or ask.
A workflow whose steps need a change is still saved, but it cannot run until every step is understood. Steps that need a change lists the kinds.
Four things save nothing, and the answer says which: a definition that is not valid (a missing id, a variable no one declares), a step that could not be read at all, a save past one of the plan’s limits, and a save when the organization has had as many steps read as it may in an hour (the answer says when to try again).
Wording that works
Section titled “Wording that works”- One action or check per step.
- Describe the element as a person would: its name, its kind, where it is.
- Quote exact text. For a loose check, write “mentions”:
Check that the alert mentions that the email is required. - Never write “it” or “that one”. Name the thing in each step.
- To carry a value forward, remember it:
Remember the ticket number in the Repair booked banner as {{ticketNumber}}.
Actions and Checks list the sentences Belay understands. get_step_guide gives an agent the same pages.
When a step is not found
Section titled “When a step is not found”A step that was understood can still end unresolved in a run: nothing on the page clearly matched its description, or Belay could not settle between a few elements. get_run may then carry suggestions on that step. Each is a wording Belay tried on the same page that picked one element the step came close to, usually with the whole step rewritten to use it (instruction).
- If one suggestion names the element you meant, put its
instructionin the step and save. When it has noinstruction, write its wording into the step yourself. - If none does, do not pick one. Call
get_step_evidenceand look at the page.
Rules that keep results honest
Section titled “Rules that keep results honest”- Do not rerun to make a run pass. Each run takes time and counts against the organization’s plan, and a pass on a second try hides whatever made the first one stop. Read why first.
- An interrupted run is the exception. A run whose outcome is
interruptedhas no result: Belay could not finish it, and neither the application nor the test is the cause. It counts against no limit. Run it again withstart_run, orrerun_interruptedfor a batch, which works on the newest batch of its selection on its environment. - Do not loosen a check to get a pass. If the application shows the wrong thing, the failing step is correct. Report it.
- Do not pick an unrelated element to get past a step that was not found.
- A run that stopped early proves less.
start_runwithstop_after_step_idruns up to that step. If it passed, only those steps passed.
Routines
Section titled “Routines”When several workflows repeat the same steps, such as signing in, make them a routine: save_routine with a name a step would say (“Log in as admin”) and a description of when to use it, or make_routine to turn a saved workflow’s steps into one. A workflow then runs it with a step that says its name. list_routines shows each routine’s id, what values it needs and remembers, and which workflows run it; get_routine gives its steps and how they were read.
- In a save’s answer, a step that runs a routine has
routine, with the routine’s steps and their readings. A step that might mean one has aquestion: write the routine’s name as the step, or rewrite the step as an action or a check. make_routineandget_routinelist insameStepsthe project’s workflows that hold the routine’s steps written out, the same sentences in the same order.use_routinewith thoseworkflow_idsputs the routine in their place and answers each workflow, changed or left as it was with areason. To put a routine in place of steps that are not its own word for word, write its name as the step withsave_workflow.save_routinereads every workflow that runs the routine again. Its answer says how many run it (usedBy) and how many can’t run now (noLongerRun).- In a run, a routine’s step has its
place, such as2.3, andget_runnames it “step 2.3, in Log in as admin”. Change it withsave_routine, never in the workflow, and every workflow that runs it gets the change. start_sessionwithroutine_idtries a routine on a live page, starting from a workflow that runs it (workflow_id) or from the project’s start page, andend_sessionwithsave: truesaves the routine. In a workflow’s live page,perform_stepsperforms a step that runs a routine whole, with each of its steps’ results, numbered 2.1, 2.2. When one of them does not pass, the steps before it have already acted, so the step is not performed again on that page:rewind_sessionto before it first.delete_routineis refused while a workflow runs the routine.
Organizing and running many
Section titled “Organizing and running many”A workflow sits in one folder and can carry tags. Set them with save_workflow’s folder and tags, or later with organize_workflow, which reads no step again.
start_batch runs every workflow with a tag, in a folder, or in the project, on one environment. get_batch gives the batch’s result (passed, failed, or incomplete) and what changed since the last batch of the same selection. See Batches.
Limits
Section titled “Limits”A plan can limit runs each month, and on some plans each hour, as well as how many workflows and projects an organization has and how many steps one workflow holds. A refused call says which limit it met and, for runs, when they can start again. See Plan and usage.
A live page uses none of the month’s runs. Opening one counts once toward the hour on a plan with an hourly limit, and a plan may limit how many live pages the organization holds open at once.