Skip to main content

The agent test

Job postings for developer documentation now say some version of "docs that don't mislead AI agents." Here is the test I ran against my own work to find out what that means in practice. The method is simple: give an agent a guide, ask it to produce the requests a developer would make, and check every request against the OpenAPI spec. Where the guide and the spec disagree, the agent follows the guide, because that is what it was given.

I ran it on two sets of docs I wrote: Nium's and Finix's.

Nium: endpoints that aren't in the spec​

Nium's bulk-payouts guide documents three requests:

POST /payout/bulk
GET /payout/bulk/{batchId}/status
GET /payout/bulk/{batchId}

None of the three exist in nium.yaml, the OpenAPI spec the reference is generated from. A developer reading the guide would try them, get a 404, and go looking. An agent reading the guide integrates against them and reports success, because nothing it was given says otherwise.

This is the drift my docs drift script exists to catch: guide text that references an operation the spec does not have. On Nium's docs the script found seven such references across the guides against 159 operations in the spec. Seven is not many. Each one is an integration that cannot work.

Finix: a label that disagrees with its own example​

Finix's guides use full URLs and link to the spec, so an agent gets further. The failure I found is smaller and more interesting. In the in-person payments guide, step 5 is labeled as a request to /authorizations, and the curl example under it posts to /transfers.

A human reads the label, glances at the curl, and probably does the right thing, because the surrounding prose is about authorizing a card. An agent copies the curl. On Finix's platform /transfers is a sale and /authorizations is a hold, so the agent places a sale where the guide meant a hold. Both requests succeed. The money moves differently.

What the test says about "docs for agents"​

  1. The spec is the source of truth. Not the guide, not the llms.txt, not the Markdown rendering of the reference. Anything a guide says about a request has to be checked against the spec by a machine, because a reader will forgive a mismatch and an agent will execute it.
  2. Labels are code. A heading that names a method and a path is a claim the agent will act on. It needs the same review as the example under it.
  3. Agents fail quietly. Both findings produce a working integration that does the wrong thing. Nothing errors. The only way to find them is to compare the guide to the spec before an agent does.
  4. The fix is a check, not a rewrite. Both findings fall out of a script that extracts method-and-path references from Markdown and looks each one up in the spec. That script now runs in CI on every pull request to the docs.

How to run it on your own docs​

  • Export the OpenAPI spec and list every method path operation in it.
  • Extract every method path reference from the guides: headings, prose, code fences.
  • Diff the two lists. References in the guides that are not in the spec are the first findings.
  • For references that match, compare the path in the label to the path in the example under it. Mismatches are the second kind.
  • Then hand a guide to an agent, ask for the requests, and read what comes back as if you were going to run it.