Live data from Hacker News

AI Agents and the Refactoring That Never Happens

rosenfeld.page

51–60 of 76 posts

Re: AI Agents and the Refactoring That Never Happens

#51

Meanwhile I'm over here refactoring as much as I can from years (or decades) of human-slung code. Turning the mess I either inherited, helped create, or built on top of into something clean and pristine might be my favorite LLM use. Same for personal projects, codebases that evolved over many years when I happened to have time that weren't kept quite as "clean" as I wish that finally been cleaned up. I've always _wan…

[deleted]

Re: AI Agents and the Refactoring That Never Happens

#52

I disagree with the claim that "AI agents don't get lost." What I've observed instead is that they don't experience the sensation of feeling lost. Which is quite different. This summer I spent quite a while using a coding agent to help me untangle a deep and complicated data processing pipeline. It had itself been built by agents, in a remarkably short amount of time. But it had also become clear that it was riddled…

"Confidently wrong" is definitely a standard behavior model for LLMs.

I agree with the other reply that you're likely to get better results if it has some kind of test case to run that's more authoritative than its own reasoning.

Re: AI Agents and the Refactoring That Never Happens

#53
post #26

Earlier quoted context omitted.

> then had a commit made for every minor issue found Interesting choice of words. Not a fix. Not a refactor. A commit.

Not sure what you’re getting at

Test coverage for its own sake is not always a worthwhile goal.

Re: AI Agents and the Refactoring That Never Happens

#54

I disagree with the claim that "AI agents don't get lost." What I've observed instead is that they don't experience the sensation of feeling lost. Which is quite different. This summer I spent quite a while using a coding agent to help me untangle a deep and complicated data processing pipeline. It had itself been built by agents, in a remarkably short amount of time. But it had also become clear that it was riddled…

Yes, I've also noticed a few occasions when Claude would get it wrong, but in most cases it's able to find issues I didn't even consider because of a very deep analysis in a confusing (to humans) code. It detects some rare situations where a defect could exist. This happens when I explicitly ask Opus to review a PR and there's some harness around this ability, but I'm really impressed at how deep their analysis can be and correct as well. Of course, sometimes they're going to fail, but I don't see them getting lost often.

Re: AI Agents and the Refactoring That Never Happens

#55

Meanwhile I'm over here refactoring as much as I can from years (or decades) of human-slung code. Turning the mess I either inherited, helped create, or built on top of into something clean and pristine might be my favorite LLM use. Same for personal projects, codebases that evolved over many years when I happened to have time that weren't kept quite as "clean" as I wish that finally been cleaned up. I've always _wan…

I feel your pain, that's what I've been doing for the past whole week. I'm trying to fix some ancient bugs (there are lots of them in this codebase) but each Claude review detects so many issues that might happen on some rare cases that it takes days until it stops complaining and I can get some peer approval to get the fix merged.

Re: AI Agents and the Refactoring That Never Happens

#56
post #3

> AI agents don’t get lost Thats… not my experience. Like, not at all. They very regularly get lost

Same. Also this article reads like it was written by Sonnet.

I think I used Opus actually. But my prompt was huge, basically the article content. I told Opus what I wanted to approach in the article with all the relevant details I wanted to include and it created the article. Then I reviewed it.

Re: AI Agents and the Refactoring That Never Happens

#57

Earlier quoted context omitted.

Same. Also this article reads like it was written by Sonnet.

I think I used Opus actually. But my prompt was huge, basically the article content. I told Opus what I wanted to approach in the article with all the relevant details I wanted to include and it created the article. Then I reviewed it.

But the part that agents don't get lost is actually part of the prompt, not something Opus wrote on its own. Of course they get lost sometimes but the idea of the article is to explain that agents can often make more sense of tangled code than humans when the bounds are not well defined.

Re: AI Agents and the Refactoring That Never Happens

#58
post #4

> Here’s the problem. AI agents are not bound by human context limits in the same way. An agent can read the tangled function, trace every caller, and make sense of the mess that would have stopped a human cold. It can add the next branch correctly, and the one after that, working confidently inside code that no human on the team fully understands anymore. They're not bound by the same limits but they're still bound…

Yes, of course, they're limited, but it doesn't compare to the limit humans face. We can't hold a lot of context on our minds when investigating a bug when the code is too complex with huge methods, lots of branches, several callers and so on. It doesn't mean agents are perfect but they don't care as much as humans if the code is a mess because they can find logic in mess, we can't.

Re: AI Agents and the Refactoring That Never Happens

#59

> Teams, em dash bla bla bla em dash have quietly bla bla bla. It's not this, it's _that_. I find it hard to read articles where the agentic writing is this obvious. It's a distraction from the message of the text, which I'm sure is worth my time. Is there no way to stop generated writing from sounding like this?

Why believe it's worth your time? Upfront it reads like: > Claude, generate a 500 word blog post about how people don't refactor anymore because of AI. Just send me the prompt!

The prompt was actually huge, containing all the central ideas of the articles in details. I actually found my first prompt in case you're curious:

---

Human contexts are way more limited compared to computers. We can't reason about complex software when they go through many branches with so many implications. It's just too hard for humans to keep track of all interconnected pieces. So humans have historically split the system parts into manageable modules that can be understood in isolation and then we spend some time connecting those parts. That's how we can keep the context reasonable for human understanding.

So, when senior engineers found themselves lost while trying to debug an issue in a complex system they would naturally decide to pause and rewrite or refactoring the confusing piece of the system to make it manageable so developers can easily understand what's going on and review future changes.

Usually a system doesn't start that confusing. But as requirements change developers add additional branches and code until the code is no longer manageable. Sometimes the requirements changed significantly since the code was first written and all we have in the code are exceptions rather than the rule. That's usually when historically senior developers would take the time to rewrite that part of the system so they can reason about it.

But AI agents are not as limited as humans context-wise and they can reason about those confusing (to humans) systems and make sense of it. So they simply keep adding additional branches to the existing mess without ever suggesting a major refactoring like a senior developer would do in those cases, unless there's specific harness to tell agents to act like that.

This article is about bringing this into attention so that developers can policy themselves and keep asking themselves whether it's time for a major refactoring instead of relying on the AI agents and trust them because they no longer understand the code because it's too complex for humans to follow. Can you draft an article focused on this concern?

Re: AI Agents and the Refactoring That Never Happens

#60
post #8

I find the basic premise for low level code quality to be true, in my experience, but counterintuitively I can now police the overall structure and system architecture MUCH more heavily. As ever, no one is willing to allocate time for this, but (with unlimited work tokens) I can parallel path massive cleanup refactors all the time now.

As long as you're working alone, that makes sense. Otherwise, some team will have to review all your refactoring PRs...
Post reply on HN