Blog

How to test an on-call agent across PagerDuty, Datadog, Slack and GitHub

An on-call agent’s riskiest calls are the ones that make alerts stop. How to test them in PagerDuty and Datadog, with a world file and three recorded runs.

November 10, 2026 · Patrick Liu

A minute before our on-call agent starts, Hector Ruiz asks in #incidents who has the page. Orders API latency is climbing in production. PagerDuty shows two triggered incidents. One is the Orders API, two minutes old, and it pages the agent. The other is Checkout returning 5xx errors in staging. It is twelve minutes old, and it pages Hector.

The task touches four tools. Acknowledge the Orders page with a note. Open a pull request that reverts yesterday’s database pool cut. Mute the staging latency monitor while the revert runs there, and keep production alerts on. Post an update in #incidents.

Two of those steps exist to make noise stop. An acknowledgment halts a page’s escalation, and a downtime keeps a monitor from alerting. They are the riskiest calls an on-call agent makes, because a mistake in either one is silent by design. Acknowledge the wrong incident and a colleague’s page goes quiet. Mute too much and the production alert goes quiet with it. Both calls return 200, and the channel gets calmer, which is what success was supposed to look like.

We built Bramble Market’s evening as a world and wrote three scripted agents against it. One acknowledges the wrong incident. One leaves a single field out of its downtime request and mutes every monitor. One does the job. The second and third agents produce identical call logs: 13 requests with matching methods and paths, in matching order, each answered with 200 or 201. The difference is one missing key in one JSON body. A test that reads only what an agent called can’t tell those two agents apart.

The world runs on Ancha, which we make.

Why the quiet calls are the risky ones

PagerDuty is direct about what an acknowledgment means: the user who acknowledges an incident “claims ownership of the issue and halts the escalation process.” Notifications for that incident stop until its acknowledgement timeout runs out. So an agent that acknowledges Hector’s Checkout page by mistake does two things nobody asked for. It tells PagerDuty that Hector’s problem has an owner, and that owner isn’t looking at it. Meanwhile its own page stays triggered: the Orders page, behind a production p95 latency of 2,120, more than double the monitor’s threshold.

Datadog’s downtimes fail the same way from the other side. In the v1 API the field that picks a monitor is optional, and the reference spells out the default: “If not provided, the downtime applies to all monitors.” Our agent was asked to mute the staging monitor for 30 minutes. Without monitor_id it also muted the production monitor, the one already in Alert.

The detail that changed how we write these tests is in the call logs. The agent that muted everything sent the same 13 requests as the agent that got it right: three to PagerDuty, six to GitHub, two to Datadog and two to Slack. Every response was 200 or 201. Line the two logs up and they match, method for method and path for path. The only difference sits inside the body of POST /api/v1/downtime, where one request carries monitor_id and the other doesn’t.

Both agents then post the same update in #incidents, and it ends with “production alerts stay on.” For one of them that sentence is false. That agent’s own log line even names the staging monitor as the one it muted.

That is why most of the checks below inspect PagerDuty and Datadog after the agent exits, instead of its requests. A status code tells you a request was accepted. It doesn’t tell you the request was the right one.

Bramble Market’s evening in four tools

We seeded Bramble Market, an online grocer, in all four tools at once. PagerDuty has two services, each with its own escalation policy: Orders API pages the on-call agent and Checkout API pages Hector. Each service has a triggered incident. Datadog has two p95 latency monitors on the Orders API, one per environment. In production the metric went from 340 to 1,450 to 2,120 over the last fifteen minutes, against a threshold of 800, so that monitor is in Alert. Staging hovers around 300, and its monitor is OK.

GitHub has bramble/orders. A month ago Nora Lindgren set the database pool to 40, and yesterday she cut it to 8. That cut is why Orders API requests are waiting for connections. Slack has #incidents, with Hector, Nora and the agent in it. Every trial starts from this state with the world’s clock at 19:00 UTC on November 10, so twelve minutes old means the same thing in each one.

These lines of the world file decide whether the agent picks correctly:

pagerduty:
  incidents:
    - ref: checkout_page
      service: $checkout
      title: "Checkout API: elevated 5xx in staging"
      status: triggered
      at: -12m
    - ref: orders_page
      service: $orders
      title: "Orders API: requests waiting for database connections"
      status: triggered
      at: -2m
datadog:
  monitors:
    - ref: latency_prod
      name: "Orders API p95 latency"
      query: "avg(last_5m):avg:orders.latency.p95{env:prod} > 800"
      message: "Production orders latency is high."
      tags: [service:orders-api, env:prod]
      state: Alert
    - ref: latency_staging
      name: "Orders API p95 latency (staging)"
      query: "avg(last_5m):avg:orders.latency.p95{env:staging} > 800"
      message: "Staging orders latency is high."
      tags: [service:orders-api, env:staging]
      state: OK

Look at the two monitors. Their names differ by one word in parentheses, and their queries differ only in env:prod against env:staging. Both carry service:orders-api. An agent that finds the monitor by its service tag, or by the start of its name, can land on production. Ours picks the monitor whose tags include env:staging, the one property that tells them apart.

What should an on-call agent test check?

Five checks, matching the five things the task asks for:

checks:
  - id: acked_orders
    state: { pagerduty.incident: { ref: $orders_page }, status: acknowledged }
  - id: left_checkout_alone
    state: { pagerduty.incident: { ref: $checkout_page }, status: triggered }
  - id: muted_staging_only
    state:
      datadog.downtime:
        monitor: $latency_staging
        remaining_gte: 20m
        duration_lte: 30m
        reject_active_unsafe: true
  - id: opened_the_revert
    trace: { called: "POST /repos/bramble/orders/pulls" }
  - id: posted_the_update
    state: { slack.message: { channel: $incidents, from: $slack_agent } }

Checks marked state look at a tool once the agent has finished. Checks marked trace look at the requests it sent. Four of the five here are state checks. On call, the mistakes worth testing end up in PagerDuty’s and Datadog’s state, so that is where we look.

acked_orders and left_checkout_alone work as a pair. Run ancha check on the freshly seeded world, with no agent at all, and left_checkout_alone already passes while the other four fail. That makes sense, since doing nothing leaves Checkout alone. A guard check like this proves nothing by itself. Next to a check that requires action, the two together say the agent acted on the right incident and only on that one.

muted_staging_only carries the most weight. It wants one active downtime on the staging monitor, with at least 20 minutes left and a total length of at most 30. It fails if any active downtime covers every monitor. Each condition covers a different way to get a downtime wrong. Without monitor_id the downtime covers every monitor. Without end it stays in effect until someone cancels it. And an end built from JavaScript’s Date.now() is in milliseconds, while Datadog’s field is a POSIX timestamp, counted in seconds. Pass milliseconds and you are asking for a downtime that ends tens of thousands of years from now. Our agent divides by 1,000 before it adds 30 minutes, and duration_lte: 30m is there for the agent that forgets.

PagerDuty’s writes have one mistake that is loud. Acknowledging an incident or adding a note needs a From header with the email of a valid user on the account. Leave it out and the request fails, so that one shows up in the agent’s own errors and in the trace.

opened_the_revert is a trace check because the point is the route the change took: a pull request, with head as the branch that holds the revert and base as main. An agent that pushes the revert straight to main gets the same code onto main and skips the review. posted_the_update reads #incidents after the run and wants a message from the agent there.

Run one: the oldest page in the list

The first agent runs a fixed script and calls no model, so all three trials make identical choices. It completes all four parts of the task, and it gets exactly one thing wrong: how it picks the incident. It lists the triggered incidents and takes the first.

$ ancha run oncall-world.yaml --local -n 3
running locally; agent not sealed (network open, 5 variables from this shell)
run_20261110-232944_b6b2a998a255cf1e: 3 trials of oncall-world, 1 at a time
trial 1 ✗ 169ms · 2 checks failed
trial 2 ✗ 159ms · 2 checks failed
trial 3 ✗ 164ms · 2 checks failed

✗ oncall-world  0/3 (0%)
    ✗ acked_orders  failed in 3/3 trials
      trial 1: Expected {"ref":"$orders_page"} status acknowledged; found incident PKWEYCF: triggered; created at 2026-11-10T18:58:00.000Z; acknowledged unmeasured; resolved unmeasured; captured at 2026-11-10T19:00:00.162Z.
    ✗ left_checkout_alone  failed in 3/3 trials
      trial 1: Expected {"ref":"$checkout_page"} status triggered; found incident PWW0YH5: acknowledged; created at 2026-11-10T18:48:00.000Z; first acknowledged at 2026-11-10T19:00:00.079Z (720079ms after creation); resolved unmeasured; captured at 2026-11-10T19:00:00.162Z.

fail (minimum pass rate 100%)  run run_20261110-232944_b6b2a998a255cf1e

In our world the list came back oldest first, so the first incident was Checkout’s. PagerDuty promises the same default order on every request, and that is what the agent got. A consistent order isn’t a relevant one, though. Nothing about it knows which service the agent covers.

Read the two failure lines together. acked_orders found the Orders incident still triggered. left_checkout_alone found Checkout acknowledged at 19:00:00.079, which is 720,079 milliseconds after it was created and 79 milliseconds into the run. The agent’s note went onto Hector’s incident as well. All 13 of its calls returned 200 or 201. The revert, the downtime and the update checked out in every trial.

One line fixes it: look up the incident whose service is the Orders API instead of taking incidents[0]. Our agent matches the service by name, which is fine in a world file. In your own code, match the service ID from your configuration, because names get edited.

Run two: thirteen identical calls

Agent two fixes the incident lookup and sends its downtime without monitor_id.

$ ancha run oncall-world.yaml --local -n 3
running locally; agent not sealed (network open, 5 variables from this shell)
run_20261110-232947_d2c97d0d2acfc4c5: 3 trials of oncall-world, 1 at a time
trial 1 ✗ 158ms · muted_staging_only failed
trial 2 ✗ 125ms · muted_staging_only failed
trial 3 ✗ 128ms · muted_staging_only failed

✗ oncall-world  0/3 (0%)
    ✗ muted_staging_only  failed in 3/3 trials
      trial 1: Expected $latency_staging active exact-monitor downtime, remaining >= 20m, duration <= 30m; no active all-monitor or overlong target downtime; found unsafe downtime 1: all-monitor; captured at 2026-11-10T19:00:00.151Z.

fail (minimum pass rate 100%)  run run_20261110-232947_d2c97d0d2acfc4c5

This is the agent the post opened with. The check found an active downtime that covers every monitor, and that alone fails it. The same downtime silences the production monitor that is in Alert. The task said production alerts stay on, and the agent told #incidents they would. Datadog holds a different answer.

Now look at what passed. acked_orders, left_checkout_alone, opened_the_revert and posted_the_update passed in every trial. A suite of trace checks would have gone green on this agent. So would any assertion that the agent called POST /api/v1/downtime, because it did, and got a 200 back.

Datadog has deprecated the v1 downtime endpoint in favor of v2, and v2 makes the target explicit: monitor_identifier is required. That doesn’t retire this mistake. In v2, setting monitor_tags to [*] mutes every monitor in the scope, so the end state worth checking is the same in both versions.

Run three: both fixes

With the incident found by its service and monitor_id in the downtime:

$ ancha run oncall-world.yaml --local -n 3
running locally; agent not sealed (network open, 5 variables from this shell)
run_20261110-232941_6cddfb01734cff98: 3 trials of oncall-world, 1 at a time
trial 1 ✓ 163ms
trial 2 ✓ 134ms
trial 3 ✓ 139ms

✓ oncall-world  3/3 (100%)

pass (minimum pass rate 100%)  run run_20261110-232941_6cddfb01734cff98

Three trials, 134 to 163 milliseconds each. The checks that failed above pass here, and that is the other half of the evidence. If a check goes red on the mistake and green on the fix, it is measuring the mistake. One that never changes color is measuring something else.

Single-tool versions of both mistakes, each with its one-line fix, are recorded on the PagerDuty and Datadog pages.

Would a mock or a recording have caught these?

ApproachCatchesMissesVendor accountTools
Mock the SDK clientsYour agent’s own decisions: which incident ID it acknowledges, what its downtime request containsWhat the APIs do with those calls: the order the incident list comes back in, and that a downtime with no monitor_id covers every monitor. A mock answers the way you wrote itNoThe mocks in Jest (30.5.2, September 2026), Vitest (5.1.0, November 2026) or Python’s unittest.mock
Fake or recorded HTTP APIsThe requests the real SDKs send: paths, headers such as PagerDuty’s From, and bodiesWhat a write changes. A stubbed or recorded answer does not acknowledge the incident or schedule the downtime, so the next read shows the old state. WireMock scenarios and Mockoon CRUD routes keep state you script yourselfNo; yes to recordWireMock (3.13.2, November 2025), Mockoon (9.10.0, October 2026), Prism (5.16.0, July 2026), Polly.js (6.0.6, July 2023), nock (15.0.6, November 2026), vcrpy (9.4.2, November 2026)
Each vendor’s own accountThe products themselves: escalation, phone and SMS notifications, the integrations between the tools, permissions, rate limitsA repeatable start: incidents stay acknowledged, downtimes stay scheduled and messages stay in the channel from the last run, until you reset themYes, one per toolA PagerDuty developer account, a Datadog trial, a Slack developer sandbox and a GitHub organization for tests (details below)
Stateful replicaWhat the agent changed: the incident it acknowledged, the monitors its downtime covers, the pull request it opened, the message it posted. Each run starts from the same seeded stateNoAncha (all four), Sparta Worlds (all four, in closed beta), Arga Labs and Archal (Datadog, GitHub and Slack), vercel-labs/emulate (GitHub and Slack; Apache-2.0, 0.13.1, November 2026)

The table’s version numbers and dates were read off npm, PyPI and GitHub on November 10, 2026.

A mock of the PagerDuty client catches the wrong incident only if you write it to return the incidents oldest first. Mocks are still worth writing for the incident-picking logic and for the function that assembles the downtime request. They run in milliseconds and pin your logic down.

A recorded or faked HTTP API sees the requests. It would show the downtime body without monitor_id, if some test asserted on that body. But the recording creates no downtime, so nothing is muted afterwards and a later look at the monitors finds nothing wrong. WireMock scenarios and Mockoon’s CRUD routes can hold state, and you script that state yourself.

The vendors’ own accounts show the real products: escalation policies, notification rules, the incident page. They are where you check API keys and integrations. They are a poor fit for running one scenario three times, because the first run leaves an acknowledged incident and an active downtime behind.

A replica keeps state and resets it for every trial. Both mistakes in this post are about what the agent left behind, so that is where they showed up for us.

Testing against real PagerDuty and Datadog

Each vendor offers a free or trial way in. PagerDuty’s developer account is free and made for building apps and integrations. It allows 3 full users and 2 stakeholders. Its users can’t receive SMS or phone notifications, and it can’t be converted into a paid account. Datadog’s trial opens the whole platform for 14 days. After that you can upgrade or move to the Free tier, which covers up to five Basic hosts with one day of metric retention.

Slack provides developer sandboxes at no extra charge. You can keep two running at once, eight users in each, and each one expires after half a year, or after a month for the basic kind. GitHub’s Free plan for organizations costs nothing and covers any number of public repositories, with all features.

What you take on is the reset. Every run leaves an acknowledged incident, a scheduled downtime and a message in the channel. Before the next run, trigger new incidents, cancel the downtimes and clear the channel, or the second run starts where the first one ended.

Pointing the SDKs at the world

Nothing in the agent’s code has to know it is in a test. The official clients for all four tools accept another base URL, and ancha connect lists the setting for each one. We ran every snippet below against this world:

import { api } from '@pagerduty/pdjs';
import { client, v1 } from '@datadog/datadog-api-client';
import { WebClient } from '@slack/web-api';
import { Octokit } from '@octokit/rest';

const pd = api({ token: process.env.PAGERDUTY_API_TOKEN });
const incidents = await pd.get('/incidents', {
  url: `${process.env.PAGERDUTY_API_URL}/incidents`
});

const datadog = client.createConfiguration({
  baseServer: new client.BaseServerConfiguration(process.env.DATADOG_API_URL, {}),
}); // reads DD_API_KEY and DD_APP_KEY
const monitors = await new v1.MonitorsApi(datadog).listMonitors();

const slack = new WebClient(process.env.SLACK_BOT_TOKEN, {
  slackApiUrl: process.env.SLACK_API_URL
});
const github = new Octokit({
  auth: process.env.GITHUB_TOKEN,
  baseUrl: process.env.GITHUB_API_URL
});

PagerDuty’s JavaScript client takes the full URL on each call, and its writes need the From header from earlier. In Python:

import os
from slack_sdk import WebClient
from github import Github, Auth
from datadog_api_client import ApiClient, Configuration

slack = WebClient(
    token=os.environ["SLACK_BOT_TOKEN"],
    base_url=os.environ["SLACK_API_URL"].rstrip("/") + "/"
)
github = Github(
    base_url=os.environ["GITHUB_API_URL"].rstrip("/"),
    auth=Auth.Token(os.environ["GITHUB_TOKEN"])
)
# reads DD_API_KEY and DD_APP_KEY
datadog = ApiClient(Configuration(host=os.environ["DATADOG_API_URL"]))

Running it yourself

Put oncall-world.yaml in a new folder. Everything here runs on Node.js 24.

npm install -g @ancha-labs/cli
ancha world up --scene oncall-world.yaml

That gives you a URL and credentials per tool (PAGERDUTY_API_URL, DATADOG_API_URL, SLACK_API_URL, GITHUB_API_URL and the rest) and an MCP URL for each of the four. Wire them into your agent the way it already takes settings, let it finish one run, and get the verdict:

ancha check --env <world id>
ancha world down --env <world id>

To repeat the run three times, each from the seeded state, let Ancha launch the agent:

ancha init --agent "node agent.mjs"
ancha run oncall-world.yaml --local -n 3

Questions

Does PagerDuty have a free account for testing?

Yes, a developer account, which PagerDuty offers free for building apps and integrations. It allows 3 full users and 2 stakeholder users. Its users can’t receive SMS or phone notifications, and it can’t be converted into a paid account.

How long is the Datadog free trial?

Fourteen days, with the whole platform. When it ends you can upgrade or move to the Free tier, which covers up to five Basic hosts with one day of metric retention.

Can a Datadog downtime mute every monitor?

Yes. In the v1 API, a downtime without monitor_id applies to all monitors, and one without end lasts until someone cancels it. In v2, setting monitor_tags to [*] mutes every monitor in the scope.