Example: a CI failure bot with Vercel Workflow
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 })
}
import { start } from 'workflow/api'
import { ciFailureBotChat } from '../workflows/ci-failure-bot.workflow'
export default defineEventHandler(async (event) => {
const { messages } = await readBody(event)
const run = await start(ciFailureBotChat, [messages])
setHeader(event, 'x-workflow-run-id', run.runId)
return run.readable
})
# 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
npm install @github-tools/sdk @vercel/connect workflow @ai-sdk/workflow ai zod
yarn add @github-tools/sdk @vercel/connect workflow @ai-sdk/workflow ai zod
bun 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:
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-opsfor['ci-ops', 'code-review']if the bot should also suggest a fix in the PR that broke the build
Release notes generator
A standalone AI SDK script that drafts release notes from merged pull requests since the last tag, using the release-manager preset and Vercel Connect.
Issue triage bot
A durable GitHub bot that triages @mentioned issues, classifies them, and labels them, built with Chat SDK, Vercel Workflow, the issue-triage preset, and Vercel Connect.