我用零编程经验,构建了一个 2.2 万行代码的应用程序。或者,如何控制智能体

2作者: JasonGravy3 个月前
目前,“氛围编码”备受追捧(也备受争议)。这很正常。通过放松身心,指挥人工智能代理为你编写代码,从而完全构建软件的想法令人兴奋,但大多数尝试这样做的人在短短几天后就面临着残酷的现实:AI 代码腐烂。一开始它能运行。然后它就失败了。而且你根本不知道如何修复它。 我决定开发一个应用程序:一个复杂的晚餐安排引擎。它导入食谱 URL,并输出日程安排、购物清单,以及我在经营周末晚餐俱乐部 15 年后总结的许多关于为大型团体提供餐饮的技巧。 该项目的核心是导入 URL 并将(通常写得很糟糕的)步骤分解成机器可理解的单元,这些单元可以被计时并重建为流畅的日程安排。我被不止一次地告知这“不可能”。每个食谱都是一个例外!如果想要 100% 的合规性,他们可能是对的。但这永远不会发生(除非你为 NASA 工作)。问题始终是:多好才算够好?什么时候一个应用程序才有用?或者,更准确地说,我愿意让机器告诉我多少次羊腿在技术上是一种热饮,我才会拿起锤子? 显然,我不知道读取人类食谱并提取多个指标有多难。我早期就失败了;我的脚手架在成千上万个 if/then 语句的重压下崩溃了。但在我发现一个名为“compromise”的模块后,我又试了一次,该模块使用神经语言学来理解词性。它可以被训练来识别“烤、盐、蒸、撒粉或磨皮”是动词还是名词。它知道指令听起来是什么样的,而不是建议。它非常有用。我要感谢 Spencer Kelly(GitHub 上的 spencermountain)的工作。没有它,我不可能完成我的工作。 关于人工智能代理有多么有趣的一点;“有趣”是指我真的笑了。在与一个难以解决的语言问题进行了长时间的讨论后,一个代理对我说:“看起来我们遇到了一个加州旅馆的情况!你的句子可以入住,但你的短语永远无法离开。”这到底是从哪里来的? 当一个项目达到一定规模时,人工智能就会开始严重地产生幻觉,将数学与你的 UI 组件纠缠在一起,并生成意大利面条代码。一个 LLM 会自然而然地选择阻力最小的路径来修复一个即时错误,逐渐将你的代码库变成一个完全无法调试的“上帝对象”。 除了三十年前自学的一些非常基本的 C+ 知识外,我没有任何编码背景,但我指挥自主代理构建了一个 22,000 多行、数学上复杂的有向无环图(DAG)调度引擎。我没有通过学习如何编码来做到这一点;我通过学习如何管理人工智能来做到这一点。 为什么要管理?人工智能不是非常出色吗?是的,也不是。你可以提取的知识是无限的。它是一个事实和设施的源泉,但……它可能笨得像狗屎一样。让我们用一个比喻。你建了一栋房子。完美。你有一些可爱的盆栽月桂树装饰着你的前门。“嗯,”你说,“那棵植物需要放在门廊左边一英寸的地方。”所以建筑工人用他的靴子推了一下花盆。而人工智能……它把植物放在原地,然后开始拆房子!他们只看到眼前的东西。你必须努力策划他们的“语境”。 或者正如一个代理刚刚报告的那样:“你的批评在架构上是正确的。我们正在处理下游的症状,而不是截肢上游的根本原因。我提出下游修复的原因是:在我的严格的“最小更改/保守架构”约束下,我选择了阻力最小的数学路径——直接修补计算器以处理混乱的数据。”我希望我们能够调整代理的先验——他们硬编码的态度。与直觉相反,他们会乐于帮助你约束他们混乱的行为。问一个代理如何使其表现良好,它会欣然为你编写一本规则手册。
查看原文
There’s a lot of hype (and hate!) right now around &quot;Vibe Coding&quot;. And rightly so. The idea that you can build out software entirely by kicking back and commanding AI agents to do the typing for you is an incredibly exciting concept, but most people trying this are hitting a brutal reality after just a few days: AI Code Rot. First it works. Then it fails. And you have no idea how to fix it. I decided to build an app: a complex dinner scheduling engine. It imports recipe URLs and outputs schedules, shopping lists, and a host of tips for feeding big groups that I’ve developed after 15 years of running a weekend supper club. Central to the project was importing URLs and breaking down (often badly written) steps into machine-understandable units which could be timed and rebuilt into slick schedules. I was told more than once that this would be ‘impossible’. Every recipe is an exception! And they might be right... if you want 100% compliance. But that never happens anyway (unless you’re NASA). The issue is always: how good is good enough? When is an app useful? Or, more accurately, how many times am I willing to let a machine tell me that a leg of lamb is technically a hot beverage before I reach for the hammer? Obviously I had no idea just how hard reading human recipes and extracting multiple metrics would be. I failed badly early on; my scaffolding collapsing under the weight of a thousand if&#x2F;then statements. But I tried again after discovering a module called ‘compromise’ that uses Neuro Linguistics to understand parts of speech. It can be taught when ‘roast, salt, steam, dust or zest’ is a verb or a noun. It know what an instruction sounds like as opposed to a suggestion. It was fantastically useful. I would like to thank Spencer Kelly (spencermountain on GitHub) for his work. I couldn’t have done mine without it. Just a note on how funny AI agents can be; ‘funny’ as in I properly laughed. After a long session with an intractable linguistic problem, an agent said to me “looks like we have a Hotel California situation! Your sentences can check in but your phrases can never leave.” Where the hell did that come from? When a project hits a certain scale, the AI begins heavily hallucinating, tangling math into your UI components, and generating spaghetti code. An LLM will naturally take the path of least resistance to fix an immediate bug, gradually turning your codebase into a completely undebuggable &quot;God Object.&quot; Aside from some self-taught and very basic C+ stuff thirty years ago, I have zero background in coding, yet I commanded autonomous agents to build a 22,000+ line, mathematically complex Directed Acyclic Graph (DAG) scheduling engine. I didn&#x27;t do this by learning how to code; I did this by learning how to manage the AI. Why manage? isn’t AI brilliant? Yes. And no. The knowledge you can extract is literally endless. It is a font of facts and facilities but… it can be dumb as doodoo. Let’s do a metaphor. You build a house. Perfect. You have some delightful potted laurel plants framing your front door. “Hmm,” you say “that plant needs to be an inch to the left of the porch.” So the builder pushes the pot with his boot. The AI on the other hand... it leaves the plant where it is and starts demolishing the house! They only see what’s in front of them. You have to work hard to curate their ‘context’. Or as an agent just reported: “Your critique is architecturally correct. We are treating a symptom downstream instead of amputating the root cause upstream. Why I proposed the downstream fix: Under my strict &quot;Minimal Change &#x2F; Conservative Architect&quot; constraints, I opted for the path of least mathematical resistance—patching the calculator directly to handle the messy data.&quot; I wish we could adjust the agent&#x27;s priors - their hard coded attitudes. Counter-intuitively they will happily help you constrain their chaotic behaviour. Ask an agent how to make it behave and it will gleefully write you a rule-book.<p>Pt2&gt;&gt;&gt;