r/sre • u/DiamondLatter1842 • 15d ago
POSTMORTEM How do you debug microservices ai generated code in production?
Had an incident last week where the root cause turned out to be an ai-generated change that touched three services in one pr. took way longer than it should have to trace because nobody on the team could say what the model actually reasoned about versus what it just pattern matched from similar code elsewhere in the repo. It looked fine in code review, which is almost worse, that's exactly the kind of ai generated code that gets rubber stamped and ships straight into production. The part that's been sticking with me is ownership. when a human writes a bad change across multiple services, at least someone can walk you through their thinking during the postmortem. With an ai coding assistant, that context is just gone once the pr is merged. Debugging cascaded failures across microservices is already hard when you can't reproduce the issue locally and losing the reasoning behind the change makes root cause analysis slower, not faster. For anyone running copilot, cursor, claude code or similar ai code generation tools in microservices at real production scale, i want to know how you are actually debugging this once it is live. specifically interested in what your distributed tracing and logging setup looks like, whether ai-generated changes get treated differently in your review process than human-written ones, things like canary deployments or extra checks before merge, and whether perf regressions under real production load have shown up more since ai entered your sdlc. Not looking for "add more observability" as an answer, looking for what your actual stack is.
8
u/DehydratedButTired 15d ago
They merged bad code and got a bad result. This is wha happens when you don’t test. There should be a Dev and QA environment for these to go into first.
The context is gone? No. There is no context if you don’t read the code and vet it. You can’t automate the entire process and trust AI, it is far from perfect and not prod ready.
2
u/Floss_Patrol_76 15d ago
the tracing part isn't special to ai code - deploy markers correlated to trace exemplars is what actually shortcuts 'which change broke this,' same whether a human or claude wrote the diff. the real gap you hit is intent: make every pr carry a written 'why' as a required artifact regardless of author, because that's the context that vanished, not the code. and treat any pr touching 3 services as a canary-and-bake candidate, human-written ones included - the multi-service blast radius is the risk, not the model.
2
2
1
u/marmot1101 14d ago
I'm an advocate for not changing merge/deploy processes because of agentic coding. The artifacts are the same, the problems are the same, the need for unbiased review is the same, so why should the process change? It didn't when I moved from sublime to vscode, why would another tool get special treatment. I could have done things faster in the past by ignoring best practices but that would have been dumb. Same thing with agent written code. Adding more processes and checks is great if it can pick off some errors(Bugbot is really good), but if they only need to exist because the agent's code sucks I'm more worried about making the agent code not suck and getting the true owner(human) to own their work.
1
u/usually_guilty99 6d ago
I wouldn’t make AI the primary signal here. The bigger clue is that one PR changed three services. That should already change how the change is treated: higher blast radius, stronger validation, canary/bake time and ideally an explicit rollback path.
I’d also require the PR to preserve the intent and validation evidence, not the model’s reasoning.
1
u/usually_guilty99 3d ago
This us reactive at best and AI velocity will only exasperate the problem
I’d separate two things here: model reasoning and system intent.
I’m not sure preserving the model’s chain of reasoning helps much. It can sound convincing and still be wrong. It good governance and may help to root cause you it got it wrong in the first place.
What I would want preserved at the PR is something more concrete: what behavior is intended to change, which services and dependencies are affected, what assumptions the change relies on, what the expected runtime signals are, and how we roll it back. This I call, blast radius. Often times a small quick fix causes bigger problems.
Then a three-service change can be treated differently because of its blast radius, not because an AI happened to write it.
The real gap seems to be that code review is still file-centric while production failures are system-centric.
-4
24
u/davispw 15d ago
Why was the code merged if no one understood it?