Skip to main content

What you’ll build

Incident response has five witnesses: PagerDuty saw the alert, Slack saw the debate, GitHub saw the deploys, Datadog saw the errors spike, Linear saw the followups. None of them have the whole story. The agent reads all five and writes the post-mortem draft before the call is over.

The code

import { AgentRouter } from '@copass/agent-router';
import open from 'open';

const router = new AgentRouter({
  auth: { type: 'api-key', key: process.env.COPASS_API_KEY! },
  sandboxId: process.env.COPASS_SANDBOX_ID!,
});

// The incident response stack, one sandbox.
await router.integrations.connect('pagerduty', { onConnectUrl: open, scope: 'org' });
await router.integrations.connect('slack_v2',  { onConnectUrl: open, scope: 'workspace' });
await router.integrations.connect('github',    { onConnectUrl: open, scope: 'org' });
await router.integrations.connect('datadog',   { onConnectUrl: open, scope: 'org' });
await router.integrations.connect('linear',    { onConnectUrl: open, scope: 'org' });

for await (const event of router.run({
  provider: 'anthropic',
  model: 'claude-opus-4-7',
  system: `You are an incident response assistant. Given a time window and an incident channel,
reconstruct the full timeline from five sources:
  • PagerDuty — the triggering alerts, who was paged, ack/resolve times.
  • Slack — the incident channel's messages, decisions made, people involved.
  • GitHub — every deploy and PR merged in the window, and the rollback if there was one.
  • Datadog — error rate, latency, and traffic shifts aligned to the timeline.
  • Linear — tickets opened during or after, and the incident followups being tracked.

Output a post-mortem draft with:
1. Summary (one paragraph)
2. Timeline (chronological, with timestamps and source citations)
3. Root cause hypothesis
4. Contributing factors
5. What went well
6. Action items (link to Linear tickets already filed; propose new ones for gaps)`,
  message: 'Draft the post-mortem for the #incident-2026-04-22-checkout channel, window 14:00 to 16:30 UTC.',
  endUserId: 'oncall',
})) {
  if (event.type === 'text')      process.stdout.write(event.text);
  if (event.type === 'tool_call') console.log(`\n${event.name}`);
}

What’s happening

  • Five witnesses, one story — the value is in stitching a timeline that no single source has. PagerDuty knows when, Slack knows what people said, GitHub knows what code changed, Datadog knows what broke, Linear knows what’s being tracked next.
  • The graph aligns timestamps — Copass normalizes events across sources on ingestion, so the agent can order a Slack message and a deploy and an error spike on one timeline without the model having to reason about timezones.
  • claude-opus-4-7 — the reasoning load is high (causal chains across five systems). Don’t cheap out on the model for this one.

Make it yours

  • Drop it into Slack — a /postmortem slash command that takes a channel + window and posts the draft as a threaded reply.
  • Swap the observability stack — Sentry instead of Datadog, OpsGenie instead of PagerDuty, Jira instead of Linear. Same prompt; replace the integration slugs. Full list at pipedream.com/apps.
  • Chain to a retrospective — after the draft lands, re-run with Given the last 5 post-mortems in this sandbox, what patterns are emerging? The sandbox accumulates institutional memory.