Inspiration
Inspiration
Every developer has the same story: production breaks, someone gets paged, the next hour disappears into logs, codes and debugging. Yes, tools that help humans debug faster already exist but what didn't...was an engineer that simply wasn't human.
The name 4AM is a nod to the worst-case scenario (production breaking when no one's watching), but the agent runs continuously. Every production error becomes a reviewable PR without anyone needing to be paged, prompted, or pulled out of sleep. The dev's role shifts from "debugging in the dark at any hour" to "reviewing fixes in the morning."
What it does
4AM is an autonomous on-call engineer. It:
- Watches production via Dynatrace (DQL queries on error logs)
- Detects new errors as they occur
- Reads relevant source files from your GitHub repo
- Reasons about the root cause using Gemini 3 on Vertex AI
- Files a real pull request with a proposed fix...branch, commit, diff, description, all autonomous
Users sign in with Google, connect their Dynatrace + GitHub credentials once, pick which repos to watch, and then... sleep. By morning, the broken production code has a PR ready for review.
How we built it
- Frontend: Next.js 15 (App Router) + TypeScript, deployed on Vercel
- Auth & DB: Supabase (Postgres) with Row-Level Security for multi-tenant isolation
- Agent: Python 3.11+ async loop using Google's
google-genaiSDK - AI: Gemini 3 Pro (
gemini-3.1-pro-preview) on Vertex AI, regionglobal - Observability: Dynatrace MCP server — DQL queries for production logs
- GitHub: PyGithub for reading source files + filing PRs
- OAuth: GitHub OAuth App, Google OAuth via Supabase
Architecture: Each user's credentials live in Supabase, protected by Row-Level Security. The agent fetches credentials per-user, spins up a Dynatrace MCP session with that user's tenant, queries errors filtered by service name, then iterates: reads code from their GitHub, reasons with Gemini 3, decides whether to file a PR. The ReAct loop typically completes in 2-4 turns.
Three real PRs were filed by our agent during development — all merged via the standard GitHub review flow.
Challenges we ran into
- Multi-tenant MCP: Dynatrace's MCP server needed careful environment scoping per user without leaking credentials between sessions
- Ingestion latency: Dynatrace takes 30-90 seconds to ingest logs, which initially made our agent return "all clear" immediately after triggering a known error
- OAuth across environments: callback URLs differed between localhost dev and Vercel prod, requiring careful configuration
- Tuning the agent's decisions: Gemini 3 needed to know when to keep investigating (read another file, query more errors) vs when it had enough context to file a PR vs when there was genuinely nothing wrong. Early versions either filed half-baked PRs or got stuck in investigation loops. Solved through iterative system prompt design.
Accomplishments we're proud of
- Three real PRs filed autonomously by the agent on our demo repo, all merged
- End-to-end multi-tenant SaaS working in under two weeks, with brand identity built alongside the engineering
- Real partner integrations not mocked. Dynatrace MCP, Gemini 3 on Vertex AI, GitHub API all live in the loop
What we learned
- ReAct loops are clean when scoped well, a few well-chosen tools beat verbose prompts
- Dynatrace's MCP server is production-grade and saved us writing a custom DQL client
- Gemini 3's JSON mode for tool calling is reliable. The model returns structured calls cleanly, every time.
- Multi-tenant credential isolation needs to be designed in from day one, bolting it on later would have been painful
What's next for 4AM
- Streaming agent runs in the dashboard...see fixes happen in real time
- Parameterized DQL per repo (currently the service name filter is fixed)
- GitLab integration for teams using GitLab
- Slack and email notifications when a PR is filed
- A "scan now" button for ad-hoc runs
- Self-merging mode for trusted fix patterns
Built With
- dynatrace
- gemini
- github-api
- google-cloud
- mcp
- nextjs
- postgresql
- python
- supabase
- typescript
- vercel
- vertex-ai
Log in or sign up for Devpost to join the conversation.