The Pope Bot uses a two-layer architecture that separates interactive event handling from autonomous task execution. This design enables the agent to respond instantly to user requests while offloading intensive work to isolated containers on GitHub Actions.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/stephengpope/thepopebot/llms.txt
Use this file to discover all available pages before exploring further.
System Overview
The framework consists of two primary layers:- Event Handler - Next.js application for webhooks, chat interfaces, and job orchestration
- Docker Agent - Isolated containers running Pi or Claude Code for autonomous task execution
Architecture Diagram
Job Lifecycle
When a job is created (via web chat, Telegram, webhook, or cron), it flows through the following stages:1. Event Handler Creates Job
The Event Handler receives a job request and:- Generates a UUID for the job
- Creates a descriptive title using the LLM (structured output prevents token leaks)
- Builds
job.config.jsoncontaining job metadata, title, description, and optional LLM overrides - Creates a
job/{uuid}branch via GitHub API - Pushes the config file to
logs/{uuid}/job.config.json
2. GitHub Actions Triggers Workflow
Branch creation triggers.github/workflows/run-job.yml:
- Detects
job/*branch pattern - Reads thepopebot version from
package-lock.json - Reads job config for LLM/agent overrides
- Collects
AGENT_*secrets (protected from LLM) - Collects
AGENT_LLM_*secrets (accessible to LLM for skills) - Selects Docker image based on agent backend (Pi or Claude Code)
3. Docker Agent Executes Task
The container clones the job branch and executes the task autonomously (see Docker Agent for details).4. Agent Creates Pull Request
After completing the task:- Commits all changes to the job branch
- Commits session logs to
logs/{uuid}/ - Captures log commit SHA for permalink
- Removes logs from the branch (prevents merging session data into main)
- Creates a PR with a permalink to the log commit
5. Auto-Merge and Notification
Two workflows run after PR creation:auto-merge.yml - Checks merge policy:
- Validates
AUTO_MERGEis enabled - Checks modified files against
ALLOWED_PATHSconfiguration - Squash merges if all checks pass
notify-pr-complete.yml (after merge) or notify-job-failed.yml (on failure):
- Gathers job data (title, logs, PR number)
- Sends notification to event handler via
/api/github/webhook - Event handler delivers notification through original channel (web chat, Telegram, etc.)
File Structure
After runningnpx thepopebot init, your project has this structure:
All core logic lives in the
thepopebot NPM package. Your project contains only configuration files and thin Next.js wiring.GitHub Actions Workflows
| Workflow | Trigger | Purpose |
|---|---|---|
run-job.yml | job/* branch created | Runs Docker agent container |
auto-merge.yml | PR opened from job/* | Checks merge policy and auto-merges |
notify-pr-complete.yml | After auto-merge.yml | Sends success notification |
notify-job-failed.yml | run-job.yml fails | Sends failure notification |
build-image.yml | Push to main (docker changes) | Builds and pushes Docker image |
rebuild-event-handler.yml | Push to main | Rebuilds Next.js in container |
Why This Architecture?
The repository IS the agent
The repository IS the agent
Every action your agent takes is a git commit. You can see exactly what it did, when, and why. If it makes a mistake, revert it. Want to clone your agent? Fork the repo β code, personality, scheduled jobs, and full history all go with your fork.
Free compute, built in
Free compute, built in
Every GitHub account comes with free cloud computing time (2,000 minutes/month on free tier, 3,000 on Pro). The Pope Bot uses GitHub Actions to run your agent jobs, so youβre using compute you already have.
Self-evolving
Self-evolving
The agent modifies its own code through pull requests. Every change is auditable, every change is reversible. You stay in control through the auto-merge policy and path restrictions.
Isolation and security
Isolation and security
Job containers are ephemeral and isolated. Protected secrets (like your GitHub token) are filtered from the agentβs bash environment. Each job runs in a clean environment with no persistent state.
Next Steps
Event Handler
Deep dive into the Event Handler layer: API routes, chat interfaces, and job orchestration
Docker Agent
Learn how jobs execute in isolated containers with Pi or Claude Code
Skills System
Extend your agent with custom skills and tools