12因素代理:优秀大语言模型应用的模式

16作者: dhorthy12 天前原帖
大家好,我是来自HumanLayer(YC F24)的Dex,我已经在构建AI代理方面工作了一段时间。在尝试了各种框架并与许多使用AI的创始人交流后,我注意到一个有趣的现象:大多数进入生产阶段的“AI代理”实际上并没有那么“智能”。最好的那些代理大多只是经过精心设计的软件,在关键点上加入了大型语言模型(LLM)。 因此,我开始记录我在构建生产级AI系统方面的经验。今天,我很高兴分享“12因子代理”。 https://github.com/humanlayer/12-factor-agents 这是一个构建LLM驱动软件的原则集合,足够可靠,可以交给生产客户使用。 我看到许多SaaS开发者试图通过在代理框架上构建全新项目来转向AI,但发现使用现成工具无法达到70-80%的可靠性。那些成功的项目往往是将代理构建中的小型模块化概念整合到现有产品中,而不是从零开始。 受Heroku的12因子应用(https://12factor.net/)的启发,这些原则专注于使LLM应用程序更可靠、可扩展和易于维护的工程实践。即使模型变得越来越强大,这些核心技术仍然会保持其价值。 一些亮点包括: - 因子1:自然语言到工具调用 - 因子2:掌控你的提示 - 因子3:掌控你的上下文窗口 - 因子4:工具只是结构化输出 - 因子5:统一执行和业务状态 - 因子6:通过简单的API实现启动/暂停/恢复 - 因子7:通过工具调用联系人工 - 因子8:掌控你的控制流程 - 因子9:将错误压缩到上下文中 - 因子10:小而专注的代理 - 因子11:在用户所在的地方与他们会面 - 因子12:使你的代理成为无状态的归约器 完整指南详细介绍了每个原则,并提供了示例和可遵循的模式。我看到这些实践在处理真实用户流量的生产系统中表现良好。 我分享这个作为起点——这个领域发展迅速,我预计这些原则会不断演变。我欢迎大家的反馈和贡献,以帮助我们弄清楚“生产级”对AI系统意味着什么。 请查看完整指南:https://github.com/humanlayer/12-factor-agents 特别感谢(GitHub用户)@iantbutler01、@tnm、@hellovai、@stantonk、@balanceiskey、@AdjectiveAllison、@pfbyjy、@a-churchill,以及SF MLOps社区对本指南的早期反馈。
查看原文
Howdy HN - I&#x27;m Dex from HumanLayer (YC F24), and I&#x27;ve been building AI agents for a while. After trying every framework out there and talking to many founders building with AI, I&#x27;ve noticed something interesting: most &quot;AI Agents&quot; that make it to production aren&#x27;t actually that agentic. The best ones are mostly just well-engineered software with LLMs sprinkled in at key points.<p>So I set out to document what I&#x27;ve learned about building production-grade AI systems. Today I&#x27;m excited to share &quot;12 Factor Agents&quot;<p>https:&#x2F;&#x2F;github.com&#x2F;humanlayer&#x2F;12-factor-agents<p>It&#x27;s a set of principles for building LLM-powered software that&#x27;s reliable enough to put in the hands of production customers.<p>I&#x27;ve seen many SaaS builders try to pivot towards AI by building greenfield new projects on agent frameworks, only to find that they couldn&#x27;t get things past the 70-80% reliability bar with out-of-the-box tools. The ones that did succeed tended to take small, modular concepts from agent building, and incorporate them into their existing product, rather than starting from scratch.<p>In the spirit of Heroku&#x27;s 12 Factor Apps (https:&#x2F;&#x2F;12factor.net&#x2F;), these principles focus on the engineering practices that make LLM applications more reliable, scalable, and maintainable. Even as models get exponentially more powerful, these core techniques will remain valuable.<p>Some highlights:<p>- Factor 1: Natural Language to Tool Calls<p>- Factor 2: Own your prompts<p>- Factor 3: Own your context window<p>- Factor 4: Tools are just structured outputs<p>- Factor 5: Unify execution and business state<p>- Factor 6: Launch&#x2F;Pause&#x2F;Resume with simple APIs<p>- Factor 7: Contact humans with tool calls<p>- Factor 8: Own your control flow<p>- Factor 9: Compact errors into context<p>- Factor 10: Small, focused agents<p>- Factor 11: Meet users where they are<p>- Factor 12: Make your agent a stateless reducer<p>The full guide goes into detail on each principle with examples and patterns to follow. I&#x27;ve seen these practices work well in production systems handling real user traffic.<p>I&#x27;m sharing this as a starting point - the field is moving quickly and I expect these principles to evolve. I welcome your feedback and contributions to help figure out what &quot;production grade&quot; means for AI systems.<p>Check out the full guide at https:&#x2F;&#x2F;github.com&#x2F;humanlayer&#x2F;12-factor-agents<p>Special thanks to (github users) @iantbutler01, @tnm, @hellovai, @stantonk, @balanceiskey, @AdjectiveAllison, @pfbyjy, @a-churchill, as well as the SF MLOps community for early feedback on this guide.