In this article, we review the Github bot in Background Agents codebase. You will learn:
What is Background Agents?
What is this Github bot?
What is Background Agents?
Background Agents is an open-source background agents coding system.
Features
- Let your whole team ship code. Not just engineers.
- Anyone can start. No configuration required.
- Requests become PRs, not backlogs
- Scale your team without scaling headcount
- Meet agents where you work
- Every session is collaborative
Learn more about Background Agents..
What is a Github bot?
In the Background Agents codebase, there is a coding agent that uses this Github bot. You will find the below comment in the background-agents/packages/github-bot/src/index.ts.
/**
* Open-Inspect GitHub Bot Worker
*
* Cloudflare Worker that handles GitHub webhook events and provides
* automated code review and comment-triggered actions via the coding agent.
*/
So this Github bot does the code review and handles actions triggered via comments on the PR.
In this dispatch handler function, you can see the cases handled:
function dispatchHandler(
env: Env,
log: Logger,
event: string | undefined,
p: Record<string, unknown>,
payload: unknown,
traceId: string
): Promise<HandlerResult> {
switch (event) {
case "pull_request":
if (p.action === "opened") {
return handlePullRequestOpened(env, log, payload as PullRequestOpenedPayload, traceId);
}
if (p.action === "review_requested") {
return handleReviewRequested(env, log, payload as ReviewRequestedPayload, traceId);
}
return Promise.resolve({
outcome: "skipped",
skip_reason: "unsupported_action",
});
case "issue_comment":
if (p.action === "created") {
return handleIssueComment(env, log, payload as IssueCommentPayload, traceId);
}
return Promise.resolve({
outcome: "skipped",
skip_reason: "unsupported_action",
});
case "pull_request_review_comment":
if (p.action === "created") {
return handleReviewComment(env, log, payload as ReviewCommentPayload, traceId);
}
return Promise.resolve({
outcome: "skipped",
skip_reason: "unsupported_action",
});
default:
return Promise.resolve({
outcome: "skipped",
skip_reason: "unsupported_event",
});
}
}
How is Github bot built?
Background agents use Cloudflare Worker to handle GitHub webhook events.
It has these 2 endpoints defined:
app.get("/health", (c) => c.json({ status: "healthy", service: "open-inspect-github-bot" }));
app.post("/webhooks/github", async (c) => {
About me:
Hey, my name is ramunarasinga. Email: ramunarasinga@gmail.com
Tired of AI slop?
I spent 3+ years studying OSS codebases and wrote 350+ articles on what makes them production-grade. I built
Codebase architecture skills, inspired by best OSS projects.

Top comments (0)