{
  "answers": {
    "c00": {
      "noul": 0.59,
      "type": "noul"
    },
    "c01": {
      "noul": 0.27,
      "type": "noul"
    },
    "c02": {
      "noul": 0.35,
      "type": "noul"
    },
    "c03": {
      "noul": 0.43,
      "type": "noul"
    },
    "c04": {
      "noul": 0.18,
      "type": "noul"
    },
    "c05": {
      "noul": 0.79,
      "type": "noul"
    },
    "c06": {
      "noul": 0.85,
      "type": "noul"
    },
    "c07": {
      "noul": 0.56,
      "type": "noul"
    },
    "c08": {
      "noul": 0.04,
      "type": "noul"
    },
    "c09": {
      "noul": 0.77,
      "type": "noul"
    },
    "c10": {
      "noul": 0.86,
      "type": "noul"
    },
    "c11": {
      "noul": 0.95,
      "type": "noul"
    },
    "c12": {
      "noul": 0.93,
      "type": "noul"
    },
    "c13": {
      "noul": 0.95,
      "type": "noul"
    },
    "w00": {
      "noul": 0.08,
      "type": "noul"
    },
    "w01": {
      "noul": 0.05,
      "type": "noul"
    },
    "w02": {
      "noul": 0.06,
      "type": "noul"
    },
    "w03": {
      "noul": 0.93,
      "type": "noul"
    },
    "w04": {
      "noul": 0.94,
      "type": "noul"
    },
    "w05": {
      "noul": 0.81,
      "type": "noul"
    },
    "w06": {
      "noul": 0.98,
      "type": "noul"
    },
    "w07": {
      "noul": 0.96,
      "type": "noul"
    },
    "w08": {
      "noul": 0.96,
      "type": "noul"
    }
  },
  "asked_at": "2026-11-23T04:50:24Z",
  "endpoint": "https://api.typesafe.ai/v1/systemone",
  "errors_helpful": [
    {
      "call": 0,
      "noul": 0.59,
      "question": "c00"
    },
    {
      "call": 1,
      "noul": 0.27,
      "question": "c01"
    },
    {
      "call": 2,
      "noul": 0.35,
      "question": "c02"
    },
    {
      "call": 3,
      "noul": 0.43,
      "question": "c03"
    },
    {
      "call": 4,
      "noul": 0.18,
      "question": "c04"
    },
    {
      "call": 5,
      "noul": 0.79,
      "question": "c05"
    },
    {
      "call": 6,
      "noul": 0.85,
      "question": "c06"
    },
    {
      "call": 7,
      "noul": 0.56,
      "question": "c07"
    },
    {
      "call": 8,
      "noul": 0.04,
      "question": "c08"
    },
    {
      "call": 9,
      "noul": 0.77,
      "question": "c09"
    },
    {
      "call": 10,
      "noul": 0.86,
      "question": "c10"
    },
    {
      "call": 11,
      "noul": 0.95,
      "question": "c11"
    },
    {
      "call": 12,
      "noul": 0.93,
      "question": "c12"
    },
    {
      "call": 13,
      "noul": 0.95,
      "question": "c13"
    }
  ],
  "format": "didrun.judgments.v1",
  "input_tokens": 51433,
  "method": "0.15.0",
  "model": "jev-1.14.0",
  "model_asked": "jev-1.14.0",
  "request": {
    "model": "jev-1.14.0",
    "questions": {
      "c00": {
        "criteria": {
          "false": "The reply names no argument of the tool: for example a generic failure, a stack trace with no argument named, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply names at least one argument of the tool that the call left out or got wrong, and so tells the caller what to change."
        },
        "instructions": {
          "arguments_sent": {},
          "question": "Does `reply` name an argument that the call must add or fix?",
          "reply": "RunNotActive: run undefined is not active; it finished, failed or expired, so call the stepfile's tool again to start a new run",
          "tool": "stepgate_call"
        },
        "type": "noul"
      },
      "c01": {
        "criteria": {
          "false": "The reply does not point to `parameter`: for example a generic failure, an error about another argument, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply points to `parameter` or to its value and says the value has the wrong type or is not accepted."
        },
        "instructions": {
          "arguments_sent": {
            "operation": "didrun",
            "run": {}
          },
          "parameter": "run",
          "question": "Does `reply` tell the caller that `parameter` has a value the tool does not accept?",
          "reply": "RunNotActive: run [object Object] is not active; it finished, failed or expired, so call the stepfile's tool again to start a new run",
          "tool": "stepgate_call"
        },
        "type": "noul"
      },
      "c02": {
        "criteria": {
          "false": "The reply names no argument of the tool: for example a generic failure, a stack trace with no argument named, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply names at least one argument of the tool that the call left out or got wrong, and so tells the caller what to change."
        },
        "instructions": {
          "arguments_sent": {},
          "question": "Does `reply` name an argument that the call must add or fix?",
          "reply": "RunNotActive: run undefined is not active; it finished, failed or expired, so call the stepfile's tool again to start a new run",
          "tool": "stepgate_submit"
        },
        "type": "noul"
      },
      "c03": {
        "criteria": {
          "false": "The reply does not point to `parameter`: for example a generic failure, an error about another argument, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply points to `parameter` or to its value and says the value has the wrong type or is not accepted."
        },
        "instructions": {
          "arguments_sent": {
            "output": {},
            "run": {}
          },
          "parameter": "run",
          "question": "Does `reply` tell the caller that `parameter` has a value the tool does not accept?",
          "reply": "RunNotActive: run [object Object] is not active; it finished, failed or expired, so call the stepfile's tool again to start a new run",
          "tool": "stepgate_submit"
        },
        "type": "noul"
      },
      "c04": {
        "criteria": {
          "false": "The reply does not point to `parameter`: for example a generic failure, an error about another argument, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply points to `parameter` or to its value and says the value has the wrong type or is not accepted."
        },
        "instructions": {
          "arguments_sent": {
            "name": {}
          },
          "parameter": "name",
          "question": "Does `reply` tell the caller that `parameter` has a value the tool does not accept?",
          "reply": "18 catalog stepfiles. Call stepgate_examples with a name to read one.\n\n- airtable-field-completeness (data; keys: airtable): Reads up to 100 records of one Airtable table and reports, record by record, which of the fields you name are empty. Read-only.\n- snowflake-metric-to-jira (data; keys: snowflake, jira): Runs one fixed, read-only SELECT you supply against Snowflake through the SQL API once a person approves it, checks the metric it returns against your threshold, and only when the threshold is breached, and a person approves the draft, creates a Jira issue labelled stepgate-draft that quotes the exact values returned and the exact SQL.\n- dependency-upgrade-risk (engineering; no keys): Checks each npm package and pinned version against the npm registry and OSV.dev, and recommends an upgrade only where the registry's latest release is published and OSV lists no advisory against it.\n- servicenow-incident-review (engineering; keys: servicenow, github): Reads a ServiceNow incident, lists the GitHub commits and merged pull requests on one branch in the hours before it opened, builds a timeline and a list of suspect changes that cite real commit SHAs and pull request numbers, and adds the review to the incident as an internal work note once a person approves it.\n- sec-10k-ratio-extraction (finance; no keys): Resolves a US-listed ticker to its SEC CIK, pulls revenue, net income, total assets, total liabilities, equity and operating cash flow from the XBRL facts of its latest annual 10-K, and computes ratios that gates recompute from the SEC figures.\n- drug-shortage-watch (health; no keys): Checks each generic drug on a formulary against the current openFDA drug shortage list and returns an action list in which every status and NDC comes from an FDA record.\n- auto-claim-vin-validation (insurance; no keys): Decodes an auto claim's VIN with NHTSA vPIC, compares the claimed make, model and year against the decode, lists the vehicle's NHTSA recalls, and returns a consistent",
          "tool": "stepgate_examples"
        },
        "type": "noul"
      },
      "c05": {
        "criteria": {
          "false": "The reply names no argument of the tool: for example a generic failure, a stack trace with no argument named, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply names at least one argument of the tool that the call left out or got wrong, and so tells the caller what to change."
        },
        "instructions": {
          "arguments_sent": {},
          "question": "Does `reply` name an argument that the call must add or fix?",
          "reply": "The stepfile is invalid. Fix every issue:\n- /: must be object",
          "tool": "stepgate_validate"
        },
        "type": "noul"
      },
      "c06": {
        "criteria": {
          "false": "The reply does not point to `parameter`: for example a generic failure, an error about another argument, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply points to `parameter` or to its value and says the value has the wrong type or is not accepted."
        },
        "instructions": {
          "arguments_sent": {
            "stepfile": {}
          },
          "parameter": "stepfile",
          "question": "Does `reply` tell the caller that `parameter` has a value the tool does not accept?",
          "reply": "The stepfile is invalid. Fix every issue:\n- /: must be object",
          "tool": "stepgate_validate"
        },
        "type": "noul"
      },
      "c07": {
        "criteria": {
          "false": "The reply names no argument of the tool: for example a generic failure, a stack trace with no argument named, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply names at least one argument of the tool that the call left out or got wrong, and so tells the caller what to change."
        },
        "instructions": {
          "arguments_sent": {},
          "question": "Does `reply` name an argument that the call must add or fix?",
          "reply": "UrlNotPublic:  is not a public https URL",
          "tool": "stepgate_inspect_api"
        },
        "type": "noul"
      },
      "c08": {
        "criteria": {
          "false": "The reply does not point to `parameter`: for example a generic failure, an error about another argument, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply points to `parameter` or to its value and says the value has the wrong type or is not accepted."
        },
        "instructions": {
          "arguments_sent": {
            "kind": {},
            "url": "didrun"
          },
          "parameter": "kind",
          "question": "Does `reply` tell the caller that `parameter` has a value the tool does not accept?",
          "reply": "UrlNotPublic: didrun is not a public https URL",
          "tool": "stepgate_inspect_api"
        },
        "type": "noul"
      },
      "c09": {
        "criteria": {
          "false": "The reply names no argument of the tool: for example a generic failure, a stack trace with no argument named, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply names at least one argument of the tool that the call left out or got wrong, and so tells the caller what to change."
        },
        "instructions": {
          "arguments_sent": {},
          "question": "Does `reply` name an argument that the call must add or fix?",
          "reply": "ProcedureInvalid: the procedure cannot be outlined: procedure must be the SKILL.md or SOP text",
          "tool": "stepgate_outline"
        },
        "type": "noul"
      },
      "c10": {
        "criteria": {
          "false": "The reply does not point to `parameter`: for example a generic failure, an error about another argument, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply points to `parameter` or to its value and says the value has the wrong type or is not accepted."
        },
        "instructions": {
          "arguments_sent": {
            "procedure": {}
          },
          "parameter": "procedure",
          "question": "Does `reply` tell the caller that `parameter` has a value the tool does not accept?",
          "reply": "ProcedureInvalid: the procedure cannot be outlined: procedure must be the SKILL.md or SOP text",
          "tool": "stepgate_outline"
        },
        "type": "noul"
      },
      "c11": {
        "criteria": {
          "false": "The reply names no argument of the tool: for example a generic failure, a stack trace with no argument named, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply names at least one argument of the tool that the call left out or got wrong, and so tells the caller what to change."
        },
        "instructions": {
          "arguments_sent": {},
          "question": "Does `reply` name an argument that the call must add or fix?",
          "reply": "StepfileInvalid: stepfile invalid: / must be object",
          "tool": "stepgate_try"
        },
        "type": "noul"
      },
      "c12": {
        "criteria": {
          "false": "The reply does not point to `parameter`: for example a generic failure, an error about another argument, an error from a service the tool tried to reach, or a normal answer.",
          "true": "The reply points to `parameter` or to its value and says the value has the wrong type or is not accepted."
        },
        "instructions": {
          "arguments_sent": {
            "inputs": {},
            "stepfile": {}
          },
          "parameter": "stepfile",
          "question": "Does `reply` tell the caller that `parameter` has a value the tool does not accept?",
          "reply": "StepfileInvalid: stepfile invalid: / must be object",
          "tool": "stepgate_try"
        },
        "type": "noul"
      },
      "c13": {
        "criteria": {
          "false": "The reply does not say the tool is missing: for example a generic failure, a crash, or a normal answer.",
          "true": "The reply says the tool is unknown, not found, or does not exist."
        },
        "instructions": {
          "arguments_sent": {},
          "question": "Does `reply` tell the caller that there is no tool named `tool`?",
          "reply": "no tool named didrun_unknown_tool",
          "tool": "didrun_unknown_tool"
        },
        "type": "noul"
      },
      "w00": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "## Available stepfile examples\n\n| Example | What it does |\n|---|---|\n| `airtable-field-completeness` | Audits Airtable records for empty required fields. |\n| `snowflake-metric-to-jira` | Checks a Snowflake metric and can create an approved Jira issue when a threshold is breached. |\n| `dependency-upgrade-risk` | Checks npm versions against the registry and OSV advisories. |\n| `servicenow-incident-review` | Builds an incident timeline from ServiceNow and GitHub changes. |\n| `sec-10k-ratio-extraction` | Extracts SEC 10-K figures and computes financial ratios. |\n| `drug-shortage-watch` | Checks a formulary against openFDA shortage records. |\n| `auto-claim-vin-validation` | Checks claim details and recalls against NHTSA data. |\n| `regulatory-change-monitor` | Briefs Federal Register rules for a topic or agency. |\n| `github-release-to-customers` | Drafts customer release notes from GitHub pull requests. |\n| `market-research` | Researches a brand’s market position using web sources. |\n| `book-list-verification` | Checks book titles and authors against Open Library. |\n| `meeting-scheduler` | Finds free calendar slots and drafts an invitation. |\n| `disaster-declaration-brief` | Summarizes OpenFEMA disaster declarations. |\n| `reference-list-validation` | Checks references against Crossref DOI records. |\n| `hubspot-deal-to-monday` | Plans and creates approved monday.com items from a closed-won deal. |\n| `cve-triage-prioritisation` | Prioritizes CVEs using NVD and EPSS data. |\n| `zendesk-jira-escalation` | Plans approved Jira escalations for matching Zendesk tickets. |\n| `event-weather-contingency` | Uses an Open-Meteo forecast to recommend an event decision. |\n\n## Example: `book-list-verification`\n\nI requested the YAML and README for this example, but the tool returned a **truncated response**: it stopped partway through the YAML, before the README. I therefore can’t show the complete files from the available tool result.\n\nThe returned YAML begins as follows:\n\n```yaml\n# yaml-l",
          "done_when": "The tool replies show the example catalog and the YAML and README for one listed example.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {},
              "reply": "18 catalog stepfiles. Call stepgate_examples with a name to read one.\n\n- airtable-field-completeness (data; keys: airtable): Reads up to 100 records of one Airtable table and reports, record by record, which of the fields you name are empty. Read-only.\n- snowflake-metric-to-jira (data; keys: snowflake, jira): Runs one fixed, read-only SELECT you supply against Snowflake through the SQL API once a person approves it, checks the metric it returns against your threshold, and only when the threshold is breached, and a person approves the draft, creates a Jira issue labelled stepgate-draft that quotes the exact values returned and the exact SQL.\n- dependency-upgrade-risk (engineering; no keys): Checks each npm package and pinned version against the npm registry and OSV.dev, and recommends an upgrade only where the registry's latest release is published and OSV lists no advisory against it.\n- servicenow-incident-review (engineering; keys: servicenow, github): Reads a ServiceNow incident, lists the GitHub commits and merged pull requests on one branch in the hours before it opened, builds a timeline and a list of suspect changes that cite real commit SHAs and pull request numbers, and adds the review to the incident as an internal work note once a person approves it.\n- sec-10k-ratio-extraction (finance; no keys): Resolves a US-listed ticker to its SEC CIK, pulls revenue, net income, total assets, total liabilities, equity and operating cash flow from the XBRL facts of its latest annual 10-K, and computes ratios that gates recompute from the SEC figures.\n- drug-shortage-watch (health; no keys): Checks each generic drug on a formulary against the current openFDA drug shortage list and returns an action list in which every status and NDC comes from an FDA record.\n- auto-claim-vin-validation (insurance; no keys): Decodes an auto claim's VIN with NHTSA vPIC, compares the claimed make, model and year against the decode, lists the vehicle's NHTSA recalls, and returns a consistent-or-refer verdict whose every value comes from those APIs.\n- regulatory-change-monitor (legal; no keys): Finds the final and proposed rules the Federal Register published for a topic or agency in a date range, and briefs which ones matter, citing document numbers and effective or comment-close dates taken from the API.\n- github-release-to-customers (marketing; keys: github, hubspot, gmail): Collects the pull requests merged between two GitHub releases, writes customer-facing release notes that cite them by number, finds the HubSpot contacts matching a property filter, and creates a Gmail draft to the operator with the notes and the recipient list. Creates a draft; never sends.\n- market-research (marketing; keys: tavily): Researches a brand's market position from web sources, discards what is irrelevant on the record, and writes a report in which every claim cites a source that survived the filter.\n- book-list-verification (media; no keys): Confirms that every book on a reading list exists in Open Library under the stated author, and flags books that do not exist or belong to someone else.\n- meeting-scheduler (productivity; keys: google-calendar, gmail): Queries Google Calendar free/busy for every attendee over a date range, proposes up to three slots inside working hours that Google confirms are free for everyone, and creates a Gmail draft of the invite email. Creates no calendar event and never sends.\n- disaster-declaration-brief (public; no keys): Lists every federal disaster declaration OpenFEMA records for a US state and date range, summarises them by incident type and assistance program, and writes a brief that cites each declaration by its FEMA disaster number.\n- reference-list-validation (research; no keys): Resolves every reference in a list to a real Crossref DOI record and flags references that are fabricated, carry the wrong DOI, or misstate the author or year.\n- hubspot-deal-to-monday (sales; keys: hubspot, monday): Reads a HubSpot deal, refuses it unless its stage is closed won, reads its line items, contacts and companies, plans one monday.com item per line item, and, once a person approves the plan, creates them as drafts in a new \"Stepgate draft\" group on a given board, each with an update carrying the deal, company and contact details.\n- cve-triage-prioritisation (security; no keys): Ranks up to five CVE ids into priorities 1 to 4 from their NVD CVSS score, CISA Known Exploited Vulnerabilities status as NVD records it, and FIRST EPSS probability, by a fixed published rule.\n- zendesk-jira-escalation (support; keys: zendesk, jira): Finds open Zendesk tickets matching an escalation rule (a priority and a tag), searches a Jira project for unresolved issues already tracking each problem, decides per ticket to link to one of them or create a Jira issue labelled stepgate-draft, and, once a person approves, creates those issues and adds an internal note naming the Jira key to every ticket. It never posts a public reply.\n- event-weather-contingency (travel; no keys): Finds the event location with Open-Meteo geocoding, fetches the daily forecast for the event date, applies fixed go, contingency and postpone thresholds, and writes a contingency plan that quotes the forecast it rests on.",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "book-list-verification"
              },
              "reply": "# book-list-verification.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading list against Open Library\ndescription: >\n  Confirms that every book on a reading list exists in Open Library under the\n  stated author, and flags books that do not exist or belong to someone else.\n\ninputs:\n  type: object\n  required: [books]\n  properties:\n    books:\n      type: array\n      description: The books to check, each with its title and the author the list names.\n      minItems: 1\n      maxItems: 30\n      items:\n        type: object\n        required: [title, author]\n        additionalProperties: false\n        properties:\n          title: { type: string, minLength: 1 }\n          author: { type: string, minLength: 1 }\n\ntools:\n  # Two tools over one endpoint so gates can tell a search filtered by the\n  # stated author, which is the attribution check, from a title-only search.\n  openlibrary-by-author:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title and author, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitleAndAuthor\n              summary: >\n                Search Open Library works matching both a title and an author\n                name. docs is empty when no work matches both.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: author\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitleAndAuthor]\n  openlibrary-by-title:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitle\n              summary: Search Open Library works by title alone, whoever wrote them.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitle]\n\nsteps:\n  - id: search\n    tools: [searchByTitleAndAuthor]\n    instructions: |\n      Here is a reading list:\n\n      {{inputs.books}}\n\n      Number the books B-01, B-02 and so on, in the order given. For every\n      book, call searchByTitleAndAuthor once, with title and author copied\n      exactly as given and limit 5. Make one call at a time.\n\n      For each book submit its id, title and author unchanged, and match: the\n      returned doc that is this book, as { key, title, author_name } copied\n      exactly (author_name is null if the doc has none). It is the same\n      title, allowing for case, punctuation and a subtitle. A doc with a\n      different title by the same author is not a match, nor is an omnibus or\n      box set. If no doc is this book, set match to null.\n    produces:\n      type: object\n      required: [books]\n      properties:\n        books:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, match]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^B-[0-9]{2,}$\" }\n              title: { type: string }\n              author: { type: string }\n              match: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      books: { map: [{ var: output.books }, { object: [[book, [{ var: title }, { var: author }]], [match, { var: match }]] }] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\": [{ var: tool }, searchByTitleAndAuthor] }, { \"!\": { var: is_error } }] }]\n          - object:\n              - [book, [{ var: arguments.title }, { var: arguments.author }]]\n              - [docs, { map: [{ var: result.docs }, &doc { object: [[key, { var: key }], [title, { var: title }], [author_name, { var: author_name }]] }] }]\n    gates:\n      - id: every-book-once\n        message: Submit every input book exactly once, with title and author unchanged and a unique id.\n        predicate:\n          and:\n            - \"==\":\n                - { length: { var: output.books } }\n                - { length: { var: inputs.books } }\n            - \"==\":\n                - { length: { unique: { map: [{ var: output.books }, { var: id }] } } }\n                - { length: { var: output.books } }\n            - subset:\n                - map: [{ var: inputs.books }, [{ var: title }, { var: author }]]\n                - map: [{ var: output.books }, [{ var: title }, { var: author }]]\n      - id: match-from-own-search\n        message: >\n          Every book needs a successful searchByTitleAndAuthor call with its\n          exact title and author, and match must be null or one of that call's\n          docs, copied exactly. These books break it:\n        predicate:\n          none:\n            - join: [{ var: let.books }, { var: let.searched }, book, book]\n            - or:\n                - \"==\": [{ var: right }, null]\n                - and: [{ var: left.match }, { \"!\": { subset: [[{ var: left.match }], { var: right.docs }] } }]\n    retries: 2\n\n  - id: crosscheck\n    tools: [searchByTitle]\n    instructions: |\n      These books were searched under their stated author:\n\n      {{steps.search.books}}\n\n      For every book whose match is null, and only those, call searchByTitle\n      with the title copied exactly and limit 5, to learn whether the book\n      exists under a different author. If every book has a match, make no\n      calls and submit an empty checks list.\n\n      For each book checked submit its id, title and author unchanged, and\n      found: the returned doc that is this book (same title, allowing for\n      case, punctuation and a subtitle), as { key, title, author_name } copied\n      exactly, or null if none is. A found doc must not list the stated\n      author, since that search already failed.\n    produces:\n      type: object\n      required: [checks]\n      properties:\n        checks:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, found]\n            additionalProperties: false\n            properties:\n              id: { type: string }\n              title: { type: string }\n              author: { type: string }\n              found: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      unmatched: { map: [{ filter: [{ var: steps.search.books }, { \"!\": { var: match } }] }, [{ var: id }, { var: title }, { var: author }]] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\":",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "airtable-field-completeness"
              },
              "reply": "# airtable-field-completeness.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: airtable-field-completeness\ntitle: Audit an Airtable table for empty required fields\ndescription: >\n  Reads up to 100 records of one Airtable table and reports, record by record,\n  which of the fields you name are empty. Read-only.\n\ninputs:\n  type: object\n  required: [base_id, table, required_fields]\n  properties:\n    base_id:\n      type: string\n      description: The base's id, the app... part of its URL.\n      pattern: \"^app[A-Za-z0-9]{14}$\"\n    table:\n      type: string\n      description: The table's name or its tbl... id.\n      minLength: 1\n    required_fields:\n      type: array\n      description: The field names every record should fill in.\n      minItems: 1\n      maxItems: 10\n      uniqueItems: true\n      items: { type: string, minLength: 1 }\n\ncredentials:\n  airtable:\n    kind: bearer\n    hosts: [api.airtable.com]\n    description: >\n      An Airtable personal access token with the data.records:read and\n      schema.bases:read scopes on the base to audit. Nothing is written.\n\ntools:\n  airtable:\n    openapi:\n      server: https://api.airtable.com\n      document:\n        openapi: 3.1.0\n        info: { title: Airtable Web API, reads only, version: \"0\" }\n        paths:\n          /v0/meta/bases/{baseId}/tables:\n            get:\n              operationId: getBaseSchema\n              summary: >\n                The base's tables, each with its id, name and fields (id, name\n                and type).\n              security: [{ token: [] }]\n              parameters:\n                - { name: baseId, in: path, required: true, schema: { type: string, pattern: \"^app[A-Za-z0-9]{14}$\" } }\n              responses:\n                \"200\":\n                  description: The base schema.\n                  content:\n                    application/json:\n                      schema:\n                        type: object\n                        properties:\n                          tables:\n                            type: array\n                            items:\n                              type: object\n                              properties:\n                                id: { type: string }\n                                name: { type: string }\n                                fields:\n                                  type: array\n                                  items: { type: object, properties: { id: { type: string }, name: { type: string }, type: { type: string } } }\n          /v0/{baseId}/{tableIdOrName}:\n            get:\n              operationId: listRecords\n              summary: >\n                Up to 100 records of a table, each with its id and the requested\n                fields that are filled in. Airtable leaves empty fields out of a\n                record. offset is present when the table has more records.\n              security: [{ token: [] }]\n              parameters:\n                - { name: baseId, in: path, required: true, schema: { type: string, pattern: \"^app[A-Za-z0-9]{14}$\" } }\n                - { name: tableIdOrName, in: path, required: true, schema: { type: string, minLength: 1 } }\n                - name: \"fields[]\"\n                  in: query\n                  required: true\n                  description: The field names to return.\n                  schema: { type: array, minItems: 1, items: { type: string } }\n                - { name: pageSize, in: query, required: true, schema: { type: integer, enum: [100] } }\n              responses:\n                \"200\":\n                  description: One page of records.\n                  content:\n                    application/json:\n                      schema:\n                        type: object\n                        properties:\n                          records:\n                            type: array\n                            items: { type: object, properties: { id: { type: string }, createdTime: { type: string }, fields: { type: object } } }\n                          offset: { type: string }\n        components:\n          securitySchemes:\n            token: { type: http, scheme: bearer }\n    credential: airtable\n    exposes: [getBaseSchema, listRecords]\n\nsteps:\n  - id: schema\n    do:\n      calls:\n        - { id: schema, operation: getBaseSchema, arguments: { baseId: { var: inputs.base_id } } }\n      output:\n        # The table named by the input, matched first by name and then by id.\n        table:\n          if:\n            - &by-name { get: [{ get: [{ join: [[{ object: [[key, { var: inputs.table }]] }], { var: responses.schema.tables }, key, name] }, 0] }, right] }\n            - { object: [[id, { get: [*by-name, id] }], [name, { get: [*by-name, name] }], [fields, { map: [{ get: [*by-name, fields] }, { var: name }] }]] }\n            - &by-id { get: [{ get: [{ join: [[{ object: [[key, { var: inputs.table }]] }], { var: responses.schema.tables }, key, id] }, 0] }, right] }\n            - { object: [[id, { get: [*by-id, id] }], [name, { get: [*by-id, name] }], [fields, { map: [{ get: [*by-id, fields] }, { var: name }] }]] }\n            - null\n    produces:\n      type: object\n      required: [table]\n      properties:\n        table:\n          oneOf:\n            - type: \"null\"\n            - type: object\n              required: [id, name, fields]\n              additionalProperties: false\n              properties:\n                id: { type: string, pattern: \"^tbl[A-Za-z0-9]{14}$\" }\n                name: { type: string }\n                fields: { type: array, items: { type: string } }\n    gates:\n      - id: table-exists\n        message: The base has no table whose name or id is the table input.\n        predicate: { \"!=\": [{ var: output.table }, null] }\n      - id: some-field-exists\n        message: The table has none of the requested fields, so there is nothing to audit.\n        predicate: { \">\": [{ length: { difference: [{ var: inputs.required_fields }, { difference: [{ var: inputs.required_fields }, { var: output.table.fields }] }] } }, 0] }\n\n  - id: records\n    do:\n      calls:\n        - id: records\n          operation: listRecords\n          arguments:\n            baseId: { var: inputs.base_id }\n            tableIdOrName: { var: steps.schema.table.id }\n            \"fields[]\": &checked { difference: [{ var: inputs.required_fields }, { difference: [{ var: inputs.required_fields }, { var: steps.schema.table.fields }] }] }\n      output:\n        checked: *checked\n        missing_fields: { difference: [{ var: inputs.required_fields }, { var: steps.schema.table.fields }] }\n        # map cannot see checked, so the reduce carries it in its accumulator. Airtable leaves empty fields out.\n        records:\n          get:\n            - reduce:\n                - { var: responses.records.records }\n                - object:\n                    - [checked, { var: accumulator.checked }]\n                    - - rows\n                      - merge:\n                          - { var: accumulator.rows }\n                          - [{ object: [[id, { var: current.id }], [empty, { difference: [{ var: accumulator.checked }, { keys: { var: current.fields } }] }]] }]\n                - { object: [[checked, *checked], [rows, []]] }\n            - rows\n        more_records: { \"!!\": { var: responses.records.offset } }\n    produces:\n      type: object\n      required: [checked, missing_fields, records, more_records]\n      properties:\n        checked: { type: array, items: { type: string } }\n        missing_fields: { type: array, items: { type: string } }\n        records:\n          type: array\n          maxItems: 100\n          items:\n            type: object\n            required: [id, empty]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^rec[A-Za-z0-9]{14}$\" }\n              empty: { type: array, items: { type: string } }\n        more_records: { type: boolean }\n\n  - id: report\n    instructions: |\n      The table {{step",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "event-weather-contingency"
              },
              "reply": "# event-weather-contingency.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: event-weather-contingency\ntitle: Weather go, contingency or postpone call for an outdoor event\ndescription: >\n  Finds the event location with Open-Meteo geocoding, fetches the daily\n  forecast for the event date, applies fixed go, contingency and postpone\n  thresholds, and writes a contingency plan that quotes the forecast it rests on.\n\ninputs:\n  type: object\n  required: [place, country_code, date]\n  properties:\n    place: { type: string, minLength: 2, description: \"Town or city name, for example Edinburgh\" }\n    country_code: { type: string, pattern: \"^[A-Z]{2}$\", description: \"ISO 3166-1 alpha-2 country code of the place, for example GB\" }\n    date: { type: string, pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\", description: \"Event date in the place's local time, YYYY-MM-DD, at most 15 days ahead\" }\n\ntools:\n  geocoding:\n    openapi:\n      server: https://geocoding-api.open-meteo.com/v1\n      document:\n        openapi: 3.1.0\n        info: { title: Open-Meteo Geocoding API (trimmed), version: \"1\" }\n        paths:\n          /search:\n            get:\n              operationId: searchPlace\n              summary: Search places by name. Returns up to count matches with id, name, latitude, longitude, country_code, country and admin1.\n              parameters:\n                - { name: name, in: query, required: true, schema: { type: string, minLength: 2 } }\n                - { name: count, in: query, schema: { type: integer, minimum: 1, maximum: 10 } }\n                - { name: language, in: query, schema: { type: string, enum: [en] } }\n                - { name: countryCode, in: query, schema: { type: string, pattern: \"^[A-Z]{2}$\" } }\n    exposes: [searchPlace]\n  forecast:\n    openapi:\n      server: https://api.open-meteo.com/v1\n      document:\n        openapi: 3.1.0\n        info: { title: Open-Meteo Forecast API (trimmed), version: \"1\" }\n        paths:\n          /forecast:\n            get:\n              operationId: getForecast\n              summary: Daily forecast for one point. Values come back as parallel arrays under daily, one entry per date in daily.time; units are °C, mm, % and km/h.\n              parameters:\n                - { name: latitude, in: query, required: true, schema: { type: number, minimum: -90, maximum: 90 } }\n                - { name: longitude, in: query, required: true, schema: { type: number, minimum: -180, maximum: 180 } }\n                - name: daily\n                  in: query\n                  required: true\n                  schema:\n                    type: string\n                    enum: [\"weather_code,temperature_2m_max,temperature_2m_min,precipitation_sum,precipitation_probability_max,wind_speed_10m_max,wind_gusts_10m_max\"]\n                - { name: timezone, in: query, required: true, schema: { type: string, enum: [auto] } }\n                - { name: start_date, in: query, required: true, schema: { type: string, pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\" } }\n                - { name: end_date, in: query, required: true, schema: { type: string, pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\" } }\n    exposes: [getForecast]\n\nsteps:\n  # The geocoder's first match in the input country is taken as the place.\n  - id: locate\n    do:\n      calls:\n        - id: search\n          operation: searchPlace\n          arguments: { name: { var: inputs.place }, count: 5, language: en, countryCode: { var: inputs.country_code } }\n      output:\n        geocoding_id: { var: responses.search.results.0.id }\n        name: { var: responses.search.results.0.name }\n        latitude: { var: responses.search.results.0.latitude }\n        longitude: { var: responses.search.results.0.longitude }\n        country_code: { var: responses.search.results.0.country_code }\n        country: { var: responses.search.results.0.country }\n        admin1: { var: responses.search.results.0.admin1 }\n    produces:\n      type: object\n      required: [geocoding_id, name, latitude, longitude, country_code, country, admin1]\n      properties:\n        geocoding_id: { type: integer }\n        name: { type: string }\n        latitude: { type: number }\n        longitude: { type: number }\n        country_code: { type: string }\n        country: { type: [string, \"null\"] }\n        admin1: { type: [string, \"null\"] }\n    gates:\n      - id: country-respected\n        message: The geocoder's first match must be in the input country_code.\n        predicate:\n          \"==\": [{ var: output.country_code }, { var: inputs.country_code }]\n\n  - id: forecast\n    do:\n      calls:\n        - id: daily\n          operation: getForecast\n          arguments:\n            latitude: { var: steps.locate.latitude }\n            longitude: { var: steps.locate.longitude }\n            start_date: { var: inputs.date }\n            end_date: { var: inputs.date }\n      output:\n        forecast_date: { var: responses.daily.daily.time.0 }\n        weather_code: { var: responses.daily.daily.weather_code.0 }\n        temperature_max_c: { var: responses.daily.daily.temperature_2m_max.0 }\n        temperature_min_c: { var: responses.daily.daily.temperature_2m_min.0 }\n        precipitation_sum_mm: { var: responses.daily.daily.precipitation_sum.0 }\n        precipitation_probability_max_pct: { var: responses.daily.daily.precipitation_probability_max.0 }\n        wind_speed_max_kmh: { var: responses.daily.daily.wind_speed_10m_max.0 }\n        wind_gusts_max_kmh: { var: responses.daily.daily.wind_gusts_10m_max.0 }\n    produces:\n      type: object\n      required: [forecast_date, weather_code, temperature_max_c, temperature_min_c, precipitation_sum_mm, precipitation_probability_max_pct, wind_speed_max_kmh, wind_gusts_max_kmh]\n      properties:\n        forecast_date: { type: string }\n        weather_code: { type: integer }\n        temperature_max_c: { type: number }\n        temperature_min_c: { type: number }\n        precipitation_sum_mm: { type: number, minimum: 0 }\n        precipitation_probability_max_pct: { type: number, minimum: 0, maximum: 100 }\n        wind_speed_max_kmh: { type: number, minimum: 0 }\n        wind_gusts_max_kmh: { type: number, minimum: 0 }\n    gates:\n      - id: date-is-event-date\n        message: The forecast returned must be for the event date from the inputs.\n        predicate:\n          \"==\": [{ var: output.forecast_date }, { var: inputs.date }]\n\n  - id: decide\n    do:\n      output:\n        triggered:\n          merge:\n            - if: [&postpone-thunderstorm { in: [{ var: steps.forecast.weather_code }, [95, 96, 99]] }, [postpone-thunderstorm], []]\n            - if: [&postpone-gusts { \">=\": [{ var: steps.forecast.wind_gusts_max_kmh }, 65] }, [postpone-gusts], []]\n            - if: [&postpone-heavy-rain { \">=\": [{ var: steps.forecast.precipitation_sum_mm }, 15] }, [postpone-heavy-rain], []]\n            - if: [&postpone-extreme-heat { \">=\": [{ var: steps.forecast.temperature_max_c }, 38] }, [postpone-extreme-heat], []]\n            - if: [&contingency-rain-chance { \">=\": [{ var: steps.forecast.precipitation_probability_max_pct }, 40] }, [contingency-rain-chance], []]\n            - if: [&contingency-rain { \">=\": [{ var: steps.forecast.precipitation_sum_mm }, 2] }, [contingency-rain], []]\n            - if: [&contingency-gusts { \">=\": [{ var: steps.forecast.wind_gusts_max_kmh }, 40] }, [contingency-gusts], []]\n            - if: [&contingency-wind { \">=\": [{ var: steps.forecast.wind_speed_max_kmh }, 30] }, [contingency-wind], []]\n            - if: [&contingency-heat { \">=\": [{ var: steps.forecast.temperature_max_c }, 32] }, [contingency-heat], []]\n            - if: [&contingency-cold { \"<=\": [{ var: steps.forecast.temperature_min_c }, 5] }, [contingency-cold], []]\n        decision:\n          if:\n            - or: [*postpone-thunderstorm, *postpone-gusts, *postpone-heavy-rain, *postpone-extreme-heat]\n            - postpone\n            - or: [*contingency-rain-chance, *contingency-rain, *cont",
              "tool": "stepgate_examples"
            }
          ],
          "task": "List the available stepfile examples, then show the YAML and README for one example from the list."
        },
        "type": "noul"
      },
      "w01": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "## Available stepfile examples\n\nThe catalog lists 18 examples:\n\n- `airtable-field-completeness` — audit required fields in an Airtable table.\n- `snowflake-metric-to-jira` — check a Snowflake metric and, with approval, create a Jira issue.\n- `dependency-upgrade-risk` — check npm package versions and OSV advisories.\n- `servicenow-incident-review` — review GitHub changes around a ServiceNow incident.\n- `sec-10k-ratio-extraction` — extract SEC filing figures and calculate ratios.\n- `drug-shortage-watch` — check a formulary against FDA shortage records.\n- `auto-claim-vin-validation` — validate a claim’s vehicle details and list recalls.\n- `regulatory-change-monitor` — brief Federal Register rules for a topic or agency.\n- `github-release-to-customers` — prepare customer-facing release notes and a Gmail draft.\n- `market-research` — research a brand’s market position using web sources.\n- `book-list-verification` — check reading-list titles and authors against Open Library.\n- `meeting-scheduler` — find free slots and draft an invitation email.\n- `disaster-declaration-brief` — summarize FEMA disaster declarations.\n- `reference-list-validation` — validate references against Crossref DOI records.\n- `hubspot-deal-to-monday` — prepare monday.com items from a closed-won HubSpot deal.\n- `cve-triage-prioritisation` — prioritize CVEs using NVD and EPSS data.\n- `zendesk-jira-escalation` — identify ticket escalations and prepare Jira links or issues.\n- `event-weather-contingency` — apply weather thresholds and prepare a contingency plan.\n\n## Example: `book-list-verification`\n\nI requested this example’s YAML and README, but the tool returned a **truncated response**: it stopped partway through the YAML and did not include the README. I therefore can’t show the complete files from the result available to me.\n\nThe beginning of the YAML was:\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading ",
          "done_when": "The tool replies show the example catalog and the YAML and README for one listed example.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {},
              "reply": "18 catalog stepfiles. Call stepgate_examples with a name to read one.\n\n- airtable-field-completeness (data; keys: airtable): Reads up to 100 records of one Airtable table and reports, record by record, which of the fields you name are empty. Read-only.\n- snowflake-metric-to-jira (data; keys: snowflake, jira): Runs one fixed, read-only SELECT you supply against Snowflake through the SQL API once a person approves it, checks the metric it returns against your threshold, and only when the threshold is breached, and a person approves the draft, creates a Jira issue labelled stepgate-draft that quotes the exact values returned and the exact SQL.\n- dependency-upgrade-risk (engineering; no keys): Checks each npm package and pinned version against the npm registry and OSV.dev, and recommends an upgrade only where the registry's latest release is published and OSV lists no advisory against it.\n- servicenow-incident-review (engineering; keys: servicenow, github): Reads a ServiceNow incident, lists the GitHub commits and merged pull requests on one branch in the hours before it opened, builds a timeline and a list of suspect changes that cite real commit SHAs and pull request numbers, and adds the review to the incident as an internal work note once a person approves it.\n- sec-10k-ratio-extraction (finance; no keys): Resolves a US-listed ticker to its SEC CIK, pulls revenue, net income, total assets, total liabilities, equity and operating cash flow from the XBRL facts of its latest annual 10-K, and computes ratios that gates recompute from the SEC figures.\n- drug-shortage-watch (health; no keys): Checks each generic drug on a formulary against the current openFDA drug shortage list and returns an action list in which every status and NDC comes from an FDA record.\n- auto-claim-vin-validation (insurance; no keys): Decodes an auto claim's VIN with NHTSA vPIC, compares the claimed make, model and year against the decode, lists the vehicle's NHTSA recalls, and returns a consistent-or-refer verdict whose every value comes from those APIs.\n- regulatory-change-monitor (legal; no keys): Finds the final and proposed rules the Federal Register published for a topic or agency in a date range, and briefs which ones matter, citing document numbers and effective or comment-close dates taken from the API.\n- github-release-to-customers (marketing; keys: github, hubspot, gmail): Collects the pull requests merged between two GitHub releases, writes customer-facing release notes that cite them by number, finds the HubSpot contacts matching a property filter, and creates a Gmail draft to the operator with the notes and the recipient list. Creates a draft; never sends.\n- market-research (marketing; keys: tavily): Researches a brand's market position from web sources, discards what is irrelevant on the record, and writes a report in which every claim cites a source that survived the filter.\n- book-list-verification (media; no keys): Confirms that every book on a reading list exists in Open Library under the stated author, and flags books that do not exist or belong to someone else.\n- meeting-scheduler (productivity; keys: google-calendar, gmail): Queries Google Calendar free/busy for every attendee over a date range, proposes up to three slots inside working hours that Google confirms are free for everyone, and creates a Gmail draft of the invite email. Creates no calendar event and never sends.\n- disaster-declaration-brief (public; no keys): Lists every federal disaster declaration OpenFEMA records for a US state and date range, summarises them by incident type and assistance program, and writes a brief that cites each declaration by its FEMA disaster number.\n- reference-list-validation (research; no keys): Resolves every reference in a list to a real Crossref DOI record and flags references that are fabricated, carry the wrong DOI, or misstate the author or year.\n- hubspot-deal-to-monday (sales; keys: hubspot, monday): Reads a HubSpot deal, refuses it unless its stage is closed won, reads its line items, contacts and companies, plans one monday.com item per line item, and, once a person approves the plan, creates them as drafts in a new \"Stepgate draft\" group on a given board, each with an update carrying the deal, company and contact details.\n- cve-triage-prioritisation (security; no keys): Ranks up to five CVE ids into priorities 1 to 4 from their NVD CVSS score, CISA Known Exploited Vulnerabilities status as NVD records it, and FIRST EPSS probability, by a fixed published rule.\n- zendesk-jira-escalation (support; keys: zendesk, jira): Finds open Zendesk tickets matching an escalation rule (a priority and a tag), searches a Jira project for unresolved issues already tracking each problem, decides per ticket to link to one of them or create a Jira issue labelled stepgate-draft, and, once a person approves, creates those issues and adds an internal note naming the Jira key to every ticket. It never posts a public reply.\n- event-weather-contingency (travel; no keys): Finds the event location with Open-Meteo geocoding, fetches the daily forecast for the event date, applies fixed go, contingency and postpone thresholds, and writes a contingency plan that quotes the forecast it rests on.",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "book-list-verification"
              },
              "reply": "# book-list-verification.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading list against Open Library\ndescription: >\n  Confirms that every book on a reading list exists in Open Library under the\n  stated author, and flags books that do not exist or belong to someone else.\n\ninputs:\n  type: object\n  required: [books]\n  properties:\n    books:\n      type: array\n      description: The books to check, each with its title and the author the list names.\n      minItems: 1\n      maxItems: 30\n      items:\n        type: object\n        required: [title, author]\n        additionalProperties: false\n        properties:\n          title: { type: string, minLength: 1 }\n          author: { type: string, minLength: 1 }\n\ntools:\n  # Two tools over one endpoint so gates can tell a search filtered by the\n  # stated author, which is the attribution check, from a title-only search.\n  openlibrary-by-author:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title and author, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitleAndAuthor\n              summary: >\n                Search Open Library works matching both a title and an author\n                name. docs is empty when no work matches both.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: author\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitleAndAuthor]\n  openlibrary-by-title:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitle\n              summary: Search Open Library works by title alone, whoever wrote them.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitle]\n\nsteps:\n  - id: search\n    tools: [searchByTitleAndAuthor]\n    instructions: |\n      Here is a reading list:\n\n      {{inputs.books}}\n\n      Number the books B-01, B-02 and so on, in the order given. For every\n      book, call searchByTitleAndAuthor once, with title and author copied\n      exactly as given and limit 5. Make one call at a time.\n\n      For each book submit its id, title and author unchanged, and match: the\n      returned doc that is this book, as { key, title, author_name } copied\n      exactly (author_name is null if the doc has none). It is the same\n      title, allowing for case, punctuation and a subtitle. A doc with a\n      different title by the same author is not a match, nor is an omnibus or\n      box set. If no doc is this book, set match to null.\n    produces:\n      type: object\n      required: [books]\n      properties:\n        books:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, match]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^B-[0-9]{2,}$\" }\n              title: { type: string }\n              author: { type: string }\n              match: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      books: { map: [{ var: output.books }, { object: [[book, [{ var: title }, { var: author }]], [match, { var: match }]] }] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\": [{ var: tool }, searchByTitleAndAuthor] }, { \"!\": { var: is_error } }] }]\n          - object:\n              - [book, [{ var: arguments.title }, { var: arguments.author }]]\n              - [docs, { map: [{ var: result.docs }, &doc { object: [[key, { var: key }], [title, { var: title }], [author_name, { var: author_name }]] }] }]\n    gates:\n      - id: every-book-once\n        message: Submit every input book exactly once, with title and author unchanged and a unique id.\n        predicate:\n          and:\n            - \"==\":\n                - { length: { var: output.books } }\n                - { length: { var: inputs.books } }\n            - \"==\":\n                - { length: { unique: { map: [{ var: output.books }, { var: id }] } } }\n                - { length: { var: output.books } }\n            - subset:\n                - map: [{ var: inputs.books }, [{ var: title }, { var: author }]]\n                - map: [{ var: output.books }, [{ var: title }, { var: author }]]\n      - id: match-from-own-search\n        message: >\n          Every book needs a successful searchByTitleAndAuthor call with its\n          exact title and author, and match must be null or one of that call's\n          docs, copied exactly. These books break it:\n        predicate:\n          none:\n            - join: [{ var: let.books }, { var: let.searched }, book, book]\n            - or:\n                - \"==\": [{ var: right }, null]\n                - and: [{ var: left.match }, { \"!\": { subset: [[{ var: left.match }], { var: right.docs }] } }]\n    retries: 2\n\n  - id: crosscheck\n    tools: [searchByTitle]\n    instructions: |\n      These books were searched under their stated author:\n\n      {{steps.search.books}}\n\n      For every book whose match is null, and only those, call searchByTitle\n      with the title copied exactly and limit 5, to learn whether the book\n      exists under a different author. If every book has a match, make no\n      calls and submit an empty checks list.\n\n      For each book checked submit its id, title and author unchanged, and\n      found: the returned doc that is this book (same title, allowing for\n      case, punctuation and a subtitle), as { key, title, author_name } copied\n      exactly, or null if none is. A found doc must not list the stated\n      author, since that search already failed.\n    produces:\n      type: object\n      required: [checks]\n      properties:\n        checks:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, found]\n            additionalProperties: false\n            properties:\n              id: { type: string }\n              title: { type: string }\n              author: { type: string }\n              found: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      unmatched: { map: [{ filter: [{ var: steps.search.books }, { \"!\": { var: match } }] }, [{ var: id }, { var: title }, { var: author }]] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\":",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "airtable-field-completeness"
              },
              "reply": "# airtable-field-completeness.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: airtable-field-completeness\ntitle: Audit an Airtable table for empty required fields\ndescription: >\n  Reads up to 100 records of one Airtable table and reports, record by record,\n  which of the fields you name are empty. Read-only.\n\ninputs:\n  type: object\n  required: [base_id, table, required_fields]\n  properties:\n    base_id:\n      type: string\n      description: The base's id, the app... part of its URL.\n      pattern: \"^app[A-Za-z0-9]{14}$\"\n    table:\n      type: string\n      description: The table's name or its tbl... id.\n      minLength: 1\n    required_fields:\n      type: array\n      description: The field names every record should fill in.\n      minItems: 1\n      maxItems: 10\n      uniqueItems: true\n      items: { type: string, minLength: 1 }\n\ncredentials:\n  airtable:\n    kind: bearer\n    hosts: [api.airtable.com]\n    description: >\n      An Airtable personal access token with the data.records:read and\n      schema.bases:read scopes on the base to audit. Nothing is written.\n\ntools:\n  airtable:\n    openapi:\n      server: https://api.airtable.com\n      document:\n        openapi: 3.1.0\n        info: { title: Airtable Web API, reads only, version: \"0\" }\n        paths:\n          /v0/meta/bases/{baseId}/tables:\n            get:\n              operationId: getBaseSchema\n              summary: >\n                The base's tables, each with its id, name and fields (id, name\n                and type).\n              security: [{ token: [] }]\n              parameters:\n                - { name: baseId, in: path, required: true, schema: { type: string, pattern: \"^app[A-Za-z0-9]{14}$\" } }\n              responses:\n                \"200\":\n                  description: The base schema.\n                  content:\n                    application/json:\n                      schema:\n                        type: object\n                        properties:\n                          tables:\n                            type: array\n                            items:\n                              type: object\n                              properties:\n                                id: { type: string }\n                                name: { type: string }\n                                fields:\n                                  type: array\n                                  items: { type: object, properties: { id: { type: string }, name: { type: string }, type: { type: string } } }\n          /v0/{baseId}/{tableIdOrName}:\n            get:\n              operationId: listRecords\n              summary: >\n                Up to 100 records of a table, each with its id and the requested\n                fields that are filled in. Airtable leaves empty fields out of a\n                record. offset is present when the table has more records.\n              security: [{ token: [] }]\n              parameters:\n                - { name: baseId, in: path, required: true, schema: { type: string, pattern: \"^app[A-Za-z0-9]{14}$\" } }\n                - { name: tableIdOrName, in: path, required: true, schema: { type: string, minLength: 1 } }\n                - name: \"fields[]\"\n                  in: query\n                  required: true\n                  description: The field names to return.\n                  schema: { type: array, minItems: 1, items: { type: string } }\n                - { name: pageSize, in: query, required: true, schema: { type: integer, enum: [100] } }\n              responses:\n                \"200\":\n                  description: One page of records.\n                  content:\n                    application/json:\n                      schema:\n                        type: object\n                        properties:\n                          records:\n                            type: array\n                            items: { type: object, properties: { id: { type: string }, createdTime: { type: string }, fields: { type: object } } }\n                          offset: { type: string }\n        components:\n          securitySchemes:\n            token: { type: http, scheme: bearer }\n    credential: airtable\n    exposes: [getBaseSchema, listRecords]\n\nsteps:\n  - id: schema\n    do:\n      calls:\n        - { id: schema, operation: getBaseSchema, arguments: { baseId: { var: inputs.base_id } } }\n      output:\n        # The table named by the input, matched first by name and then by id.\n        table:\n          if:\n            - &by-name { get: [{ get: [{ join: [[{ object: [[key, { var: inputs.table }]] }], { var: responses.schema.tables }, key, name] }, 0] }, right] }\n            - { object: [[id, { get: [*by-name, id] }], [name, { get: [*by-name, name] }], [fields, { map: [{ get: [*by-name, fields] }, { var: name }] }]] }\n            - &by-id { get: [{ get: [{ join: [[{ object: [[key, { var: inputs.table }]] }], { var: responses.schema.tables }, key, id] }, 0] }, right] }\n            - { object: [[id, { get: [*by-id, id] }], [name, { get: [*by-id, name] }], [fields, { map: [{ get: [*by-id, fields] }, { var: name }] }]] }\n            - null\n    produces:\n      type: object\n      required: [table]\n      properties:\n        table:\n          oneOf:\n            - type: \"null\"\n            - type: object\n              required: [id, name, fields]\n              additionalProperties: false\n              properties:\n                id: { type: string, pattern: \"^tbl[A-Za-z0-9]{14}$\" }\n                name: { type: string }\n                fields: { type: array, items: { type: string } }\n    gates:\n      - id: table-exists\n        message: The base has no table whose name or id is the table input.\n        predicate: { \"!=\": [{ var: output.table }, null] }\n      - id: some-field-exists\n        message: The table has none of the requested fields, so there is nothing to audit.\n        predicate: { \">\": [{ length: { difference: [{ var: inputs.required_fields }, { difference: [{ var: inputs.required_fields }, { var: output.table.fields }] }] } }, 0] }\n\n  - id: records\n    do:\n      calls:\n        - id: records\n          operation: listRecords\n          arguments:\n            baseId: { var: inputs.base_id }\n            tableIdOrName: { var: steps.schema.table.id }\n            \"fields[]\": &checked { difference: [{ var: inputs.required_fields }, { difference: [{ var: inputs.required_fields }, { var: steps.schema.table.fields }] }] }\n      output:\n        checked: *checked\n        missing_fields: { difference: [{ var: inputs.required_fields }, { var: steps.schema.table.fields }] }\n        # map cannot see checked, so the reduce carries it in its accumulator. Airtable leaves empty fields out.\n        records:\n          get:\n            - reduce:\n                - { var: responses.records.records }\n                - object:\n                    - [checked, { var: accumulator.checked }]\n                    - - rows\n                      - merge:\n                          - { var: accumulator.rows }\n                          - [{ object: [[id, { var: current.id }], [empty, { difference: [{ var: accumulator.checked }, { keys: { var: current.fields } }] }]] }]\n                - { object: [[checked, *checked], [rows, []]] }\n            - rows\n        more_records: { \"!!\": { var: responses.records.offset } }\n    produces:\n      type: object\n      required: [checked, missing_fields, records, more_records]\n      properties:\n        checked: { type: array, items: { type: string } }\n        missing_fields: { type: array, items: { type: string } }\n        records:\n          type: array\n          maxItems: 100\n          items:\n            type: object\n            required: [id, empty]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^rec[A-Za-z0-9]{14}$\" }\n              empty: { type: array, items: { type: string } }\n        more_records: { type: boolean }\n\n  - id: report\n    instructions: |\n      The table {{step",
              "tool": "stepgate_examples"
            }
          ],
          "task": "List the available stepfile examples, then show the YAML and README for one example from the list."
        },
        "type": "noul"
      },
      "w02": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "## Available stepfile examples\n\nThe catalog returned 18 examples:\n\n| Example | Category | Credentials |\n|---|---|---|\n| `airtable-field-completeness` | Data | Airtable |\n| `snowflake-metric-to-jira` | Data | Snowflake, Jira |\n| `dependency-upgrade-risk` | Engineering | None |\n| `servicenow-incident-review` | Engineering | ServiceNow, GitHub |\n| `sec-10k-ratio-extraction` | Finance | None |\n| `drug-shortage-watch` | Health | None |\n| `auto-claim-vin-validation` | Insurance | None |\n| `regulatory-change-monitor` | Legal | None |\n| `github-release-to-customers` | Marketing | GitHub, HubSpot, Gmail |\n| `market-research` | Marketing | Tavily |\n| `book-list-verification` | Media | None |\n| `meeting-scheduler` | Productivity | Google Calendar, Gmail |\n| `disaster-declaration-brief` | Public | None |\n| `reference-list-validation` | Research | None |\n| `hubspot-deal-to-monday` | Sales | HubSpot, monday.com |\n| `cve-triage-prioritisation` | Security | None |\n| `zendesk-jira-escalation` | Support | Zendesk, Jira |\n| `event-weather-contingency` | Travel | None |\n\n## Example: `book-list-verification`\n\nI requested this example’s YAML and README. **The tool response was truncated partway through the YAML, before the README**, so I can’t show either document in full. Here is the beginning of the YAML that was returned:\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading list against Open Library\ndescription: >\n  Confirms that every book on a reading list exists in Open Library under the\n  stated author, and flags books that do not exist or belong to someone else.\n\ninputs:\n  type: object\n  required: [books]\n  properties:\n    books:\n      type: array\n      description: The books to check, each with its title and the author the list names.\n      minItems: 1\n      maxItems: 30\n      items:\n        type: object\n        required: [title, author]\n        additionalProperties: false\n        pr",
          "done_when": "The tool replies show the example catalog and the YAML and README for one listed example.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {},
              "reply": "18 catalog stepfiles. Call stepgate_examples with a name to read one.\n\n- airtable-field-completeness (data; keys: airtable): Reads up to 100 records of one Airtable table and reports, record by record, which of the fields you name are empty. Read-only.\n- snowflake-metric-to-jira (data; keys: snowflake, jira): Runs one fixed, read-only SELECT you supply against Snowflake through the SQL API once a person approves it, checks the metric it returns against your threshold, and only when the threshold is breached, and a person approves the draft, creates a Jira issue labelled stepgate-draft that quotes the exact values returned and the exact SQL.\n- dependency-upgrade-risk (engineering; no keys): Checks each npm package and pinned version against the npm registry and OSV.dev, and recommends an upgrade only where the registry's latest release is published and OSV lists no advisory against it.\n- servicenow-incident-review (engineering; keys: servicenow, github): Reads a ServiceNow incident, lists the GitHub commits and merged pull requests on one branch in the hours before it opened, builds a timeline and a list of suspect changes that cite real commit SHAs and pull request numbers, and adds the review to the incident as an internal work note once a person approves it.\n- sec-10k-ratio-extraction (finance; no keys): Resolves a US-listed ticker to its SEC CIK, pulls revenue, net income, total assets, total liabilities, equity and operating cash flow from the XBRL facts of its latest annual 10-K, and computes ratios that gates recompute from the SEC figures.\n- drug-shortage-watch (health; no keys): Checks each generic drug on a formulary against the current openFDA drug shortage list and returns an action list in which every status and NDC comes from an FDA record.\n- auto-claim-vin-validation (insurance; no keys): Decodes an auto claim's VIN with NHTSA vPIC, compares the claimed make, model and year against the decode, lists the vehicle's NHTSA recalls, and returns a consistent-or-refer verdict whose every value comes from those APIs.\n- regulatory-change-monitor (legal; no keys): Finds the final and proposed rules the Federal Register published for a topic or agency in a date range, and briefs which ones matter, citing document numbers and effective or comment-close dates taken from the API.\n- github-release-to-customers (marketing; keys: github, hubspot, gmail): Collects the pull requests merged between two GitHub releases, writes customer-facing release notes that cite them by number, finds the HubSpot contacts matching a property filter, and creates a Gmail draft to the operator with the notes and the recipient list. Creates a draft; never sends.\n- market-research (marketing; keys: tavily): Researches a brand's market position from web sources, discards what is irrelevant on the record, and writes a report in which every claim cites a source that survived the filter.\n- book-list-verification (media; no keys): Confirms that every book on a reading list exists in Open Library under the stated author, and flags books that do not exist or belong to someone else.\n- meeting-scheduler (productivity; keys: google-calendar, gmail): Queries Google Calendar free/busy for every attendee over a date range, proposes up to three slots inside working hours that Google confirms are free for everyone, and creates a Gmail draft of the invite email. Creates no calendar event and never sends.\n- disaster-declaration-brief (public; no keys): Lists every federal disaster declaration OpenFEMA records for a US state and date range, summarises them by incident type and assistance program, and writes a brief that cites each declaration by its FEMA disaster number.\n- reference-list-validation (research; no keys): Resolves every reference in a list to a real Crossref DOI record and flags references that are fabricated, carry the wrong DOI, or misstate the author or year.\n- hubspot-deal-to-monday (sales; keys: hubspot, monday): Reads a HubSpot deal, refuses it unless its stage is closed won, reads its line items, contacts and companies, plans one monday.com item per line item, and, once a person approves the plan, creates them as drafts in a new \"Stepgate draft\" group on a given board, each with an update carrying the deal, company and contact details.\n- cve-triage-prioritisation (security; no keys): Ranks up to five CVE ids into priorities 1 to 4 from their NVD CVSS score, CISA Known Exploited Vulnerabilities status as NVD records it, and FIRST EPSS probability, by a fixed published rule.\n- zendesk-jira-escalation (support; keys: zendesk, jira): Finds open Zendesk tickets matching an escalation rule (a priority and a tag), searches a Jira project for unresolved issues already tracking each problem, decides per ticket to link to one of them or create a Jira issue labelled stepgate-draft, and, once a person approves, creates those issues and adds an internal note naming the Jira key to every ticket. It never posts a public reply.\n- event-weather-contingency (travel; no keys): Finds the event location with Open-Meteo geocoding, fetches the daily forecast for the event date, applies fixed go, contingency and postpone thresholds, and writes a contingency plan that quotes the forecast it rests on.",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "book-list-verification"
              },
              "reply": "# book-list-verification.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading list against Open Library\ndescription: >\n  Confirms that every book on a reading list exists in Open Library under the\n  stated author, and flags books that do not exist or belong to someone else.\n\ninputs:\n  type: object\n  required: [books]\n  properties:\n    books:\n      type: array\n      description: The books to check, each with its title and the author the list names.\n      minItems: 1\n      maxItems: 30\n      items:\n        type: object\n        required: [title, author]\n        additionalProperties: false\n        properties:\n          title: { type: string, minLength: 1 }\n          author: { type: string, minLength: 1 }\n\ntools:\n  # Two tools over one endpoint so gates can tell a search filtered by the\n  # stated author, which is the attribution check, from a title-only search.\n  openlibrary-by-author:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title and author, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitleAndAuthor\n              summary: >\n                Search Open Library works matching both a title and an author\n                name. docs is empty when no work matches both.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: author\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitleAndAuthor]\n  openlibrary-by-title:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitle\n              summary: Search Open Library works by title alone, whoever wrote them.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitle]\n\nsteps:\n  - id: search\n    tools: [searchByTitleAndAuthor]\n    instructions: |\n      Here is a reading list:\n\n      {{inputs.books}}\n\n      Number the books B-01, B-02 and so on, in the order given. For every\n      book, call searchByTitleAndAuthor once, with title and author copied\n      exactly as given and limit 5. Make one call at a time.\n\n      For each book submit its id, title and author unchanged, and match: the\n      returned doc that is this book, as { key, title, author_name } copied\n      exactly (author_name is null if the doc has none). It is the same\n      title, allowing for case, punctuation and a subtitle. A doc with a\n      different title by the same author is not a match, nor is an omnibus or\n      box set. If no doc is this book, set match to null.\n    produces:\n      type: object\n      required: [books]\n      properties:\n        books:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, match]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^B-[0-9]{2,}$\" }\n              title: { type: string }\n              author: { type: string }\n              match: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      books: { map: [{ var: output.books }, { object: [[book, [{ var: title }, { var: author }]], [match, { var: match }]] }] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\": [{ var: tool }, searchByTitleAndAuthor] }, { \"!\": { var: is_error } }] }]\n          - object:\n              - [book, [{ var: arguments.title }, { var: arguments.author }]]\n              - [docs, { map: [{ var: result.docs }, &doc { object: [[key, { var: key }], [title, { var: title }], [author_name, { var: author_name }]] }] }]\n    gates:\n      - id: every-book-once\n        message: Submit every input book exactly once, with title and author unchanged and a unique id.\n        predicate:\n          and:\n            - \"==\":\n                - { length: { var: output.books } }\n                - { length: { var: inputs.books } }\n            - \"==\":\n                - { length: { unique: { map: [{ var: output.books }, { var: id }] } } }\n                - { length: { var: output.books } }\n            - subset:\n                - map: [{ var: inputs.books }, [{ var: title }, { var: author }]]\n                - map: [{ var: output.books }, [{ var: title }, { var: author }]]\n      - id: match-from-own-search\n        message: >\n          Every book needs a successful searchByTitleAndAuthor call with its\n          exact title and author, and match must be null or one of that call's\n          docs, copied exactly. These books break it:\n        predicate:\n          none:\n            - join: [{ var: let.books }, { var: let.searched }, book, book]\n            - or:\n                - \"==\": [{ var: right }, null]\n                - and: [{ var: left.match }, { \"!\": { subset: [[{ var: left.match }], { var: right.docs }] } }]\n    retries: 2\n\n  - id: crosscheck\n    tools: [searchByTitle]\n    instructions: |\n      These books were searched under their stated author:\n\n      {{steps.search.books}}\n\n      For every book whose match is null, and only those, call searchByTitle\n      with the title copied exactly and limit 5, to learn whether the book\n      exists under a different author. If every book has a match, make no\n      calls and submit an empty checks list.\n\n      For each book checked submit its id, title and author unchanged, and\n      found: the returned doc that is this book (same title, allowing for\n      case, punctuation and a subtitle), as { key, title, author_name } copied\n      exactly, or null if none is. A found doc must not list the stated\n      author, since that search already failed.\n    produces:\n      type: object\n      required: [checks]\n      properties:\n        checks:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, found]\n            additionalProperties: false\n            properties:\n              id: { type: string }\n              title: { type: string }\n              author: { type: string }\n              found: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      unmatched: { map: [{ filter: [{ var: steps.search.books }, { \"!\": { var: match } }] }, [{ var: id }, { var: title }, { var: author }]] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\":",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "event-weather-contingency"
              },
              "reply": "# event-weather-contingency.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: event-weather-contingency\ntitle: Weather go, contingency or postpone call for an outdoor event\ndescription: >\n  Finds the event location with Open-Meteo geocoding, fetches the daily\n  forecast for the event date, applies fixed go, contingency and postpone\n  thresholds, and writes a contingency plan that quotes the forecast it rests on.\n\ninputs:\n  type: object\n  required: [place, country_code, date]\n  properties:\n    place: { type: string, minLength: 2, description: \"Town or city name, for example Edinburgh\" }\n    country_code: { type: string, pattern: \"^[A-Z]{2}$\", description: \"ISO 3166-1 alpha-2 country code of the place, for example GB\" }\n    date: { type: string, pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\", description: \"Event date in the place's local time, YYYY-MM-DD, at most 15 days ahead\" }\n\ntools:\n  geocoding:\n    openapi:\n      server: https://geocoding-api.open-meteo.com/v1\n      document:\n        openapi: 3.1.0\n        info: { title: Open-Meteo Geocoding API (trimmed), version: \"1\" }\n        paths:\n          /search:\n            get:\n              operationId: searchPlace\n              summary: Search places by name. Returns up to count matches with id, name, latitude, longitude, country_code, country and admin1.\n              parameters:\n                - { name: name, in: query, required: true, schema: { type: string, minLength: 2 } }\n                - { name: count, in: query, schema: { type: integer, minimum: 1, maximum: 10 } }\n                - { name: language, in: query, schema: { type: string, enum: [en] } }\n                - { name: countryCode, in: query, schema: { type: string, pattern: \"^[A-Z]{2}$\" } }\n    exposes: [searchPlace]\n  forecast:\n    openapi:\n      server: https://api.open-meteo.com/v1\n      document:\n        openapi: 3.1.0\n        info: { title: Open-Meteo Forecast API (trimmed), version: \"1\" }\n        paths:\n          /forecast:\n            get:\n              operationId: getForecast\n              summary: Daily forecast for one point. Values come back as parallel arrays under daily, one entry per date in daily.time; units are °C, mm, % and km/h.\n              parameters:\n                - { name: latitude, in: query, required: true, schema: { type: number, minimum: -90, maximum: 90 } }\n                - { name: longitude, in: query, required: true, schema: { type: number, minimum: -180, maximum: 180 } }\n                - name: daily\n                  in: query\n                  required: true\n                  schema:\n                    type: string\n                    enum: [\"weather_code,temperature_2m_max,temperature_2m_min,precipitation_sum,precipitation_probability_max,wind_speed_10m_max,wind_gusts_10m_max\"]\n                - { name: timezone, in: query, required: true, schema: { type: string, enum: [auto] } }\n                - { name: start_date, in: query, required: true, schema: { type: string, pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\" } }\n                - { name: end_date, in: query, required: true, schema: { type: string, pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\" } }\n    exposes: [getForecast]\n\nsteps:\n  # The geocoder's first match in the input country is taken as the place.\n  - id: locate\n    do:\n      calls:\n        - id: search\n          operation: searchPlace\n          arguments: { name: { var: inputs.place }, count: 5, language: en, countryCode: { var: inputs.country_code } }\n      output:\n        geocoding_id: { var: responses.search.results.0.id }\n        name: { var: responses.search.results.0.name }\n        latitude: { var: responses.search.results.0.latitude }\n        longitude: { var: responses.search.results.0.longitude }\n        country_code: { var: responses.search.results.0.country_code }\n        country: { var: responses.search.results.0.country }\n        admin1: { var: responses.search.results.0.admin1 }\n    produces:\n      type: object\n      required: [geocoding_id, name, latitude, longitude, country_code, country, admin1]\n      properties:\n        geocoding_id: { type: integer }\n        name: { type: string }\n        latitude: { type: number }\n        longitude: { type: number }\n        country_code: { type: string }\n        country: { type: [string, \"null\"] }\n        admin1: { type: [string, \"null\"] }\n    gates:\n      - id: country-respected\n        message: The geocoder's first match must be in the input country_code.\n        predicate:\n          \"==\": [{ var: output.country_code }, { var: inputs.country_code }]\n\n  - id: forecast\n    do:\n      calls:\n        - id: daily\n          operation: getForecast\n          arguments:\n            latitude: { var: steps.locate.latitude }\n            longitude: { var: steps.locate.longitude }\n            start_date: { var: inputs.date }\n            end_date: { var: inputs.date }\n      output:\n        forecast_date: { var: responses.daily.daily.time.0 }\n        weather_code: { var: responses.daily.daily.weather_code.0 }\n        temperature_max_c: { var: responses.daily.daily.temperature_2m_max.0 }\n        temperature_min_c: { var: responses.daily.daily.temperature_2m_min.0 }\n        precipitation_sum_mm: { var: responses.daily.daily.precipitation_sum.0 }\n        precipitation_probability_max_pct: { var: responses.daily.daily.precipitation_probability_max.0 }\n        wind_speed_max_kmh: { var: responses.daily.daily.wind_speed_10m_max.0 }\n        wind_gusts_max_kmh: { var: responses.daily.daily.wind_gusts_10m_max.0 }\n    produces:\n      type: object\n      required: [forecast_date, weather_code, temperature_max_c, temperature_min_c, precipitation_sum_mm, precipitation_probability_max_pct, wind_speed_max_kmh, wind_gusts_max_kmh]\n      properties:\n        forecast_date: { type: string }\n        weather_code: { type: integer }\n        temperature_max_c: { type: number }\n        temperature_min_c: { type: number }\n        precipitation_sum_mm: { type: number, minimum: 0 }\n        precipitation_probability_max_pct: { type: number, minimum: 0, maximum: 100 }\n        wind_speed_max_kmh: { type: number, minimum: 0 }\n        wind_gusts_max_kmh: { type: number, minimum: 0 }\n    gates:\n      - id: date-is-event-date\n        message: The forecast returned must be for the event date from the inputs.\n        predicate:\n          \"==\": [{ var: output.forecast_date }, { var: inputs.date }]\n\n  - id: decide\n    do:\n      output:\n        triggered:\n          merge:\n            - if: [&postpone-thunderstorm { in: [{ var: steps.forecast.weather_code }, [95, 96, 99]] }, [postpone-thunderstorm], []]\n            - if: [&postpone-gusts { \">=\": [{ var: steps.forecast.wind_gusts_max_kmh }, 65] }, [postpone-gusts], []]\n            - if: [&postpone-heavy-rain { \">=\": [{ var: steps.forecast.precipitation_sum_mm }, 15] }, [postpone-heavy-rain], []]\n            - if: [&postpone-extreme-heat { \">=\": [{ var: steps.forecast.temperature_max_c }, 38] }, [postpone-extreme-heat], []]\n            - if: [&contingency-rain-chance { \">=\": [{ var: steps.forecast.precipitation_probability_max_pct }, 40] }, [contingency-rain-chance], []]\n            - if: [&contingency-rain { \">=\": [{ var: steps.forecast.precipitation_sum_mm }, 2] }, [contingency-rain], []]\n            - if: [&contingency-gusts { \">=\": [{ var: steps.forecast.wind_gusts_max_kmh }, 40] }, [contingency-gusts], []]\n            - if: [&contingency-wind { \">=\": [{ var: steps.forecast.wind_speed_max_kmh }, 30] }, [contingency-wind], []]\n            - if: [&contingency-heat { \">=\": [{ var: steps.forecast.temperature_max_c }, 32] }, [contingency-heat], []]\n            - if: [&contingency-cold { \"<=\": [{ var: steps.forecast.temperature_min_c }, 5] }, [contingency-cold], []]\n        decision:\n          if:\n            - or: [*postpone-thunderstorm, *postpone-gusts, *postpone-heavy-rain, *postpone-extreme-heat]\n            - postpone\n            - or: [*contingency-rain-chance, *contingency-rain, *cont",
              "tool": "stepgate_examples"
            }
          ],
          "task": "List the available stepfile examples, then show the YAML and README for one example from the list."
        },
        "type": "noul"
      },
      "w03": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "I generated the skeleton and submitted it for validation.\n\n```yaml\nstepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n```\n\n**Validation did not pass:** the validator reported five remaining TODO markers:\n\n- `/inputs` — define the run’s input schema.\n- `/steps/0/produces` — define the review step’s output schema.\n- `/steps/0/gates/0` — define a review gate.\n- `/steps/1/produces` — define the publish step’s output schema.\n- `/steps/1/gates/0` — define a publish gate.\n\nThe outline also says to add the tools the steps need. The gates should reflect the SOP’s requirements, including that publishing happens only after review is complete.",
          "done_when": "The transcript shows the generated skeleton and a validation reply identifying its outstanding issues or TODO markers.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {
                "procedure": "# Release checklist\n\n## Review\nCheck that all changes have been reviewed.\n\n## Publish\nPublish the release only after review is complete."
              },
              "reply": "A skeleton stepfile for this procedure. Replace every TODO marker: declare the inputs, give each step a produces schema and gates that check its output against calls, and add the tools it needs. Then call stepgate_validate.\n\n```yaml\nstepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n```",
              "tool": "stepgate_outline"
            },
            {
              "arguments": {
                "stepfile": "stepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\""
              },
              "reply": "error: The stepfile still has parts to write. Replace every marker, then validate again:\n- /inputs: TODO(inputs): a JSON Schema object for what a run starts with\n- /steps/0/produces: TODO(produces): the JSON Schema of the output this step submits\n- /steps/0/gates/0: TODO(gate): the procedure states no rule for this step; check a real property of its output\n- /steps/1/produces: TODO(produces): the JSON Schema of the output this step submits\n- /steps/1/gates/0: TODO(gate): the procedure states no rule for this step; check a real property of its output",
              "tool": "stepgate_validate"
            }
          ],
          "task": "Turn this SOP into a skeleton stepfile, then validate the resulting skeleton and report its remaining issues: \"# Release checklist\\n\\n## Review\\nCheck that all changes have been reviewed.\\n\\n## Publish\\nPublish the release only after review is complete.\""
        },
        "type": "noul"
      },
      "w04": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "The SOP was converted into this skeleton stepfile:\n\n```yaml\nstepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n```\n\n**Validation did not pass.** The validator reported five remaining TODO markers:\n\n- `/inputs` — define the run’s input JSON Schema.\n- `/steps/0/produces` and `/steps/1/produces` — define each step’s output JSON Schema.\n- `/steps/0/gates/0` and `/steps/1/gates/0` — define checks for each step’s output.\n\nThe publish gate should enforce the SOP’s requirement that review be complete before publication. The outline also notes that the necessary tools must be added before the stepfile is runnable.",
          "done_when": "The transcript shows the generated skeleton and a validation reply identifying its outstanding issues or TODO markers.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {
                "procedure": "# Release checklist\n\n## Review\nCheck that all changes have been reviewed.\n\n## Publish\nPublish the release only after review is complete."
              },
              "reply": "A skeleton stepfile for this procedure. Replace every TODO marker: declare the inputs, give each step a produces schema and gates that check its output against calls, and add the tools it needs. Then call stepgate_validate.\n\n```yaml\nstepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n```",
              "tool": "stepgate_outline"
            },
            {
              "arguments": {
                "stepfile": "stepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\""
              },
              "reply": "error: The stepfile still has parts to write. Replace every marker, then validate again:\n- /inputs: TODO(inputs): a JSON Schema object for what a run starts with\n- /steps/0/produces: TODO(produces): the JSON Schema of the output this step submits\n- /steps/0/gates/0: TODO(gate): the procedure states no rule for this step; check a real property of its output\n- /steps/1/produces: TODO(produces): the JSON Schema of the output this step submits\n- /steps/1/gates/0: TODO(gate): the procedure states no rule for this step; check a real property of its output",
              "tool": "stepgate_validate"
            }
          ],
          "task": "Turn this SOP into a skeleton stepfile, then validate the resulting skeleton and report its remaining issues: \"# Release checklist\\n\\n## Review\\nCheck that all changes have been reviewed.\\n\\n## Publish\\nPublish the release only after review is complete.\""
        },
        "type": "noul"
      },
      "w05": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "I generated the skeleton and validated it. The validator reported five unresolved TODO markers, so the skeleton is not yet valid.\n\n```yaml\nstepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n```\n\n**Remaining issues reported by the validator:**\n\n- `/inputs`: Define the run’s input JSON Schema.\n- `/steps/0/produces` and `/steps/1/produces`: Define each step’s output JSON Schema.\n- `/steps/0/gates/0` and `/steps/1/gates/0`: Replace the placeholder gates with checks on the step outputs.\n\nThe skeleton also needs the tools required for review and publishing. The publish gate should enforce the SOP’s requirement that review be complete before release.",
          "done_when": "The transcript shows the generated skeleton and a validation reply identifying its outstanding issues or TODO markers.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {
                "procedure": "# Release checklist\n\n## Review\nCheck that all changes have been reviewed.\n\n## Publish\nPublish the release only after review is complete."
              },
              "reply": "A skeleton stepfile for this procedure. Replace every TODO marker: declare the inputs, give each step a produces schema and gates that check its output against calls, and add the tools it needs. Then call stepgate_validate.\n\n```yaml\nstepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n```",
              "tool": "stepgate_outline"
            },
            {
              "arguments": {
                "stepfile": "stepgate: \"1\"\nid: release-checklist\ninputs: \"TODO(inputs): a JSON Schema object for what a run starts with\"\nsteps:\n  - id: review\n    instructions: Check that all changes have been reviewed.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\"\n  - id: publish\n    instructions: Publish the release only after review is complete.\n    produces: \"TODO(produces): the JSON Schema of the output this step submits\"\n    gates:\n      - \"TODO(gate): the procedure states no rule for this step; check a real property of its output\""
              },
              "reply": "error: The stepfile still has parts to write. Replace every marker, then validate again:\n- /inputs: TODO(inputs): a JSON Schema object for what a run starts with\n- /steps/0/produces: TODO(produces): the JSON Schema of the output this step submits\n- /steps/0/gates/0: TODO(gate): the procedure states no rule for this step; check a real property of its output\n- /steps/1/produces: TODO(produces): the JSON Schema of the output this step submits\n- /steps/1/gates/0: TODO(gate): the procedure states no rule for this step; check a real property of its output",
              "tool": "stepgate_validate"
            }
          ],
          "task": "Turn this SOP into a skeleton stepfile, then validate the resulting skeleton and report its remaining issues: \"# Release checklist\\n\\n## Review\\nCheck that all changes have been reviewed.\\n\\n## Publish\\nPublish the release only after review is complete.\""
        },
        "type": "noul"
      },
      "w06": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "I wrote and validated this minimal stepfile:\n\n```yaml\nstepgate: \"1\"\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name:\n      type: string\n      minLength: 1\n      description: \"The person's name\"\nsteps:\n  - id: greet\n    do:\n      output:\n        greeting: {cat: [\"Hello, \", {var: inputs.name}, \"!\"]}\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n```\n\nValidation reported that the stepfile is valid. I tried the draft with `name: Ada`; its mechanical step completed automatically, and the run finished with:\n\n```json\n{\"greet\": {\"greeting\": \"Hello, Ada!\"}}\n```\n\nThe tools do not provide a file-writing operation, so the stepfile was not saved to disk.",
          "done_when": "The transcript shows validation of the draft, a started run, and the completed run's output containing a greeting for Ada.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {},
              "reply": "# Writing a stepfile with Stepgate\n\n1. Read the reference below. Then call stepgate_examples to find a catalog stepfile close to the use case, and read it whole.\n2. For each OpenAPI API, call stepgate_inspect_api with kind \"openapi\" and the document's URL. It returns the sha256 to pin, the servers, the security schemes and the operationIds to expose; pass operations to see the arguments each takes. For a remote MCP server, kind \"mcp\" lists its tools with the schema_sha256 of each.\n3. Give every step gates that check its output against `calls`, what the APIs actually returned, not only its shape.\n4. Call stepgate_validate with the draft and fix every issue it lists.\n5. Call stepgate_try with the draft and example inputs, then drive the run with stepgate_call and stepgate_submit as for any stepfile. Drafts may call only public https URLs, and may declare only the credentials and settings the operator granted to drafts (a credential only for the hosts it was granted for); any other stepfile that needs a key is tried by saving it and adding its path to the server's configuration.\n6. Save it as <id>.stepfile.yaml. It runs by passing its absolute path to stepgate.\n\n## Starting from a procedure you already have\n\nWhen the user has the procedure written down, as a SKILL.md, a runbook or an SOP, call stepgate_outline with its text instead of starting from nothing. It returns a skeleton: one agent step per numbered item or second-level heading, and each sentence stating a rule (MUST, SHALL, REQUIRED, must, never) as a TODO(gate) under its step. Then:\n\n- Turn each TODO(gate) into a gate that checks the rule against the output and calls, and add gates for anything else the step's output must satisfy.\n- Make a step mechanical, with do, where it needs no judgement: fetching what the inputs name, counting, picking the latest item, copying fields. Use derive for computed fields of an agent step.\n- Declare inputs, tools and each step's produces, and replace every remaining TODO marker. stepgate_validate lists the markers left before it checks anything else.\n\n<a id=\"top\"></a>\n\n<p><a href=\"../README.md\">Stepgate</a> &middot; <strong>Writing a stepfile</strong> &middot; <a href=\"connect.md\">Connecting a client</a> &middot; <a href=\"how-it-works.md\">How it works</a></p>\n\n# Writing a stepfile\n\nA stepfile is one YAML or JSON file that describes an agent's procedure: its inputs, the remote APIs and MCP servers it may call, and an ordered list of steps with the checks each step must pass. It names no model, provider or framework, so the same file runs on any MCP client.\n\n- **Schema.** The JSON Schema is [server/schema/stepfile.schema.json](../server/schema/stepfile.schema.json).\n- **Example.** [awesome-stepfiles/marketing/market-research](../awesome-stepfiles/marketing/market-research/) is a complete example from the [catalog](../awesome-stepfiles/).\n- **File name.** Name files `<id>.stepfile.yaml`.\n- **Running your own.** Pass its path to `stepgate`, as [connect.md](connect.md#your-own-stepfiles) describes. It does not need to be in the catalog.\n- **What happens in a run.** See [how-it-works.md](how-it-works.md).\n\nThe format version is `\"1\"`. It is a draft, so fields may still change before a stable release.\n\n<details>\n  <summary>Contents</summary>\n  <ol>\n    <li><a href=\"#top-level-fields\">Top-level fields</a></li>\n    <li>\n      <a href=\"#tools\">Tools</a>\n      <ul>\n        <li><a href=\"#openapi-tools\">OpenAPI tools</a></li>\n        <li><a href=\"#mcp-tools\">MCP tools</a></li>\n        <li><a href=\"#verifier-tools\">Verifier tools</a></li>\n        <li><a href=\"#names-and-credentials\">Names and credentials</a></li>\n        <li><a href=\"#narrowing-results-with-select\">Narrowing results with <code>select</code></a></li>\n        <li><a href=\"#read-only-post-operations\">Read-only POST operations</a></li>\n        <li><a href=\"#how-parameters-and-bodies-are-sent\">How parameters and bodies are sent</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#settings\">Settings</a></li>\n    <li>\n      <a href=\"#credentials\">Credentials</a>\n      <ul>\n        <li><a href=\"#refreshing-oauth2-credentials\">Refreshing <code>oauth2</code> credentials</a></li>\n        <li><a href=\"#mcp-servers-that-use-mcp-authorization\">MCP servers that use MCP authorization</a></li>\n      </ul>\n    </li>\n    <li>\n      <a href=\"#steps\">Steps</a>\n      <ul>\n        <li><a href=\"#mechanical-steps\">Mechanical steps</a></li>\n        <li><a href=\"#deriving-fields\">Deriving fields</a></li>\n      </ul>\n    </li>\n    <li>\n      <a href=\"#gates\">Gates</a>\n      <ul>\n        <li><a href=\"#schema-gates\">Schema gates</a></li>\n        <li><a href=\"#predicate-gates\">Predicate gates</a></li>\n        <li><a href=\"#operators\">Operators</a></li>\n        <li><a href=\"#patterns\">Patterns</a></li>\n        <li><a href=\"#http-gates\">HTTP gates</a></li>\n        <li><a href=\"#approve-gates\">Approve gates</a></li>\n        <li><a href=\"#naming-expressions\">Naming expressions</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#testing-gates-offline\">Testing gates offline</a></li>\n    <li><a href=\"#when-a-gate-fails\">When a gate fails</a></li>\n    <li><a href=\"#identity\">Identity</a></li>\n  </ol>\n</details>\n\n## Top-level fields\n\n| Field | Required | Meaning |\n|---|---|---|\n| `stepgate` | yes | Format version, `\"1\"` |\n| `id` | yes | Lowercase identifier; it becomes the MCP tool name |\n| `title`, `description` | no | Human-facing text; `description` becomes the tool description |\n| `inputs` | yes | JSON Schema (2020-12) with `type: object`; it becomes the tool's input schema |\n| `settings` | no | Values whoever runs Stepgate supplies, such as a customer's site name ([Settings](#settings)) |\n| `credentials` | no | Secrets the tools need, by name ([Credentials](#credentials)) |\n| `tools` | no | Remote APIs and MCP servers the steps may call, keyed by lowercase hyphenated names such as `jira-cloud` ([Tools](#tools)) |\n| `steps` | yes | The steps, run in order ([Steps](#steps)) |\n| `$defs` | no | Shared JSON Schemas, referenced as `#/$defs/<name>` |\n\nUnknown fields are rejected.\n\nBeyond the schema, Stepgate checks these rules when it loads a file. It refuses to start if one fails:\n\n1. Step ids are unique, and gate ids are unique within a step.\n2. Every name in any `exposes` list is unique across the file, and none is `submit`.\n3. Every name in a step's `tools` is an exposed name.\n4. Every `credential` a tool names is declared, and the tool's host is in that credential's `hosts`.\n5. Every `http` gate names a `verifier` tool.\n6. Every placeholder and every `var` path under `steps.` names an earlier step.\n7. A step has `instructions` or `do`, not both.\n   - An agent step has at least one gate.\n   - A mechanical step has no `tools`, `retries`, `derive` or `let`.\n   - A mechanical step's call ids are unique, and every call names an exposed operation.\n   - `responses.<id>` names an earlier call of the step, or, in `output`, any of its calls.\n8. Every `derive` key is a property of the step's `produces`.\n9. Every `var` path under `let.` names an entry of the step's `let`.\n   - Read from `let` itself, it names an entry before it.\n   - `when` reads no `let`.\n10. Every `results` takes a literal operation name and an optional path.\n    - It appears only in an agent step's gates, `let` and `derive`.\n    - It never appears in `when`, `select` or `do`.\n11. Every expression is made of one-key objects naming a JSONLogic or Stepgate operator, and empty objects.\n    - An object with other keys would be kept as data, unevaluated, so it is refused.\n    - Build such an object with `object`, or, in a template, write it as it is.\n\n## Tools\n\nTools are remote. A stepfile cannot run local code or launch a stdio MCP server.\n\nEvery URL is `https`. The exception is plain `http` for a loopback address (`localhost`, `127.0.0.1`, `[::1]`), so local verifiers and test servers work.\n\n### OpenAPI tools\n\nAn **`openapi`** tool gives:\n\n- **`server`**, the URL Stepgate calls;\n- **the OpenAPI ",
              "tool": "stepgate_guide"
            },
            {
              "arguments": {},
              "reply": "18 catalog stepfiles. Call stepgate_examples with a name to read one.\n\n- airtable-field-completeness (data; keys: airtable): Reads up to 100 records of one Airtable table and reports, record by record, which of the fields you name are empty. Read-only.\n- snowflake-metric-to-jira (data; keys: snowflake, jira): Runs one fixed, read-only SELECT you supply against Snowflake through the SQL API once a person approves it, checks the metric it returns against your threshold, and only when the threshold is breached, and a person approves the draft, creates a Jira issue labelled stepgate-draft that quotes the exact values returned and the exact SQL.\n- dependency-upgrade-risk (engineering; no keys): Checks each npm package and pinned version against the npm registry and OSV.dev, and recommends an upgrade only where the registry's latest release is published and OSV lists no advisory against it.\n- servicenow-incident-review (engineering; keys: servicenow, github): Reads a ServiceNow incident, lists the GitHub commits and merged pull requests on one branch in the hours before it opened, builds a timeline and a list of suspect changes that cite real commit SHAs and pull request numbers, and adds the review to the incident as an internal work note once a person approves it.\n- sec-10k-ratio-extraction (finance; no keys): Resolves a US-listed ticker to its SEC CIK, pulls revenue, net income, total assets, total liabilities, equity and operating cash flow from the XBRL facts of its latest annual 10-K, and computes ratios that gates recompute from the SEC figures.\n- drug-shortage-watch (health; no keys): Checks each generic drug on a formulary against the current openFDA drug shortage list and returns an action list in which every status and NDC comes from an FDA record.\n- auto-claim-vin-validation (insurance; no keys): Decodes an auto claim's VIN with NHTSA vPIC, compares the claimed make, model and year against the decode, lists the vehicle's NHTSA recalls, and returns a consistent-or-refer verdict whose every value comes from those APIs.\n- regulatory-change-monitor (legal; no keys): Finds the final and proposed rules the Federal Register published for a topic or agency in a date range, and briefs which ones matter, citing document numbers and effective or comment-close dates taken from the API.\n- github-release-to-customers (marketing; keys: github, hubspot, gmail): Collects the pull requests merged between two GitHub releases, writes customer-facing release notes that cite them by number, finds the HubSpot contacts matching a property filter, and creates a Gmail draft to the operator with the notes and the recipient list. Creates a draft; never sends.\n- market-research (marketing; keys: tavily): Researches a brand's market position from web sources, discards what is irrelevant on the record, and writes a report in which every claim cites a source that survived the filter.\n- book-list-verification (media; no keys): Confirms that every book on a reading list exists in Open Library under the stated author, and flags books that do not exist or belong to someone else.\n- meeting-scheduler (productivity; keys: google-calendar, gmail): Queries Google Calendar free/busy for every attendee over a date range, proposes up to three slots inside working hours that Google confirms are free for everyone, and creates a Gmail draft of the invite email. Creates no calendar event and never sends.\n- disaster-declaration-brief (public; no keys): Lists every federal disaster declaration OpenFEMA records for a US state and date range, summarises them by incident type and assistance program, and writes a brief that cites each declaration by its FEMA disaster number.\n- reference-list-validation (research; no keys): Resolves every reference in a list to a real Crossref DOI record and flags references that are fabricated, carry the wrong DOI, or misstate the author or year.\n- hubspot-deal-to-monday (sales; keys: hubspot, monday): Reads a HubSpot deal, refuses it unless its stage is closed won, reads its line items, contacts and companies, plans one monday.com item per line item, and, once a person approves the plan, creates them as drafts in a new \"Stepgate draft\" group on a given board, each with an update carrying the deal, company and contact details.\n- cve-triage-prioritisation (security; no keys): Ranks up to five CVE ids into priorities 1 to 4 from their NVD CVSS score, CISA Known Exploited Vulnerabilities status as NVD records it, and FIRST EPSS probability, by a fixed published rule.\n- zendesk-jira-escalation (support; keys: zendesk, jira): Finds open Zendesk tickets matching an escalation rule (a priority and a tag), searches a Jira project for unresolved issues already tracking each problem, decides per ticket to link to one of them or create a Jira issue labelled stepgate-draft, and, once a person approves, creates those issues and adds an internal note naming the Jira key to every ticket. It never posts a public reply.\n- event-weather-contingency (travel; no keys): Finds the event location with Open-Meteo geocoding, fetches the daily forecast for the event date, applies fixed go, contingency and postpone thresholds, and writes a contingency plan that quotes the forecast it rests on.",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "book-list-verification"
              },
              "reply": "# book-list-verification.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading list against Open Library\ndescription: >\n  Confirms that every book on a reading list exists in Open Library under the\n  stated author, and flags books that do not exist or belong to someone else.\n\ninputs:\n  type: object\n  required: [books]\n  properties:\n    books:\n      type: array\n      description: The books to check, each with its title and the author the list names.\n      minItems: 1\n      maxItems: 30\n      items:\n        type: object\n        required: [title, author]\n        additionalProperties: false\n        properties:\n          title: { type: string, minLength: 1 }\n          author: { type: string, minLength: 1 }\n\ntools:\n  # Two tools over one endpoint so gates can tell a search filtered by the\n  # stated author, which is the attribution check, from a title-only search.\n  openlibrary-by-author:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title and author, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitleAndAuthor\n              summary: >\n                Search Open Library works matching both a title and an author\n                name. docs is empty when no work matches both.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: author\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitleAndAuthor]\n  openlibrary-by-title:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitle\n              summary: Search Open Library works by title alone, whoever wrote them.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitle]\n\nsteps:\n  - id: search\n    tools: [searchByTitleAndAuthor]\n    instructions: |\n      Here is a reading list:\n\n      {{inputs.books}}\n\n      Number the books B-01, B-02 and so on, in the order given. For every\n      book, call searchByTitleAndAuthor once, with title and author copied\n      exactly as given and limit 5. Make one call at a time.\n\n      For each book submit its id, title and author unchanged, and match: the\n      returned doc that is this book, as { key, title, author_name } copied\n      exactly (author_name is null if the doc has none). It is the same\n      title, allowing for case, punctuation and a subtitle. A doc with a\n      different title by the same author is not a match, nor is an omnibus or\n      box set. If no doc is this book, set match to null.\n    produces:\n      type: object\n      required: [books]\n      properties:\n        books:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, match]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^B-[0-9]{2,}$\" }\n              title: { type: string }\n              author: { type: string }\n              match: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      books: { map: [{ var: output.books }, { object: [[book, [{ var: title }, { var: author }]], [match, { var: match }]] }] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\": [{ var: tool }, searchByTitleAndAuthor] }, { \"!\": { var: is_error } }] }]\n          - object:\n              - [book, [{ var: arguments.title }, { var: arguments.author }]]\n              - [docs, { map: [{ var: result.docs }, &doc { object: [[key, { var: key }], [title, { var: title }], [author_name, { var: author_name }]] }] }]\n    gates:\n      - id: every-book-once\n        message: Submit every input book exactly once, with title and author unchanged and a unique id.\n        predicate:\n          and:\n            - \"==\":\n                - { length: { var: output.books } }\n                - { length: { var: inputs.books } }\n            - \"==\":\n                - { length: { unique: { map: [{ var: output.books }, { var: id }] } } }\n                - { length: { var: output.books } }\n            - subset:\n                - map: [{ var: inputs.books }, [{ var: title }, { var: author }]]\n                - map: [{ var: output.books }, [{ var: title }, { var: author }]]\n      - id: match-from-own-search\n        message: >\n          Every book needs a successful searchByTitleAndAuthor call with its\n          exact title and author, and match must be null or one of that call's\n          docs, copied exactly. These books break it:\n        predicate:\n          none:\n            - join: [{ var: let.books }, { var: let.searched }, book, book]\n            - or:\n                - \"==\": [{ var: right }, null]\n                - and: [{ var: left.match }, { \"!\": { subset: [[{ var: left.match }], { var: right.docs }] } }]\n    retries: 2\n\n  - id: crosscheck\n    tools: [searchByTitle]\n    instructions: |\n      These books were searched under their stated author:\n\n      {{steps.search.books}}\n\n      For every book whose match is null, and only those, call searchByTitle\n      with the title copied exactly and limit 5, to learn whether the book\n      exists under a different author. If every book has a match, make no\n      calls and submit an empty checks list.\n\n      For each book checked submit its id, title and author unchanged, and\n      found: the returned doc that is this book (same title, allowing for\n      case, punctuation and a subtitle), as { key, title, author_name } copied\n      exactly, or null if none is. A found doc must not list the stated\n      author, since that search already failed.\n    produces:\n      type: object\n      required: [checks]\n      properties:\n        checks:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, found]\n            additionalProperties: false\n            properties:\n              id: { type: string }\n              title: { type: string }\n              author: { type: string }\n              found: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      unmatched: { map: [{ filter: [{ var: steps.search.books }, { \"!\": { var: match } }] }, [{ var: id }, { var: title }, { var: author }]] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\":",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "cve-triage-prioritisation"
              },
              "reply": "# cve-triage-prioritisation.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: cve-triage-prioritisation\ntitle: Prioritise CVEs by severity, exploitation probability and known exploitation\ndescription: >\n  Ranks up to five CVE ids into priorities 1 to 4 from their NVD CVSS score, CISA Known Exploited\n  Vulnerabilities status as NVD records it, and FIRST EPSS probability, by a fixed published rule.\n\ninputs:\n  type: object\n  required: [cves]\n  properties:\n    # Five, because keyless NVD allows about five requests in a rolling 30 seconds and the run stops\n    # if a request is still rate limited after Stepgate's retries.\n    cves:\n      type: array\n      minItems: 1\n      maxItems: 5\n      uniqueItems: true\n      items: { type: string, pattern: \"^CVE-[0-9]{4}-[0-9]{4,}$\" }\n\ntools:\n  nvd:\n    openapi:\n      server: https://services.nvd.nist.gov/rest/json\n      document:\n        openapi: 3.1.0\n        info: { title: NVD CVE API 2.0 (trimmed), version: \"2.0\" }\n        paths:\n          /cves/2.0:\n            get:\n              operationId: getCve\n              summary: >\n                Fetch one CVE record from the NVD. vulnerabilities[0].cve.metrics holds CVSS entries under\n                cvssMetricV40, cvssMetricV31, cvssMetricV30 and cvssMetricV2, each with type (Primary or\n                Secondary), source and cvssData.baseScore. cisaExploitAdd and cisaActionDue are present only\n                when the CVE is in the CISA Known Exploited Vulnerabilities catalog. totalResults is 0 when\n                the NVD has no such CVE.\n              parameters:\n                - name: cveId\n                  in: query\n                  required: true\n                  schema: { type: string, pattern: \"^CVE-[0-9]{4}-[0-9]{4,}$\", description: \"One CVE id, for example CVE-2021-44228\" }\n              responses:\n                \"200\": { description: \"An NVD_CVE result with a vulnerabilities array of zero or one entries\" }\n    exposes: [getCve]\n\n  epss:\n    openapi:\n      server: https://api.first.org/data/v1\n      document:\n        openapi: 3.1.0\n        info: { title: FIRST EPSS API (trimmed), version: \"1\" }\n        paths:\n          /epss:\n            get:\n              operationId: getEpss\n              summary: >\n                Fetch today's EPSS scores. data holds one entry per scored CVE, with epss and percentile as\n                decimal strings between 0 and 1 and the score date. A CVE EPSS has not scored is left out.\n              parameters:\n                - name: cve\n                  in: query\n                  required: true\n                  explode: false\n                  schema: { type: array, items: { type: string }, description: \"CVE ids, sent comma-separated\" }\n              responses:\n                \"200\": { description: \"status, total and a data array\" }\n    exposes: [getEpss]\n\nsteps:\n  - id: nvd\n    do:\n      calls:\n        - id: lookups\n          operation: getCve\n          each: { var: inputs.cves }\n          arguments: { cveId: { var: item } }\n      output:\n        records:\n          map:\n            # A CVE the NVD lacks returns no id, so each input id is joined to its record.\n            - map:\n                - join: [{ map: [{ var: inputs.cves }, { object: [[cve, { var: \"\" }]] }] }, { var: responses.lookups }, cve, vulnerabilities.0.cve.id]\n                - object:\n                    - [cve, { var: left.cve }]\n                    - [record, { var: right.vulnerabilities.0.cve }]\n                    # The newest CVSS version present, then its first Primary entry, else its first entry.\n                    - - entry\n                      - if:\n                          - &primary\n                            filter:\n                              - &newest\n                                if:\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV40 }\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV40 }\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV31 }\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV31 }\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV30 }\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV30 }\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV2 }\n                                  - { var: right.vulnerabilities.0.cve.metrics.cvssMetricV2 }\n                                  - []\n                              - \"==\": [{ var: type }, Primary]\n                          - { get: [*primary, 0] }\n                          - { get: [*newest, 0] }\n            - object:\n                - [cve, { var: cve }]\n                - [in_nvd, { \"!=\": [{ var: record }, null] }]\n                - [cvss_version, { if: [{ var: entry }, { var: entry.cvssData.version }, none] }]\n                - [cvss_source, { var: entry.source }]\n                - [cvss_score, { var: entry.cvssData.baseScore }]\n                - [kev, { \"!=\": [{ var: record.cisaExploitAdd }, null] }]\n                - [kev_date_added, { var: record.cisaExploitAdd }]\n                - [kev_due_date, { var: record.cisaActionDue }]\n    produces:\n      type: object\n      required: [records]\n      properties:\n        records:\n          type: array\n          items:\n            type: object\n            required: [cve, in_nvd, cvss_version, cvss_source, cvss_score, kev, kev_date_added, kev_due_date]\n            additionalProperties: false\n            properties:\n              cve: { type: string }\n              in_nvd: { type: boolean }\n              cvss_version: { enum: [\"4.0\", \"3.1\", \"3.0\", \"2.0\", none] }\n              cvss_source: { type: [string, \"null\"] }\n              cvss_score: { type: [number, \"null\"], minimum: 0, maximum: 10 }\n              kev: { type: boolean }\n              kev_date_added: { type: [string, \"null\"], pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\" }\n              kev_due_date: { type: [string, \"null\"], pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\" }\n\n  - id: epss\n    do:\n      calls:\n        - { id: scores, operation: getEpss, arguments: { cve: { var: inputs.cves } } }\n      output:\n        # \"+\" turns FIRST's decimal strings into numbers; a CVE EPSS has not scored has no entry.\n        scores:\n          map:\n            - join: [{ map: [{ var: inputs.cves }, { object: [[cve, { var: \"\" }]] }] }, { var: responses.scores.data }, cve, cve]\n            - object:\n                - [cve, { var: left.cve }]\n                - [epss, { if: [{ var: right }, { \"+\": [{ var: right.epss }] }, null] }]\n                - [percentile, { if: [{ var: right }, { \"+\": [{ var: right.percentile }] }, null] }]\n        epss_date: { var: responses.scores.data.0.date }\n    produces:\n      type: object\n      required: [scores, epss_date]\n      properties:\n        scores:\n          type: array\n          items:\n            type: object\n            required: [cve, epss, percentile]\n            additionalProperties: false\n            properties:\n              cve: { type: string }\n              epss: { type: [number, \"null\"], minimum: 0, maximum: 1 }\n              percentile: { type: [number, \"null\"], minimum: 0, maximum: 1 }\n        epss_date: { type: [string, \"null\"], pattern: \"^[0-9]{4}-[0-9]{2}-[0-9]{2}$\" }\n\n  - id: rank\n    do:\n      output:\n        # Sorted by priority.\n        ranking:\n          sort_by:\n            - map:\n                - map:\n                    - join: [{ var: steps.nvd.records }, { var: steps.epss.scores }, cve, cve]\n                    - object:\n                        - [cve, { var: left.cve }]\n                        - [kev, { var: left.kev }]\n                        - [epss, { var: right.epss }]\n                        - [cvss_score, { var: left.cvss_score }]\n                        - - priority\n                          -",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "stepfile": "stepgate: \"1\"\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1, description: \"The person's name\"}\nsteps:\n  - id: greet\n    do:\n      output:\n        greeting: {cat: [\"Hello, \", {var: inputs.name}, \"!\"]}\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n"
              },
              "reply": "The stepfile is valid.\nid: greeting\nidentity: sha256:14069392645ae4b4f9975844b083a1a55aa54fce5efe2ccbe56964499c8d5b8d\nsteps: greet\n\nstepgate_try can run it.",
              "tool": "stepgate_validate"
            },
            {
              "arguments": {
                "inputs": {
                  "name": "Ada"
                },
                "stepfile": "stepgate: \"1\"\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1, description: \"The person's name\"}\nsteps:\n  - id: greet\n    do:\n      output:\n        greeting: {cat: [\"Hello, \", {var: inputs.name}, \"!\"]}\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n"
              },
              "reply": "The run finished. Every step passed its gates. Outputs:\n{\n  \"greet\": {\n    \"greeting\": \"Hello, Ada!\"\n  }\n}",
              "tool": "stepgate_try"
            }
          ],
          "task": "Using the stepfile authoring guide, write and validate a minimal stepfile for a run that asks for a person's name and returns a greeting, then try the draft with the name Ada and complete its steps."
        },
        "type": "noul"
      },
      "w07": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "The draft validated successfully, and the trial run completed with every gate passing. For the input `Ada`, it returned **“Hello, Ada!”**\n\n```yaml\n# greeting.stepfile.yaml\nstepgate: \"1\"\nid: greeting\ntitle: Greeting\n\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1}\n\nsteps:\n  - id: greet\n    instructions: \"Greet {{inputs.name}} as Hello, <name>!\"\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n    gates:\n      - id: correct-greeting\n        message: The greeting must match the input name.\n        predicate:\n          '==': [{var: output.greeting}, {cat: ['Hello, ', {var: inputs.name}, '!']}]\n```\n\nThe tools validated and ran the draft but did not provide a way to save it as a file.",
          "done_when": "The transcript shows validation of the draft, a started run, and the completed run's output containing a greeting for Ada.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {},
              "reply": "# Writing a stepfile with Stepgate\n\n1. Read the reference below. Then call stepgate_examples to find a catalog stepfile close to the use case, and read it whole.\n2. For each OpenAPI API, call stepgate_inspect_api with kind \"openapi\" and the document's URL. It returns the sha256 to pin, the servers, the security schemes and the operationIds to expose; pass operations to see the arguments each takes. For a remote MCP server, kind \"mcp\" lists its tools with the schema_sha256 of each.\n3. Give every step gates that check its output against `calls`, what the APIs actually returned, not only its shape.\n4. Call stepgate_validate with the draft and fix every issue it lists.\n5. Call stepgate_try with the draft and example inputs, then drive the run with stepgate_call and stepgate_submit as for any stepfile. Drafts may call only public https URLs, and may declare only the credentials and settings the operator granted to drafts (a credential only for the hosts it was granted for); any other stepfile that needs a key is tried by saving it and adding its path to the server's configuration.\n6. Save it as <id>.stepfile.yaml. It runs by passing its absolute path to stepgate.\n\n## Starting from a procedure you already have\n\nWhen the user has the procedure written down, as a SKILL.md, a runbook or an SOP, call stepgate_outline with its text instead of starting from nothing. It returns a skeleton: one agent step per numbered item or second-level heading, and each sentence stating a rule (MUST, SHALL, REQUIRED, must, never) as a TODO(gate) under its step. Then:\n\n- Turn each TODO(gate) into a gate that checks the rule against the output and calls, and add gates for anything else the step's output must satisfy.\n- Make a step mechanical, with do, where it needs no judgement: fetching what the inputs name, counting, picking the latest item, copying fields. Use derive for computed fields of an agent step.\n- Declare inputs, tools and each step's produces, and replace every remaining TODO marker. stepgate_validate lists the markers left before it checks anything else.\n\n<a id=\"top\"></a>\n\n<p><a href=\"../README.md\">Stepgate</a> &middot; <strong>Writing a stepfile</strong> &middot; <a href=\"connect.md\">Connecting a client</a> &middot; <a href=\"how-it-works.md\">How it works</a></p>\n\n# Writing a stepfile\n\nA stepfile is one YAML or JSON file that describes an agent's procedure: its inputs, the remote APIs and MCP servers it may call, and an ordered list of steps with the checks each step must pass. It names no model, provider or framework, so the same file runs on any MCP client.\n\n- **Schema.** The JSON Schema is [server/schema/stepfile.schema.json](../server/schema/stepfile.schema.json).\n- **Example.** [awesome-stepfiles/marketing/market-research](../awesome-stepfiles/marketing/market-research/) is a complete example from the [catalog](../awesome-stepfiles/).\n- **File name.** Name files `<id>.stepfile.yaml`.\n- **Running your own.** Pass its path to `stepgate`, as [connect.md](connect.md#your-own-stepfiles) describes. It does not need to be in the catalog.\n- **What happens in a run.** See [how-it-works.md](how-it-works.md).\n\nThe format version is `\"1\"`. It is a draft, so fields may still change before a stable release.\n\n<details>\n  <summary>Contents</summary>\n  <ol>\n    <li><a href=\"#top-level-fields\">Top-level fields</a></li>\n    <li>\n      <a href=\"#tools\">Tools</a>\n      <ul>\n        <li><a href=\"#openapi-tools\">OpenAPI tools</a></li>\n        <li><a href=\"#mcp-tools\">MCP tools</a></li>\n        <li><a href=\"#verifier-tools\">Verifier tools</a></li>\n        <li><a href=\"#names-and-credentials\">Names and credentials</a></li>\n        <li><a href=\"#narrowing-results-with-select\">Narrowing results with <code>select</code></a></li>\n        <li><a href=\"#read-only-post-operations\">Read-only POST operations</a></li>\n        <li><a href=\"#how-parameters-and-bodies-are-sent\">How parameters and bodies are sent</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#settings\">Settings</a></li>\n    <li>\n      <a href=\"#credentials\">Credentials</a>\n      <ul>\n        <li><a href=\"#refreshing-oauth2-credentials\">Refreshing <code>oauth2</code> credentials</a></li>\n        <li><a href=\"#mcp-servers-that-use-mcp-authorization\">MCP servers that use MCP authorization</a></li>\n      </ul>\n    </li>\n    <li>\n      <a href=\"#steps\">Steps</a>\n      <ul>\n        <li><a href=\"#mechanical-steps\">Mechanical steps</a></li>\n        <li><a href=\"#deriving-fields\">Deriving fields</a></li>\n      </ul>\n    </li>\n    <li>\n      <a href=\"#gates\">Gates</a>\n      <ul>\n        <li><a href=\"#schema-gates\">Schema gates</a></li>\n        <li><a href=\"#predicate-gates\">Predicate gates</a></li>\n        <li><a href=\"#operators\">Operators</a></li>\n        <li><a href=\"#patterns\">Patterns</a></li>\n        <li><a href=\"#http-gates\">HTTP gates</a></li>\n        <li><a href=\"#approve-gates\">Approve gates</a></li>\n        <li><a href=\"#naming-expressions\">Naming expressions</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#testing-gates-offline\">Testing gates offline</a></li>\n    <li><a href=\"#when-a-gate-fails\">When a gate fails</a></li>\n    <li><a href=\"#identity\">Identity</a></li>\n  </ol>\n</details>\n\n## Top-level fields\n\n| Field | Required | Meaning |\n|---|---|---|\n| `stepgate` | yes | Format version, `\"1\"` |\n| `id` | yes | Lowercase identifier; it becomes the MCP tool name |\n| `title`, `description` | no | Human-facing text; `description` becomes the tool description |\n| `inputs` | yes | JSON Schema (2020-12) with `type: object`; it becomes the tool's input schema |\n| `settings` | no | Values whoever runs Stepgate supplies, such as a customer's site name ([Settings](#settings)) |\n| `credentials` | no | Secrets the tools need, by name ([Credentials](#credentials)) |\n| `tools` | no | Remote APIs and MCP servers the steps may call, keyed by lowercase hyphenated names such as `jira-cloud` ([Tools](#tools)) |\n| `steps` | yes | The steps, run in order ([Steps](#steps)) |\n| `$defs` | no | Shared JSON Schemas, referenced as `#/$defs/<name>` |\n\nUnknown fields are rejected.\n\nBeyond the schema, Stepgate checks these rules when it loads a file. It refuses to start if one fails:\n\n1. Step ids are unique, and gate ids are unique within a step.\n2. Every name in any `exposes` list is unique across the file, and none is `submit`.\n3. Every name in a step's `tools` is an exposed name.\n4. Every `credential` a tool names is declared, and the tool's host is in that credential's `hosts`.\n5. Every `http` gate names a `verifier` tool.\n6. Every placeholder and every `var` path under `steps.` names an earlier step.\n7. A step has `instructions` or `do`, not both.\n   - An agent step has at least one gate.\n   - A mechanical step has no `tools`, `retries`, `derive` or `let`.\n   - A mechanical step's call ids are unique, and every call names an exposed operation.\n   - `responses.<id>` names an earlier call of the step, or, in `output`, any of its calls.\n8. Every `derive` key is a property of the step's `produces`.\n9. Every `var` path under `let.` names an entry of the step's `let`.\n   - Read from `let` itself, it names an entry before it.\n   - `when` reads no `let`.\n10. Every `results` takes a literal operation name and an optional path.\n    - It appears only in an agent step's gates, `let` and `derive`.\n    - It never appears in `when`, `select` or `do`.\n11. Every expression is made of one-key objects naming a JSONLogic or Stepgate operator, and empty objects.\n    - An object with other keys would be kept as data, unevaluated, so it is refused.\n    - Build such an object with `object`, or, in a template, write it as it is.\n\n## Tools\n\nTools are remote. A stepfile cannot run local code or launch a stdio MCP server.\n\nEvery URL is `https`. The exception is plain `http` for a loopback address (`localhost`, `127.0.0.1`, `[::1]`), so local verifiers and test servers work.\n\n### OpenAPI tools\n\nAn **`openapi`** tool gives:\n\n- **`server`**, the URL Stepgate calls;\n- **the OpenAPI ",
              "tool": "stepgate_guide"
            },
            {
              "arguments": {},
              "reply": "18 catalog stepfiles. Call stepgate_examples with a name to read one.\n\n- airtable-field-completeness (data; keys: airtable): Reads up to 100 records of one Airtable table and reports, record by record, which of the fields you name are empty. Read-only.\n- snowflake-metric-to-jira (data; keys: snowflake, jira): Runs one fixed, read-only SELECT you supply against Snowflake through the SQL API once a person approves it, checks the metric it returns against your threshold, and only when the threshold is breached, and a person approves the draft, creates a Jira issue labelled stepgate-draft that quotes the exact values returned and the exact SQL.\n- dependency-upgrade-risk (engineering; no keys): Checks each npm package and pinned version against the npm registry and OSV.dev, and recommends an upgrade only where the registry's latest release is published and OSV lists no advisory against it.\n- servicenow-incident-review (engineering; keys: servicenow, github): Reads a ServiceNow incident, lists the GitHub commits and merged pull requests on one branch in the hours before it opened, builds a timeline and a list of suspect changes that cite real commit SHAs and pull request numbers, and adds the review to the incident as an internal work note once a person approves it.\n- sec-10k-ratio-extraction (finance; no keys): Resolves a US-listed ticker to its SEC CIK, pulls revenue, net income, total assets, total liabilities, equity and operating cash flow from the XBRL facts of its latest annual 10-K, and computes ratios that gates recompute from the SEC figures.\n- drug-shortage-watch (health; no keys): Checks each generic drug on a formulary against the current openFDA drug shortage list and returns an action list in which every status and NDC comes from an FDA record.\n- auto-claim-vin-validation (insurance; no keys): Decodes an auto claim's VIN with NHTSA vPIC, compares the claimed make, model and year against the decode, lists the vehicle's NHTSA recalls, and returns a consistent-or-refer verdict whose every value comes from those APIs.\n- regulatory-change-monitor (legal; no keys): Finds the final and proposed rules the Federal Register published for a topic or agency in a date range, and briefs which ones matter, citing document numbers and effective or comment-close dates taken from the API.\n- github-release-to-customers (marketing; keys: github, hubspot, gmail): Collects the pull requests merged between two GitHub releases, writes customer-facing release notes that cite them by number, finds the HubSpot contacts matching a property filter, and creates a Gmail draft to the operator with the notes and the recipient list. Creates a draft; never sends.\n- market-research (marketing; keys: tavily): Researches a brand's market position from web sources, discards what is irrelevant on the record, and writes a report in which every claim cites a source that survived the filter.\n- book-list-verification (media; no keys): Confirms that every book on a reading list exists in Open Library under the stated author, and flags books that do not exist or belong to someone else.\n- meeting-scheduler (productivity; keys: google-calendar, gmail): Queries Google Calendar free/busy for every attendee over a date range, proposes up to three slots inside working hours that Google confirms are free for everyone, and creates a Gmail draft of the invite email. Creates no calendar event and never sends.\n- disaster-declaration-brief (public; no keys): Lists every federal disaster declaration OpenFEMA records for a US state and date range, summarises them by incident type and assistance program, and writes a brief that cites each declaration by its FEMA disaster number.\n- reference-list-validation (research; no keys): Resolves every reference in a list to a real Crossref DOI record and flags references that are fabricated, carry the wrong DOI, or misstate the author or year.\n- hubspot-deal-to-monday (sales; keys: hubspot, monday): Reads a HubSpot deal, refuses it unless its stage is closed won, reads its line items, contacts and companies, plans one monday.com item per line item, and, once a person approves the plan, creates them as drafts in a new \"Stepgate draft\" group on a given board, each with an update carrying the deal, company and contact details.\n- cve-triage-prioritisation (security; no keys): Ranks up to five CVE ids into priorities 1 to 4 from their NVD CVSS score, CISA Known Exploited Vulnerabilities status as NVD records it, and FIRST EPSS probability, by a fixed published rule.\n- zendesk-jira-escalation (support; keys: zendesk, jira): Finds open Zendesk tickets matching an escalation rule (a priority and a tag), searches a Jira project for unresolved issues already tracking each problem, decides per ticket to link to one of them or create a Jira issue labelled stepgate-draft, and, once a person approves, creates those issues and adds an internal note naming the Jira key to every ticket. It never posts a public reply.\n- event-weather-contingency (travel; no keys): Finds the event location with Open-Meteo geocoding, fetches the daily forecast for the event date, applies fixed go, contingency and postpone thresholds, and writes a contingency plan that quotes the forecast it rests on.",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "book-list-verification"
              },
              "reply": "# book-list-verification.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading list against Open Library\ndescription: >\n  Confirms that every book on a reading list exists in Open Library under the\n  stated author, and flags books that do not exist or belong to someone else.\n\ninputs:\n  type: object\n  required: [books]\n  properties:\n    books:\n      type: array\n      description: The books to check, each with its title and the author the list names.\n      minItems: 1\n      maxItems: 30\n      items:\n        type: object\n        required: [title, author]\n        additionalProperties: false\n        properties:\n          title: { type: string, minLength: 1 }\n          author: { type: string, minLength: 1 }\n\ntools:\n  # Two tools over one endpoint so gates can tell a search filtered by the\n  # stated author, which is the attribution check, from a title-only search.\n  openlibrary-by-author:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title and author, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitleAndAuthor\n              summary: >\n                Search Open Library works matching both a title and an author\n                name. docs is empty when no work matches both.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: author\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitleAndAuthor]\n  openlibrary-by-title:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitle\n              summary: Search Open Library works by title alone, whoever wrote them.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitle]\n\nsteps:\n  - id: search\n    tools: [searchByTitleAndAuthor]\n    instructions: |\n      Here is a reading list:\n\n      {{inputs.books}}\n\n      Number the books B-01, B-02 and so on, in the order given. For every\n      book, call searchByTitleAndAuthor once, with title and author copied\n      exactly as given and limit 5. Make one call at a time.\n\n      For each book submit its id, title and author unchanged, and match: the\n      returned doc that is this book, as { key, title, author_name } copied\n      exactly (author_name is null if the doc has none). It is the same\n      title, allowing for case, punctuation and a subtitle. A doc with a\n      different title by the same author is not a match, nor is an omnibus or\n      box set. If no doc is this book, set match to null.\n    produces:\n      type: object\n      required: [books]\n      properties:\n        books:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, match]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^B-[0-9]{2,}$\" }\n              title: { type: string }\n              author: { type: string }\n              match: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      books: { map: [{ var: output.books }, { object: [[book, [{ var: title }, { var: author }]], [match, { var: match }]] }] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\": [{ var: tool }, searchByTitleAndAuthor] }, { \"!\": { var: is_error } }] }]\n          - object:\n              - [book, [{ var: arguments.title }, { var: arguments.author }]]\n              - [docs, { map: [{ var: result.docs }, &doc { object: [[key, { var: key }], [title, { var: title }], [author_name, { var: author_name }]] }] }]\n    gates:\n      - id: every-book-once\n        message: Submit every input book exactly once, with title and author unchanged and a unique id.\n        predicate:\n          and:\n            - \"==\":\n                - { length: { var: output.books } }\n                - { length: { var: inputs.books } }\n            - \"==\":\n                - { length: { unique: { map: [{ var: output.books }, { var: id }] } } }\n                - { length: { var: output.books } }\n            - subset:\n                - map: [{ var: inputs.books }, [{ var: title }, { var: author }]]\n                - map: [{ var: output.books }, [{ var: title }, { var: author }]]\n      - id: match-from-own-search\n        message: >\n          Every book needs a successful searchByTitleAndAuthor call with its\n          exact title and author, and match must be null or one of that call's\n          docs, copied exactly. These books break it:\n        predicate:\n          none:\n            - join: [{ var: let.books }, { var: let.searched }, book, book]\n            - or:\n                - \"==\": [{ var: right }, null]\n                - and: [{ var: left.match }, { \"!\": { subset: [[{ var: left.match }], { var: right.docs }] } }]\n    retries: 2\n\n  - id: crosscheck\n    tools: [searchByTitle]\n    instructions: |\n      These books were searched under their stated author:\n\n      {{steps.search.books}}\n\n      For every book whose match is null, and only those, call searchByTitle\n      with the title copied exactly and limit 5, to learn whether the book\n      exists under a different author. If every book has a match, make no\n      calls and submit an empty checks list.\n\n      For each book checked submit its id, title and author unchanged, and\n      found: the returned doc that is this book (same title, allowing for\n      case, punctuation and a subtitle), as { key, title, author_name } copied\n      exactly, or null if none is. A found doc must not list the stated\n      author, since that search already failed.\n    produces:\n      type: object\n      required: [checks]\n      properties:\n        checks:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, found]\n            additionalProperties: false\n            properties:\n              id: { type: string }\n              title: { type: string }\n              author: { type: string }\n              found: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      unmatched: { map: [{ filter: [{ var: steps.search.books }, { \"!\": { var: match } }] }, [{ var: id }, { var: title }, { var: author }]] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\":",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "stepfile": "stepgate: \"1\"\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1}\nsteps:\n  - id: greet\n    instructions: \"Greet {{inputs.name}} as Hello, <name>!\"\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n    gates:\n      - id: correct-greeting\n        predicate:\n          '==': [{var: output.greeting}, {cat: ['Hello, ', {var: inputs.name}, '!']}]\n"
              },
              "reply": "error: The stepfile is invalid. Fix every issue:\n- /steps/0/gates/0: must have required property 'schema'\n- /steps/0/gates/0: must have required property 'message'\n- /steps/0/gates/0: must have required property 'http'\n- /steps/0/gates/0: must have required property 'approve'\n- /steps/0/gates/0: must match exactly one schema in oneOf",
              "tool": "stepgate_validate"
            },
            {
              "arguments": {
                "stepfile": "stepgate: \"1\"\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1}\nsteps:\n  - id: greet\n    instructions: \"Greet {{inputs.name}} as Hello, <name>!\"\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n    gates:\n      - id: correct-greeting\n        message: The greeting must match the input name.\n        predicate:\n          '==': [{var: output.greeting}, {cat: ['Hello, ', {var: inputs.name}, '!']}]\n"
              },
              "reply": "The stepfile is valid.\nid: greeting\nidentity: sha256:b243b5a12afd66d3e621aa8fe8264e4bbba3f5170a78c64bf5354e2f0e29b401\nsteps: greet\n\nstepgate_try can run it.",
              "tool": "stepgate_validate"
            },
            {
              "arguments": {
                "inputs": {
                  "name": "Ada"
                },
                "stepfile": "stepgate: \"1\"\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1}\nsteps:\n  - id: greet\n    instructions: \"Greet {{inputs.name}} as Hello, <name>!\"\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n    gates:\n      - id: correct-greeting\n        message: The greeting must match the input name.\n        predicate:\n          '==': [{var: output.greeting}, {cat: ['Hello, ', {var: inputs.name}, '!']}]\n"
              },
              "reply": "Run ce71ba31-1053-4bfa-8ae4-6ddb4ff80d11, step 1 of 1: greet.\n\nInstructions:\nGreet Ada as Hello, <name>!\n\nThis step has no operations; work from the instructions and what earlier steps returned.\n\nWhen the step is done, call stepgate_submit with run \"ce71ba31-1053-4bfa-8ae4-6ddb4ff80d11\" and an output matching this JSON Schema:\n{\"type\":\"object\",\"required\":[\"greeting\"],\"properties\":{\"greeting\":{\"type\":\"string\"}}}\n\nAttempts: 1.",
              "tool": "stepgate_try"
            },
            {
              "arguments": {
                "output": {
                  "greeting": "Hello, Ada!"
                },
                "run": "ce71ba31-1053-4bfa-8ae4-6ddb4ff80d11"
              },
              "reply": "The run finished. Every step passed its gates. Outputs:\n{\n  \"greet\": {\n    \"greeting\": \"Hello, Ada!\"\n  }\n}",
              "tool": "stepgate_submit"
            }
          ],
          "task": "Using the stepfile authoring guide, write and validate a minimal stepfile for a run that asks for a person's name and returns a greeting, then try the draft with the name Ada and complete its steps."
        },
        "type": "noul"
      },
      "w08": {
        "criteria": {
          "false": "The tool replies show an error, a missing or different result, or nothing about the task; or only the agent's final answer claims the task was done.",
          "true": "The tool replies in `steps` show the result that `done_when` describes. The result came from the server's tools, not only from the agent's own words."
        },
        "instructions": {
          "agent_final_answer": "Here is the validated stepfile:\n\n```yaml\nstepgate: \"1\"\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name:\n      type: string\n      minLength: 1\n      description: \"The person's name\"\nsteps:\n  - id: greet\n    instructions: \"Greet {{inputs.name}} as Hello, <name>!\"\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting:\n          type: string\n    gates:\n      - id: exact-greeting\n        message: Greeting must include the name exactly.\n        predicate:\n          \"==\":\n            - {var: output.greeting}\n            - {cat: [\"Hello, \", {var: inputs.name}, \"!\"]}\n```\n\nValidation reported that the stepfile is valid. I tried it with `name: Ada` and completed its single step; the run finished with every gate passing:\n\n```json\n{\"greet\": {\"greeting\": \"Hello, Ada!\"}}\n```\n\nThe available tools do not provide a file-writing operation, so I did not save it as `greeting.stepfile.yaml`.",
          "done_when": "The transcript shows validation of the draft, a started run, and the completed run's output containing a greeting for Ada.",
          "how_it_ended": "answered",
          "question": "Did the agent finish `task`, as `done_when` describes, according to the tool replies in `steps`?",
          "steps": [
            {
              "arguments": {},
              "reply": "# Writing a stepfile with Stepgate\n\n1. Read the reference below. Then call stepgate_examples to find a catalog stepfile close to the use case, and read it whole.\n2. For each OpenAPI API, call stepgate_inspect_api with kind \"openapi\" and the document's URL. It returns the sha256 to pin, the servers, the security schemes and the operationIds to expose; pass operations to see the arguments each takes. For a remote MCP server, kind \"mcp\" lists its tools with the schema_sha256 of each.\n3. Give every step gates that check its output against `calls`, what the APIs actually returned, not only its shape.\n4. Call stepgate_validate with the draft and fix every issue it lists.\n5. Call stepgate_try with the draft and example inputs, then drive the run with stepgate_call and stepgate_submit as for any stepfile. Drafts may call only public https URLs, and may declare only the credentials and settings the operator granted to drafts (a credential only for the hosts it was granted for); any other stepfile that needs a key is tried by saving it and adding its path to the server's configuration.\n6. Save it as <id>.stepfile.yaml. It runs by passing its absolute path to stepgate.\n\n## Starting from a procedure you already have\n\nWhen the user has the procedure written down, as a SKILL.md, a runbook or an SOP, call stepgate_outline with its text instead of starting from nothing. It returns a skeleton: one agent step per numbered item or second-level heading, and each sentence stating a rule (MUST, SHALL, REQUIRED, must, never) as a TODO(gate) under its step. Then:\n\n- Turn each TODO(gate) into a gate that checks the rule against the output and calls, and add gates for anything else the step's output must satisfy.\n- Make a step mechanical, with do, where it needs no judgement: fetching what the inputs name, counting, picking the latest item, copying fields. Use derive for computed fields of an agent step.\n- Declare inputs, tools and each step's produces, and replace every remaining TODO marker. stepgate_validate lists the markers left before it checks anything else.\n\n<a id=\"top\"></a>\n\n<p><a href=\"../README.md\">Stepgate</a> &middot; <strong>Writing a stepfile</strong> &middot; <a href=\"connect.md\">Connecting a client</a> &middot; <a href=\"how-it-works.md\">How it works</a></p>\n\n# Writing a stepfile\n\nA stepfile is one YAML or JSON file that describes an agent's procedure: its inputs, the remote APIs and MCP servers it may call, and an ordered list of steps with the checks each step must pass. It names no model, provider or framework, so the same file runs on any MCP client.\n\n- **Schema.** The JSON Schema is [server/schema/stepfile.schema.json](../server/schema/stepfile.schema.json).\n- **Example.** [awesome-stepfiles/marketing/market-research](../awesome-stepfiles/marketing/market-research/) is a complete example from the [catalog](../awesome-stepfiles/).\n- **File name.** Name files `<id>.stepfile.yaml`.\n- **Running your own.** Pass its path to `stepgate`, as [connect.md](connect.md#your-own-stepfiles) describes. It does not need to be in the catalog.\n- **What happens in a run.** See [how-it-works.md](how-it-works.md).\n\nThe format version is `\"1\"`. It is a draft, so fields may still change before a stable release.\n\n<details>\n  <summary>Contents</summary>\n  <ol>\n    <li><a href=\"#top-level-fields\">Top-level fields</a></li>\n    <li>\n      <a href=\"#tools\">Tools</a>\n      <ul>\n        <li><a href=\"#openapi-tools\">OpenAPI tools</a></li>\n        <li><a href=\"#mcp-tools\">MCP tools</a></li>\n        <li><a href=\"#verifier-tools\">Verifier tools</a></li>\n        <li><a href=\"#names-and-credentials\">Names and credentials</a></li>\n        <li><a href=\"#narrowing-results-with-select\">Narrowing results with <code>select</code></a></li>\n        <li><a href=\"#read-only-post-operations\">Read-only POST operations</a></li>\n        <li><a href=\"#how-parameters-and-bodies-are-sent\">How parameters and bodies are sent</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#settings\">Settings</a></li>\n    <li>\n      <a href=\"#credentials\">Credentials</a>\n      <ul>\n        <li><a href=\"#refreshing-oauth2-credentials\">Refreshing <code>oauth2</code> credentials</a></li>\n        <li><a href=\"#mcp-servers-that-use-mcp-authorization\">MCP servers that use MCP authorization</a></li>\n      </ul>\n    </li>\n    <li>\n      <a href=\"#steps\">Steps</a>\n      <ul>\n        <li><a href=\"#mechanical-steps\">Mechanical steps</a></li>\n        <li><a href=\"#deriving-fields\">Deriving fields</a></li>\n      </ul>\n    </li>\n    <li>\n      <a href=\"#gates\">Gates</a>\n      <ul>\n        <li><a href=\"#schema-gates\">Schema gates</a></li>\n        <li><a href=\"#predicate-gates\">Predicate gates</a></li>\n        <li><a href=\"#operators\">Operators</a></li>\n        <li><a href=\"#patterns\">Patterns</a></li>\n        <li><a href=\"#http-gates\">HTTP gates</a></li>\n        <li><a href=\"#approve-gates\">Approve gates</a></li>\n        <li><a href=\"#naming-expressions\">Naming expressions</a></li>\n      </ul>\n    </li>\n    <li><a href=\"#testing-gates-offline\">Testing gates offline</a></li>\n    <li><a href=\"#when-a-gate-fails\">When a gate fails</a></li>\n    <li><a href=\"#identity\">Identity</a></li>\n  </ol>\n</details>\n\n## Top-level fields\n\n| Field | Required | Meaning |\n|---|---|---|\n| `stepgate` | yes | Format version, `\"1\"` |\n| `id` | yes | Lowercase identifier; it becomes the MCP tool name |\n| `title`, `description` | no | Human-facing text; `description` becomes the tool description |\n| `inputs` | yes | JSON Schema (2020-12) with `type: object`; it becomes the tool's input schema |\n| `settings` | no | Values whoever runs Stepgate supplies, such as a customer's site name ([Settings](#settings)) |\n| `credentials` | no | Secrets the tools need, by name ([Credentials](#credentials)) |\n| `tools` | no | Remote APIs and MCP servers the steps may call, keyed by lowercase hyphenated names such as `jira-cloud` ([Tools](#tools)) |\n| `steps` | yes | The steps, run in order ([Steps](#steps)) |\n| `$defs` | no | Shared JSON Schemas, referenced as `#/$defs/<name>` |\n\nUnknown fields are rejected.\n\nBeyond the schema, Stepgate checks these rules when it loads a file. It refuses to start if one fails:\n\n1. Step ids are unique, and gate ids are unique within a step.\n2. Every name in any `exposes` list is unique across the file, and none is `submit`.\n3. Every name in a step's `tools` is an exposed name.\n4. Every `credential` a tool names is declared, and the tool's host is in that credential's `hosts`.\n5. Every `http` gate names a `verifier` tool.\n6. Every placeholder and every `var` path under `steps.` names an earlier step.\n7. A step has `instructions` or `do`, not both.\n   - An agent step has at least one gate.\n   - A mechanical step has no `tools`, `retries`, `derive` or `let`.\n   - A mechanical step's call ids are unique, and every call names an exposed operation.\n   - `responses.<id>` names an earlier call of the step, or, in `output`, any of its calls.\n8. Every `derive` key is a property of the step's `produces`.\n9. Every `var` path under `let.` names an entry of the step's `let`.\n   - Read from `let` itself, it names an entry before it.\n   - `when` reads no `let`.\n10. Every `results` takes a literal operation name and an optional path.\n    - It appears only in an agent step's gates, `let` and `derive`.\n    - It never appears in `when`, `select` or `do`.\n11. Every expression is made of one-key objects naming a JSONLogic or Stepgate operator, and empty objects.\n    - An object with other keys would be kept as data, unevaluated, so it is refused.\n    - Build such an object with `object`, or, in a template, write it as it is.\n\n## Tools\n\nTools are remote. A stepfile cannot run local code or launch a stdio MCP server.\n\nEvery URL is `https`. The exception is plain `http` for a loopback address (`localhost`, `127.0.0.1`, `[::1]`), so local verifiers and test servers work.\n\n### OpenAPI tools\n\nAn **`openapi`** tool gives:\n\n- **`server`**, the URL Stepgate calls;\n- **the OpenAPI ",
              "tool": "stepgate_guide"
            },
            {
              "arguments": {},
              "reply": "18 catalog stepfiles. Call stepgate_examples with a name to read one.\n\n- airtable-field-completeness (data; keys: airtable): Reads up to 100 records of one Airtable table and reports, record by record, which of the fields you name are empty. Read-only.\n- snowflake-metric-to-jira (data; keys: snowflake, jira): Runs one fixed, read-only SELECT you supply against Snowflake through the SQL API once a person approves it, checks the metric it returns against your threshold, and only when the threshold is breached, and a person approves the draft, creates a Jira issue labelled stepgate-draft that quotes the exact values returned and the exact SQL.\n- dependency-upgrade-risk (engineering; no keys): Checks each npm package and pinned version against the npm registry and OSV.dev, and recommends an upgrade only where the registry's latest release is published and OSV lists no advisory against it.\n- servicenow-incident-review (engineering; keys: servicenow, github): Reads a ServiceNow incident, lists the GitHub commits and merged pull requests on one branch in the hours before it opened, builds a timeline and a list of suspect changes that cite real commit SHAs and pull request numbers, and adds the review to the incident as an internal work note once a person approves it.\n- sec-10k-ratio-extraction (finance; no keys): Resolves a US-listed ticker to its SEC CIK, pulls revenue, net income, total assets, total liabilities, equity and operating cash flow from the XBRL facts of its latest annual 10-K, and computes ratios that gates recompute from the SEC figures.\n- drug-shortage-watch (health; no keys): Checks each generic drug on a formulary against the current openFDA drug shortage list and returns an action list in which every status and NDC comes from an FDA record.\n- auto-claim-vin-validation (insurance; no keys): Decodes an auto claim's VIN with NHTSA vPIC, compares the claimed make, model and year against the decode, lists the vehicle's NHTSA recalls, and returns a consistent-or-refer verdict whose every value comes from those APIs.\n- regulatory-change-monitor (legal; no keys): Finds the final and proposed rules the Federal Register published for a topic or agency in a date range, and briefs which ones matter, citing document numbers and effective or comment-close dates taken from the API.\n- github-release-to-customers (marketing; keys: github, hubspot, gmail): Collects the pull requests merged between two GitHub releases, writes customer-facing release notes that cite them by number, finds the HubSpot contacts matching a property filter, and creates a Gmail draft to the operator with the notes and the recipient list. Creates a draft; never sends.\n- market-research (marketing; keys: tavily): Researches a brand's market position from web sources, discards what is irrelevant on the record, and writes a report in which every claim cites a source that survived the filter.\n- book-list-verification (media; no keys): Confirms that every book on a reading list exists in Open Library under the stated author, and flags books that do not exist or belong to someone else.\n- meeting-scheduler (productivity; keys: google-calendar, gmail): Queries Google Calendar free/busy for every attendee over a date range, proposes up to three slots inside working hours that Google confirms are free for everyone, and creates a Gmail draft of the invite email. Creates no calendar event and never sends.\n- disaster-declaration-brief (public; no keys): Lists every federal disaster declaration OpenFEMA records for a US state and date range, summarises them by incident type and assistance program, and writes a brief that cites each declaration by its FEMA disaster number.\n- reference-list-validation (research; no keys): Resolves every reference in a list to a real Crossref DOI record and flags references that are fabricated, carry the wrong DOI, or misstate the author or year.\n- hubspot-deal-to-monday (sales; keys: hubspot, monday): Reads a HubSpot deal, refuses it unless its stage is closed won, reads its line items, contacts and companies, plans one monday.com item per line item, and, once a person approves the plan, creates them as drafts in a new \"Stepgate draft\" group on a given board, each with an update carrying the deal, company and contact details.\n- cve-triage-prioritisation (security; no keys): Ranks up to five CVE ids into priorities 1 to 4 from their NVD CVSS score, CISA Known Exploited Vulnerabilities status as NVD records it, and FIRST EPSS probability, by a fixed published rule.\n- zendesk-jira-escalation (support; keys: zendesk, jira): Finds open Zendesk tickets matching an escalation rule (a priority and a tag), searches a Jira project for unresolved issues already tracking each problem, decides per ticket to link to one of them or create a Jira issue labelled stepgate-draft, and, once a person approves, creates those issues and adds an internal note naming the Jira key to every ticket. It never posts a public reply.\n- event-weather-contingency (travel; no keys): Finds the event location with Open-Meteo geocoding, fetches the daily forecast for the event date, applies fixed go, contingency and postpone thresholds, and writes a contingency plan that quotes the forecast it rests on.",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "name": "book-list-verification"
              },
              "reply": "# book-list-verification.stepfile.yaml\n\n```yaml\n# yaml-language-server: $schema=../../../server/schema/stepfile.schema.json\nstepgate: \"1\"\nid: book-list-verification\ntitle: Verify a reading list against Open Library\ndescription: >\n  Confirms that every book on a reading list exists in Open Library under the\n  stated author, and flags books that do not exist or belong to someone else.\n\ninputs:\n  type: object\n  required: [books]\n  properties:\n    books:\n      type: array\n      description: The books to check, each with its title and the author the list names.\n      minItems: 1\n      maxItems: 30\n      items:\n        type: object\n        required: [title, author]\n        additionalProperties: false\n        properties:\n          title: { type: string, minLength: 1 }\n          author: { type: string, minLength: 1 }\n\ntools:\n  # Two tools over one endpoint so gates can tell a search filtered by the\n  # stated author, which is the attribution check, from a title-only search.\n  openlibrary-by-author:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title and author, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitleAndAuthor\n              summary: >\n                Search Open Library works matching both a title and an author\n                name. docs is empty when no work matches both.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: author\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitleAndAuthor]\n  openlibrary-by-title:\n    openapi:\n      server: https://openlibrary.org\n      document:\n        openapi: 3.1.0\n        info: { title: Open Library search, by title, version: \"1\" }\n        paths:\n          /search.json:\n            get:\n              operationId: searchByTitle\n              summary: Search Open Library works by title alone, whoever wrote them.\n              parameters:\n                - name: title\n                  in: query\n                  required: true\n                  schema: { type: string, minLength: 1 }\n                - name: limit\n                  in: query\n                  required: true\n                  description: Number of results, 1 to 5.\n                  schema: { type: integer, minimum: 1, maximum: 5 }\n                - name: fields\n                  in: query\n                  required: true\n                  description: The fields to return; only this value is accepted.\n                  schema: { type: string, enum: [\"key,title,author_name,first_publish_year\"] }\n              responses:\n                \"200\": { description: Search results }\n    exposes: [searchByTitle]\n\nsteps:\n  - id: search\n    tools: [searchByTitleAndAuthor]\n    instructions: |\n      Here is a reading list:\n\n      {{inputs.books}}\n\n      Number the books B-01, B-02 and so on, in the order given. For every\n      book, call searchByTitleAndAuthor once, with title and author copied\n      exactly as given and limit 5. Make one call at a time.\n\n      For each book submit its id, title and author unchanged, and match: the\n      returned doc that is this book, as { key, title, author_name } copied\n      exactly (author_name is null if the doc has none). It is the same\n      title, allowing for case, punctuation and a subtitle. A doc with a\n      different title by the same author is not a match, nor is an omnibus or\n      box set. If no doc is this book, set match to null.\n    produces:\n      type: object\n      required: [books]\n      properties:\n        books:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, match]\n            additionalProperties: false\n            properties:\n              id: { type: string, pattern: \"^B-[0-9]{2,}$\" }\n              title: { type: string }\n              author: { type: string }\n              match: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      books: { map: [{ var: output.books }, { object: [[book, [{ var: title }, { var: author }]], [match, { var: match }]] }] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\": [{ var: tool }, searchByTitleAndAuthor] }, { \"!\": { var: is_error } }] }]\n          - object:\n              - [book, [{ var: arguments.title }, { var: arguments.author }]]\n              - [docs, { map: [{ var: result.docs }, &doc { object: [[key, { var: key }], [title, { var: title }], [author_name, { var: author_name }]] }] }]\n    gates:\n      - id: every-book-once\n        message: Submit every input book exactly once, with title and author unchanged and a unique id.\n        predicate:\n          and:\n            - \"==\":\n                - { length: { var: output.books } }\n                - { length: { var: inputs.books } }\n            - \"==\":\n                - { length: { unique: { map: [{ var: output.books }, { var: id }] } } }\n                - { length: { var: output.books } }\n            - subset:\n                - map: [{ var: inputs.books }, [{ var: title }, { var: author }]]\n                - map: [{ var: output.books }, [{ var: title }, { var: author }]]\n      - id: match-from-own-search\n        message: >\n          Every book needs a successful searchByTitleAndAuthor call with its\n          exact title and author, and match must be null or one of that call's\n          docs, copied exactly. These books break it:\n        predicate:\n          none:\n            - join: [{ var: let.books }, { var: let.searched }, book, book]\n            - or:\n                - \"==\": [{ var: right }, null]\n                - and: [{ var: left.match }, { \"!\": { subset: [[{ var: left.match }], { var: right.docs }] } }]\n    retries: 2\n\n  - id: crosscheck\n    tools: [searchByTitle]\n    instructions: |\n      These books were searched under their stated author:\n\n      {{steps.search.books}}\n\n      For every book whose match is null, and only those, call searchByTitle\n      with the title copied exactly and limit 5, to learn whether the book\n      exists under a different author. If every book has a match, make no\n      calls and submit an empty checks list.\n\n      For each book checked submit its id, title and author unchanged, and\n      found: the returned doc that is this book (same title, allowing for\n      case, punctuation and a subtitle), as { key, title, author_name } copied\n      exactly, or null if none is. A found doc must not list the stated\n      author, since that search already failed.\n    produces:\n      type: object\n      required: [checks]\n      properties:\n        checks:\n          type: array\n          items:\n            type: object\n            required: [id, title, author, found]\n            additionalProperties: false\n            properties:\n              id: { type: string }\n              title: { type: string }\n              author: { type: string }\n              found: { anyOf: [{ $ref: \"#/$defs/doc\" }, { type: \"null\" }] }\n    let:\n      unmatched: { map: [{ filter: [{ var: steps.search.books }, { \"!\": { var: match } }] }, [{ var: id }, { var: title }, { var: author }]] }\n      searched:\n        map:\n          - filter: [{ var: calls }, { and: [{ \"==\":",
              "tool": "stepgate_examples"
            },
            {
              "arguments": {
                "stepfile": "stepgate: '1'\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1, description: \"The person's name\"}\nsteps:\n  - id: greet\n    instructions: \"Greet {{inputs.name}} as Hello, <name>!\"\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n    gates:\n      - id: exact-greeting\n        message: Greeting must include the name exactly.\n        predicate:\n          '==': [{var: output.greeting}, {cat: ['Hello, ', {var: inputs.name}, '!']}]\n"
              },
              "reply": "The stepfile is valid.\nid: greeting\nidentity: sha256:5b6dd00bdfc057bb9f50d11cbe15d780c2361f36891a6c36f73b0ff64ec50f37\nsteps: greet\n\nstepgate_try can run it.",
              "tool": "stepgate_validate"
            },
            {
              "arguments": {
                "inputs": {
                  "name": "Ada"
                },
                "stepfile": "stepgate: '1'\nid: greeting\ntitle: Greeting\ninputs:\n  type: object\n  required: [name]\n  properties:\n    name: {type: string, minLength: 1, description: \"The person's name\"}\nsteps:\n  - id: greet\n    instructions: \"Greet {{inputs.name}} as Hello, <name>!\"\n    produces:\n      type: object\n      required: [greeting]\n      properties:\n        greeting: {type: string}\n    gates:\n      - id: exact-greeting\n        message: Greeting must include the name exactly.\n        predicate:\n          '==': [{var: output.greeting}, {cat: ['Hello, ', {var: inputs.name}, '!']}]\n"
              },
              "reply": "Run 76dafb40-a27b-4c20-8924-5336d2c5ae71, step 1 of 1: greet.\n\nInstructions:\nGreet Ada as Hello, <name>!\n\nThis step has no operations; work from the instructions and what earlier steps returned.\n\nWhen the step is done, call stepgate_submit with run \"76dafb40-a27b-4c20-8924-5336d2c5ae71\" and an output matching this JSON Schema:\n{\"type\":\"object\",\"required\":[\"greeting\"],\"properties\":{\"greeting\":{\"type\":\"string\"}}}\n\nAttempts: 1.",
              "tool": "stepgate_try"
            },
            {
              "arguments": {
                "output": {
                  "greeting": "Hello, Ada!"
                },
                "run": "76dafb40-a27b-4c20-8924-5336d2c5ae71"
              },
              "reply": "The run finished. Every step passed its gates. Outputs:\n{\n  \"greet\": {\n    \"greeting\": \"Hello, Ada!\"\n  }\n}",
              "tool": "stepgate_submit"
            }
          ],
          "task": "Using the stepfile authoring guide, write and validate a minimal stepfile for a run that asks for a person's name and returns a greeting, then try the draft with the name Ada and complete its steps."
        },
        "type": "noul"
      }
    },
    "state": {
      "about": "Replies of an MCP server to tool calls that were sent with bad input on purpose, to see whether its error messages help a caller fix the call."
    }
  },
  "run_id": "01M838ZMRXP5S5T99YM114BQXW",
  "works_done": [
    {
      "attempt": 0,
      "noul": 0.08,
      "question": "w00"
    },
    {
      "attempt": 1,
      "noul": 0.05,
      "question": "w01"
    },
    {
      "attempt": 2,
      "noul": 0.06,
      "question": "w02"
    },
    {
      "attempt": 3,
      "noul": 0.93,
      "question": "w03"
    },
    {
      "attempt": 4,
      "noul": 0.94,
      "question": "w04"
    },
    {
      "attempt": 5,
      "noul": 0.81,
      "question": "w05"
    },
    {
      "attempt": 6,
      "noul": 0.98,
      "question": "w06"
    },
    {
      "attempt": 7,
      "noul": 0.96,
      "question": "w07"
    },
    {
      "attempt": 8,
      "noul": 0.96,
      "question": "w08"
    }
  ]
}
