AI Agents Can Merge Code - But Should They Deploy to Production?

AI Agents Can Merge Code - But Should They Deploy to Production?

AI Agents Can Merge Code - But Should They Deploy to Production?

Today, when AI can read code, spot bugs, and fix errors on its own, a very human question surfaces: should we let the machine decide? Cole Medin's experience with AI agents shows that you can let agents merge code, but you shouldn't let them deploy to production without oversight.

🧠 Why splitting "merge" and "deploy" matters

Tests and code reviews only check if the code is correct. But when code runs live with real user data, three things can go wrong that tests definitely won't catch:

  • Performance: code runs slow on large datasets
  • Edge cases: interactions with other parts of the system break
  • Business logic: code is technically correct but logically wrong (design flaw)

Example: an agent optimizes a query to run fast on 10,000 test records, but when it runs on 10 million real records, it deadlocks. Or it fixes a bug in microservice A, but makes service B timeout when calling A.

⚙️ How "merge but never auto-deploy" works

LaunchDarkly (Cole's platform of choice) uses Canary Release - a powerful risk-control model:

  1. Agent merges code and runs tests automatically (still the machine)
  2. Merge before deployment - engineer reviews the diff, can comment, but doesn't block
  3. Deploy to canary - only 5% of users get the new version, 95% stay on the old one
  4. Watch for 24-48 hours - if something breaks in that 5%, it's easy to spot; metrics stay normal
  5. Scale gradually - 10%, 25%, then finally 100%

If metrics go bad (error rate, latency, conversion drop), automatically rollback - no engineer needed.

The machine decides "code is OK", but humans decide "safe enough for users to run".

🎯 What this means for you

If you use AI agents for anything (code, email, data processing) where users or money are involved:

  • Separate "doing work" from "executing changes" - agents can do the work, but you control when it affects others
  • Build monitoring - not just "code runs", but "code runs right in production" (latency, errors, revenue impact)
  • Gradual rollout - move from 100% human decision → 100% agent decision gradually, don't jump straight

This pattern applies everywhere. If AI writes emails for you (send 10% first, check feedback before mass send) or writes proposals (AI drafts, you edit before submitting), the same principle works.

⚠️ Common misunderstandings

Myth 1: "Agent merges code means full CI/CD automation" Wrong. Merge ≠ Deploy. Merge means the agent actively edits the codebase (risky), deploy means sending code to users (riskier). Two different things.

Myth 2: "High test coverage = safe to auto-deploy" Wrong. Tests answer "is the logic correct?" (covers ~75% of risk). The other 25% - "does the logic match what users actually need?", "is performance acceptable?", "what unexpected side effects happen?" - only production data can answer.

Myth 3: "Automatic rollback is enough" Wrong. Rollback at best takes 5-10 minutes. If deployment is wrong, 10,000 users already experienced the bug. Prevent with canary is better than cure with rollback.

❓ Frequently asked questions

Q: How long have agents been merging code? For a while now. GitHub Copilot suggestions → developer accepts → commits to main is agents "merging" (machine proposes, human accepts). The new part: agent proposes → agent merges, humans just review diffs instead of blocking. It's scaling based on trust, not new technology.

Q: Does LaunchDarkly have a free tier? Yes, free up to 5 feature flags. Paid plans start at $5/month for more. But the core concept (canary release, gradual rollout) can be done free with AWS Route 53 weighted routing, Kubernetes pod percentages, or even vanilla SQL (version column).

Q: "You merge code 24/7, when should agents only merge?" Agents should merge clear-cut logic first: typo fixes, test updates, running formatter. Humans should merge: business logic changes, breaking API changes, security patches, or anything the agent isn't confident about. After 100 agent merges that are small and correct, you can start letting agents merge slightly riskier changes.

Q: If an agent merges bad code, can the team undo it? Yes. Any merge has git history - easy undo. But undo is already too late if users see the bug (reputation damage). Deploying gradually (canary) is the safeguard between "merge and pray" and "undo after 10k users broke".

Q: What else besides LaunchDarkly does this? Many platforms: CloudFlare Workers routing by percentage, Datadog flags, AWS AppConfig, Vercel preview deployments. The core ability: "choose a subset of users for new code", whether manual or automatic based on metrics.


Bottom line: AI agents doing work is good. AI agents deciding on their own what affects users is risky. Solution: let agents do the work, but control the last step (deployment). Production is not a lab.

#agent #automate #deployment #code #aiagent #testing #canarydeploy #production #launchdarkly

More articles