Examples

Example: a CI failure bot with Vercel Workflow

A durable chat backend that diagnoses failing GitHub Actions runs, built with createDurableGithubAgent, the ci-ops preset, and Vercel Connect.

Build a durable CI failure bot with Vercel Workflow

A chat backend a developer can ask "why did CI fail on PR #128?". The agent inspects the failing workflow run, its jobs, and the combined status, then explains the likely cause, crash-safe across restarts thanks to Vercel Workflow.

Files

import { createDurableGithubAgent } from '@github-tools/sdk/workflow'
import { connectGithubToken } from '@github-tools/sdk/connect'
import { getWritable } from 'workflow'
import type { ModelMessage, UIMessageChunk } from 'ai'

export async function ciFailureBotChat(messages: ModelMessage[]) {
  'use workflow'

  const agent = createDurableGithubAgent({
    model: 'anthropic/claude-sonnet-4.6',
    token: connectGithubToken('github/my-connector', { preset: 'ci-ops' }),
    preset: 'ci-ops',
    additionalInstructions: `
      When asked about a failing run, use listWorkflowRuns and getWorkflowRun to find it,
      then listWorkflowJobs and listCheckRuns to find the failing step.
      Summarize the likely cause in plain language before suggesting a fix.
    `,
  })

  const writable = getWritable<UIMessageChunk>()
  await agent.stream({ messages, writable })
}
.env
# Vercel Connect OIDC token, required by the "github/my-connector" connector.
# vercel link && vercel env pull
VERCEL_OIDC_TOKEN=

Install

pnpm add @github-tools/sdk @vercel/connect workflow @ai-sdk/workflow ai zod

Set up the connector

Create a github/my-connector connector scoped to the repositories this bot monitors, then pull a local OIDC token for development:

Terminal
vercel link
vercel env pull

connectGithubToken mints a fresh, short-lived token on every call rather than a long-lived GITHUB_TOKEN, see Vercel Connect: token provider only. Full connector checklist: Vercel Connect.

Wire the client

Point WorkflowChatTransport at /api/ci-chat, and add a GET reconnect route so long runs survive timeouts, exactly as described in Durable agents with Vercel Workflow.

ci-ops includes triggerWorkflow, cancelWorkflowRun, and rerunWorkflowRun. All three require approval by default. This bot only reads run status, so it never triggers an approval prompt unless you explicitly ask it to re-run a job. Details: Control write safety.

Go further

  • Add a GitHub webhook that calls this workflow automatically whenever a run fails, instead of waiting for someone to ask
  • Combine with the release notes generator so a green CI run on main can trigger a release draft
  • Swap ci-ops for ['ci-ops', 'code-review'] if the bot should also suggest a fix in the PR that broke the build