Autonomous AI agent that detects API schema drift, patches your client code, and opens a GitHub PR β without human intervention.
π Live Demo: self-heal-api.vercel.app
Third-party APIs (Stripe, Twilio, Shopify) release breaking changes. Your integration breaks at 2am. An engineer spends hours tracking down which field was renamed, finding the right docs, rewriting the mapper, and opening a PR.
SelfHeal-API eliminates that entire loop β automatically.
User pastes error log β OR β Sentry webhook fires automatically
β
Step 1 β Detect β LLM analyzes the log, extracts endpoint + failing field
β
Step 2 β Search β GitHub Code Search locates the broken file and function
β
Step 3 β Crawl β Fetches vendor OpenAPI spec, identifies what changed
β
Step 4 β Patch β Rewrites the broken function with AST-validated code gen
β
Step 5 β PR β Opens a GitHub PR with full explanation + Discord alert
End-to-end in under 60 seconds. Zero human input required.
PR opened and merged autonomously on August 10, 2026:
- Job:
61c02ac4-5385-414e-8bba-95a311d1215c - PR: codewithleo1/selfheal-test-repo/pull/17 β MERGED
- All 5 steps completed with zero human input
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, TailwindCSS |
| Backend | FastAPI, Python 3.12, uvicorn |
| Agent / LLM | Groq API (Llama 3.3 70B), dual-key rotation |
| Database | Supabase (PostgreSQL) |
| Job Queue | Upstash Redis |
| Auth | GitHub OAuth 2.0 |
| Notifications | Discord webhooks |
| Monitoring | Sentry (webhook trigger) |
| CI/CD | GitHub Actions (lint + test on every push) |
| Hosting | Vercel (frontend), Render (backend) |
100% free-tier infrastructure.
βββββββββββββββββββββββ
β Sentry Webhook β β auto-trigger on error
ββββββββββ¬βββββββββββββ
β
Browser (Vercel) β
β HTTPS β
FastAPI Backend (Render) βββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββ
β Agent Pipeline β
β detect β search β crawl β patch β pr β
βββββββββββββββββββββββββββββββββββββββββββββββ
β β β β
Groq API GitHub API Supabase Discord
(LLM) (search + (jobs + (notify)
PR create) logs)
β
Upstash Redis
(job queue)
Parses the raw error log using an LLM prompt. Returns structured JSON: endpoint, HTTP method, failing field, vendor name.
Uses GitHub Code Search API to locate the broken file and function in the repo automatically. Falls back to direct repo file listing if the search index is stale. No manual file path needed.
Fetches the vendor's public OpenAPI spec (Stripe, Twilio, Shopify). Uses jsondiff to compare old vs new schema. LLM summarizes the breaking change in plain English.
Fetches the broken file from the user's GitHub repo. Prompts the LLM to rewrite only the failing function. Validates output with ast.parse() before proceeding.
Creates a new branch selfheal/fix-{timestamp}, pushes the patched file, opens a Pull Request with a structured description explaining what broke and how it was fixed. Fires a Discord notification on success.
Configure SelfHeal-API as a Sentry webhook to trigger healing with zero human input:
URL: https://selfheal-api.onrender.com/api/v1/webhooks/sentry?repo=https://github.com/your-org/your-repo
Events: issue created
When Sentry fires, the agent runs the full 5-step pipeline and opens a PR automatically.
See ARCHITECTURE-DECISIONS.md for the full ADR log. Highlights:
- No LangChain β custom 5-step linear pipeline is simpler, more debuggable, and easier for reviewers to understand
- Groq over OpenAI β free tier with 14,400 req/day; dual-key rotation handles rate limits automatically
- Static analysis only β patched code is never executed server-side;
ast.parse()validates syntax without running anything - GitHub Code Search + fallback β search index can lag on new files; direct contents API listing used as fallback
/api/v1/prefix from day one β zero cost to add now, expensive to retrofit later- Sentry webhook
?repo=query param β simpler than maintaining a DB mapping of Sentry project β repo
See SECURITY.md for the full threat model. Key points:
- GitHub tokens stored server-side only, never returned to the frontend
- Error logs validated via Pydantic before reaching the agent
- No arbitrary code execution β lint and syntax checks only
- CORS restricted to the configured frontend origin
- Sentry webhook signature verified via HMAC-SHA256
- Python 3.12+
- Node.js 18+
uvpackage manager- Supabase account (free)
- Groq API keys (free at console.groq.com)
- GitHub OAuth App
- GitHub classic token with
reposcope
cd backend
uv sync
cp ../.env.example .env
# Fill in your keys in .env
uv run uvicorn app.main:app --reloadcd frontend
npm install
npm run devGROQ_API_KEY_1=
GROQ_API_KEY_2=
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_TOKEN=
SUPABASE_URL=
SUPABASE_SERVICE_KEY=
UPSTASH_REDIS_URL=
UPSTASH_REDIS_TOKEN=
DISCORD_WEBHOOK_URL=
SENTRY_WEBHOOK_SECRET=
FRONTEND_URL=https://self-heal-api.vercel.appcd backend
uv run pytest tests/ -vselfheal-api/
βββ backend/
β βββ app/
β β βββ agent/ # detect.py, search.py, crawl.py, patch.py, pr.py
β β βββ routers/ # jobs.py, github.py, pr_sync.py, webhooks.py
β β βββ notifications/ # discord.py
β β βββ db/ # Supabase client
β β βββ queue/ # Redis worker
β βββ tests/
βββ frontend/
β βββ src/
β βββ pages/ # Landing, Dashboard, NewJob, JobProgress, JobResult
βββ screenshots/ # README screenshots
- Auto file detection β agent searches the repo to find the broken file and function automatically
- Sentry webhook β fully autonomous trigger, zero human input required
- Discord notifications β alert on PR open
- PR status sync β track merged/open/closed on dashboard
- TypeScript support (currently Python only)
- Support for more vendors (Plaid, SendGrid, Twilio)
- Slack webhook option
- Self-serve data deletion / GDPR controls
Built by Suraj



