最新资讯
www.infoq.com Yelp 为 AI Assistant 融合原生与服务器驱动 UI computerworld.com Box 发布 Architect:用自然语言构建业务流程工作流 the-decoder.com METR 称 Anthropic 或已在 7 月越过自身 AI 加速预警阈值 towardsdatascience.com 用 Ollama 和 Python 构建你的第一个多工具 AI Agent the-decoder.com Thinking Machines 的 Inkling 2 Small 称霸西方开放权重模型 dev.to 为 CI/CD 构建 AI 质量门禁 dev.to Kakao 发布面向 AI Agent 的决策模型 Kanana-2-v-decide computerworld.com Microsoft 对 Copilot Chat 企业用户扩大未公开的使用限制 pub.towardsai.net Google 发布 Gemini 4 Carbon:主打网络安全能力的前沿模型 gradientflow.com METR 研究:AI 正在加速构建 AI 的团队本身 www.infoq.com GitLab 19.5 将 Agentic 开发纳入 DevOps 平台的治理体系 aiacceleratorinstitute.com 研究:AI Agent 的复杂流程编排可能反而是问题所在
多元动态
登录 注册
智能体 dev.to · @Jonas Gauffin

为什么我不再给 coding agent 直接套用现成框架

原文 我的收藏

作者称其项目 UI 代码多由 coding agent 编写,底层改用自研 Web Component 库 @relax.js/core(含路由、表单、模板、DI,无虚拟 DOM)。他指出 agent 对 Vue/Angular 首稿通常正确,但对自研库首稿常出错,会沿用 React 习惯,例如把 connectedCallback 标为 async、额外添加 submit 监听。核心论点是 agent 无法打开浏览器,只能读文件、grep、跑类型检查和测试,因此框架调度器层面的运行时 bug(watch 晚一 tick、computed 未重算、zone 外更新、ngOnInit 假设 @Input 已到)对它不可见,容易在错误位置做看似合理的修改;显式更新代码(如 this.nameSpan.textContent = user.name)则更易被 agent 和评审者验证。

AI推荐理由 作者以自身经验说明:coding agent 对 Vue/Angular 等训练数据充足的框架首稿通常正确,但对自研 Web Component 库 @relax.js/core 首稿常出错,会沿用 React 习惯(如把 connectedCallback 标为 async、额外加 submit 监听);并指出 agent 无法打开浏览器,只能读文件、grep、跑类型检查和测试,因此框架调度器层面的运行时 bug(watch 延迟一 tick、computed 未重算、zone 外更新、ngOnInit 假设 @Input 已到)对 agent 不可见,容易产生看似合理但位置错误的修改。这是关于 agent 编码局限性的具体经验观察,对开发工具有参考价值,但属个人博客观点,无量化证据,且为系列文章开篇,结论尚不完整。

62

正文

I have shipped SPAs in Vue and in Angular. Today most of the UI code in my projects is written by a coding agent, and the library underneath is one I wrote myself: @relax.js/core, a small Web Component library with routing, forms, templates and DI, and no virtual DOM. That is a strange choice on paper. This series is about why it works, where it does not, and what I had to build to make it work. The case against me An agent has seen millions of Vue components and Angular modules in training. Its first draft of a Vue SFC is usually right. Its first draft of a Relaxjs component is usually wrong :O It carries habits over. It marks connectedCallback as async and expects the browser to wait. It reaches for a reactive store. It adds its own submit listener next to the one the library already owns. The core skill that ships with the library opens with this sentence, because it is the failure mode: Patterns carried over from React compile, type-check and do nothing. I have not written React myself, but I have watched agents write it unprompted, and it is what they reach for when nobody tells them otherwise. There is a second point against me. Angular's compiler type-checks templates. vue-tsc does the same for Vue SFCs. A typo in a template is a build error before anything runs. In a library where the template is a string, {{user.naem}} is just a string until the page renders. I will come back to that in a later article, because it bothered me enough to fix. So: worse priors, and until recently weaker static checking. Why bother? What an agent actually has An agent cannot open a browser. It reads files, greps for names, runs the type checker and runs the tests. That is the whole feedback loop. Anything that is only observable at runtime is invisible to it. Now think about the bugs I spent the most time on in Vue and Angular, the ones that survived review: A watch that fired one tick later than I thought, so the DOM showed the previous value. A computed that never recalculated because the dependency was read behind a condition. Change detection that did not run because the update came from outside the zone. An ngOnInit that assumed an @Input that arrives on the next cycle. None of these are visible in the file where the symptom appears. The cause is in the framework's scheduler, and you find it by opening DevTools, setting a breakpoint and watching. An agent cannot do any of that. It will reason about the file it opened, conclude that the file is correct, and start changing things speculatively. That is the most expensive thing an agent does: producing plausible edits in the wrong place. Explicit code does not have that class of bug. When the update is this.nameSpan.textContent = user.name at the place where user changed, the update is where the change is. A reviewer can verify it by reading. So can an agent. Nothing decides later whether it ran. What helps the agent The usual pitch for a small library is "the whole thing fits in the context window". True, and beside the point. An agent rarely needs to read a framework's source; it needs correct memory of the framework's behaviour, and that memory rots with every major version. The three properties that matter: Failure locality. The bug is in the file that shows the symptom. No scheduler, no dependency graph, no zone. Greppability. A typed event class is one grep away from every producer and every consumer. r-click="save()" in a template is one grep away from save. Agents navigate by search, and a connection that is not a shared literal name is a connection the agent will guess at. Reviewability. The diff says what will happen. Not what the framework will decide to do with it. What I had to build Small and explicit is not enough on its own. Three things turned "an agent can in principle work here" into "an agent does work here": Skills, not docs. The library ships a set of short files an agent loads before it starts, and every sentence in them is something an agent gets wrong from habit. The docs explain how things work; the skills say what you will get wrong. The border between them is stated, and it is worth reading. Silence turned into errors. A template that cannot resolve a path renders an empty string. For a human that is a blank spot on the page; for an agent it is a green test. Every such quiet failure now reports through one error channel, and a test helper turns the channel into assertions. A checker. npx @relax.js/core check resolves every template expression against the TypeScript types at the call site and prints tsc-style lines. That closes most of the gap with Angular's template type-checking, and it does so without a compiler in the build. Then the test seam: mount(), flush(), fakeServer(), mountRouting(). The agent verifies by running vitest, not by asking me to click. When I would still pick the framework If the agent's zero-shot correctness is the whole game, meaning nobody reviews the diff and no skills get loaded, Vue or Angular wins on priors alone. If the app is large with deeply interdependent state, the reactive engine earns its complexity, and I said as much in the library's own README. If you need SSR, there is nothing here for you. For a small-to-medium SPA where a human reads what the agent wrote, I have found the explicit model cheaper every time, and the rest of this series is the evidence. Next: what a skill is and why it is not documentation.

来源报道 · 1 篇 · 以下链接均前往原始媒体

← 返回精选动态 原文

更多内容