WRITE WORKFLOW GUIDANCE FOR AI AGENTS
This guide shows you how to add guidance to a workflow: instructions for an AI
agent choosing and running it. Agents connected to your serve's /mcp read it,
and so do local agents through the swamp skill.
Add guidance to a workflow
Add a top-level guidance block with a one-line description and a markdown
body:
name: deploy-service
description: Deploys a service to an environment.
guidance:
description: Use when a member asks to deploy, ship or release a service to staging or production.
body: |
- Inputs: `service` (api, web or worker) and `environment` (staging or production).
- Before running, ask the member "Deploy <service> to <environment>?" and wait for a yes.
- A production deploy needs a change ticket. Ask for one in the form CHG-1234 and
pass it as `ticket`. Never start a production deploy without it.
- After the run, read its log with workflow_run_logs and report the line that
starts with "deployed".
jobs:
# ...Check it with swamp workflow validate <name>.
description(required) says when to use the workflow, in one line of at most 1024 characters, with no line breaks. Agents see it in every search result, so keep it under about 250 characters. It is separate from the workflow's owndescription, which is for people.body(required) is markdown of at most 32 KiB. An agent reads it the first time it uses the workflow, or when unsure how. Write it as one self-contained page: it is served as text, so links to other files and scripts don't work.
Guidance is never evaluated, so a ${{ ... }} in it stays as written. Editing
it doesn't change the run fingerprint, so it never blocks a resume.
Write guidance an agent follows
- Start the description with when. "Use when a member asks to roll a service back" lets an agent match a request; "Rolls back services" does not.
- Name each input and its allowed values, especially ones the input schema can't say, such as a ticket format.
- Say what to confirm before running, and what must never run without confirmation.
- Say what to check afterwards: which step's log to read, and what line to report.
- Say when not to use it, if another workflow fits better.
Every agent connected to /mcp is told to search for workflows, read guidance
on first use, and follow it unless it conflicts with what the member asked:
This swamp server runs workflows for the member. To help with a task, call workflow_search to find the workflows they may use and offer the ones that fit; a result with guidance says when to use it. The first time you use a workflow, or when unsure how, call workflow_get: it returns its inputs and any guidance from the people who maintain it. Follow that guidance unless it conflicts with what the member asked. Start a run with workflow_run and follow it with workflow_run_get.
The text is fixed: you can't add to it.
Who sees it
Guidance goes to anyone who may read the workflow, and to their agent: in
workflow get and workflow_get whole, and as the description in
workflow search and workflow_search. Write it as you would any instruction
to an assistant acting for that reader, and keep secrets out of it.
An extension's workflows bring their author's guidance with them. Pulling the extension is the only approval it gets, so read it before you pull.
Roll it out
The workflow schema is strict, so a Swamp release older than guidance refuses a workflow that sets it, and a repository holding one fails to load it. Upgrade every machine and every serve replica, followers included, before you add guidance. An extension that ships workflows with guidance should say in its README which Swamp release it needs, since the manifest has no field for it.