行业动态
odsc.medium.com ·
@ODSC - Open Data Science
为什么AI代理演示在生产中失败
文章指出AI代理在生产中失败源于持久状态、不可预测输入、外部API、并发、延迟、权限和恢复需求,演示的成功不等于生产可靠性,并举例说明多步骤自主性风险。
AI推荐理由 深入分析AI代理演示与生产环境的差异,指出状态、输入、API等挑战,并给出概率示例,对开发者有实际指导价值。
80
正文
AI代理
行动中的AI代理
代理式AI
AI生产
AI系统
为什么AI代理演示在生产中失败
ODSC - 开放数据科学
4分钟阅读
·
4天前
--
收听
分享
是什么让AI代理在演示中看起来令人印象深刻,但在生产中却不可靠?答案通常不是底层模型能力变弱了。AI代理生产失败的出现是因为生产环境增加了持久状态、不可预测的输入、外部API、并发性、延迟限制、权限和恢复要求,而这些是受控演示可以避免的。
演示证明代理可以完成任务;生产工程必须使这种行为在条件混乱时变得可靠。
演示成功不等于生产可靠性
大多数演示遵循一条顺利路径:已知提示、小型工具集、干净数据和短执行链。生产系统面临格式错误的输入、服务中断、过时数据、变化的模式,以及用户做出设计者未预料到的事情。
多步骤自主性加剧了风险。如果每个独立步骤的成功率为90%,那么一个五步序列端到端成功的概率仅为约59%:0.9^5 = 0.59049。这就是为什么评估单个调用是不够的;团队需要在整个工作流中进行轨迹级评估。
传统软件执行确定性指令。代理系统引入了关于下一步做什么、调用哪个工具以及何时停止的概率性决策。LangGraph记录了递归限制,因为图可能达到最大执行步数而找不到停止条件,包括通过无限循环。1
抢先了解ODSC West日程!👀
查看旧金山(10月27-29日)的精彩内容,包括LLM工程、生成式AI和生产数据科学领域的行业领先专题。
🎟️ 在价格上涨前,限时享受50%折扣!
失败模式1:工具调用在真实API下崩溃
Gorilla背后的研究发现,LLM可能难以生成正确的API参数,并可能幻觉API用法;其基于检索的方法在API文档变化时提高了适应性。ToolLLM和ToolBench同样将跨数千个真实世界API的工具使用视为需要专门训练和评估的能力。
生产失败可能小到类型不匹配:
{
“customer_id”: “1842”,
“refund_amount”: “49.99”
}
如果API期望refund_amount为数值,调用可能在业务任务开始前就失败。健壮的系统应在运行时验证模式,防御性地包装API,限制重试次数,对错误进行分类,并仅检索与当前任务相关的工具,而不是暴露大型静态目录。
失败模式2:上下文和状态随时间漂移
长上下文窗口并不能消除上下文管理问题。“迷失在中间”研究发现,性能可能因相关信息在长上下文中的位置而下降,中间的信息往往使用可靠性较低。代理工作流增加了工具输出、中间状态、先前消息、摘要和交接。
解决方案是结构化状态,而不是无限增长的历史对话。LangGraph将线程范围的检查点与长期存储分开,并使用检查点支持持久性、人工审查、恢复和容错执行。多代理交接也应传递明确的字段、来源、任务状态和约束,而不是假设下一个代理会从原始历史中重建意图。
失败模式3:延迟和成本复合
代理延迟很少来自一次模型调用。一个请求可能需要规划、生成、工具调用、验证、另一次模型调用和重试。每一步都增加网络延迟、令牌使用和另一次失败机会。
模式/模型/工具活动/生产权衡
单次推理:一次模型调用,最低编排开销
工具使用工作流:多次模型和API调用,更好的能力,更高的延迟
反思式多代理工作流:重复规划、工具、批评、重试,最高的控制和成本负担
在规模上,递归代理可能对下游API、数据库和连接池造成压力。因此,团队需要延迟预算、令牌上限、适当的缓存、并发控制、退避策略和硬执行限制。成本应按每个完成的任务来衡量,而不仅仅是每个模型请求。
抢先了解ODSC West日程!👀
查看旧金山(10月27-29日)的精彩内容,包括LLM工程、生成式AI和生产数据科学领域的行业领先专题。
🎟️ 在价格上涨前,限时享受50%折扣!
为生产环境工程化AI代理
实用的解决方案是在概率推理周围放置确定性控制。生产代理不应拥有无限权力来决定其执行路径、重试、权限或完成标准。
有用的控制包括状态图、模式验证、重试限制、超时策略、高风险操作的审批门,以及在不可逆操作之前的评估检查。OpenTelemetry的GenAI指南支持跟踪模型身份、令牌使用和完成原因等属性,为团队提供标准化信号,以检查分布式系统中模型的行为。
团队还应跟踪工具调用准确性、任务完成率、轨迹正确性、步数、循环频率、延迟和人工干预率。这些措施能暴露仅靠端点正常运行时间无法发现的失败。
结论:生产代理是系统工程
AI代理生产失败很少通过找到一个更好的提示来解决。更大的挑战是系统工程:状态隔离、验证的工具执行、有界自主性、故障恢复、可观测性和持续评估。在将代理从原型提升到生产之前,团队应审计状态边界、循环限制、模式验证、权限
控制、跟踪和可衡量的完成标准。
对于技术专业人士,这改变了核心问题,从“模型能做到吗?”变为“系统能在故障条件下可靠、可重复且安全地做到吗?”这是生产级代理最终必须达到的标准。
在ODSC AI West 2026培养生产就绪的AI技能
ODSC AI West 2026将于10月27-29日在旧金山举行。7其议程包括代理式AI和AI工程栈,涵盖LLMOps、AgentOps、可观测性、评估框架、基础设施优化和生产部署架构等领域。8对于超越原型的数据科学家、ML工程师和技术领导者,这些主题直接映射到决定代理能否在生产环境中存活的问题。
探索ODSC AI West 2026的演讲者、技术专题和实践培训。
查看原文(中文正文为 AI 翻译)
AI Agent
Ai Agents In Action
Agentic Ai
Ai Production
Ai System
Why AI Agent Demos Fail in Production
ODSC - Open Data Science
4 min read
·
4 days ago
--
Listen
Share
What makes an AI agent look impressive in a demo but unreliable in production? The answer is usually not that the underlying model became less capable. AI agent production failures emerge because production adds persistent state, unpredictable inputs, external APIs, concurrency, latency constraints, permissions, and recovery requirements that controlled demonstrations can avoid.
A demo proves that an agent can complete a task; production engineering must make that behavior dependable when conditions are messy.
Demo Success Does Not Equal Production Reliability
Most demos follow a happy path: a known prompt, a small toolset, clean data, and a short execution chain. Production systems face malformed inputs, service outages, stale data, changing schemas, and users who do things the designer did not anticipate.
Multi-step autonomy compounds risk. If each independent step succeeds 90% of the time, a five-step sequence succeeds end to end only about 59% of the time: 0.⁹⁵ = 0.59049. That is why evaluating individual calls is not enough; teams need trajectory-level evaluation across the full workflow.
Traditional software executes deterministic instructions. Agentic systems introduce probabilistic decisions about what to do next, which tool to call, and when to stop. LangGraph documents recursion limits because graphs can reach the maximum number of execution steps without finding a stopping condition, including through infinite loops.1
Get a First Look at the ODSC West Schedule! 👀
Check what’s in store for San Francisco (Oct 27–29), featuring industry-leading tracks on LLM engineering, generative AI, and production data science.
🎟️ Claim 50% OFF with this limited-time discount before prices go up!
Failure Mode 1: Tool Calling Breaks Under Real APIs
Research behind Gorilla found that LLMs can struggle to generate correct API arguments and may hallucinate API usage; its retrieval-based approach improved adaptation when API documentation changed. ToolLLM and ToolBench similarly treat tool use across thousands of real-world APIs as a capability requiring specialized training and evaluation.
A production failure may be as small as a type mismatch:
{
“customer_id”: “1842”,
“refund_amount”: “49.99”
}
If the API expects refund_amount as a numeric value, the call may fail before the business task begins. Robust systems should validate schemas at runtime, wrap APIs defensively, cap retries, classify errors, and retrieve only tools relevant to the current task instead of exposing a large static catalog.
Failure Mode 2: Context and State Drift Over Time
Long context windows do not eliminate context-management problems. The Lost in the Middle study found that performance can degrade depending on where relevant information appears in a long context, with information in the middle often used less reliably. Agent workflows add tool outputs, intermediate state, prior messages, summaries, and handoffs.
The answer is structured state rather than endlessly growing conversation history. LangGraph separates thread-scoped checkpoints from longer-term stores and uses checkpoints to support persistence, human review, recovery, and fault-tolerant execution. Multi-agent handoffs should likewise pass explicit fields, provenance, task status, and constraints instead of assuming the next agent will reconstruct intent from raw history.
Failure Mode 3: Latency and Cost Compound
Agent latency rarely comes from one model call. A request may require planning, generation, a tool call, validation, another model call, and a retry. Each step adds network delay, token usage, and another opportunity to fail.
PatternModel/Tool ActivityProduction TradeoffSingle inferenceOne model callLowest orchestration overheadTool-using workflowMultiple model and API callsBetter capability, higher latencyReflective multi-agent workflowRepeated planning, tools, critique, retriesHighest control and cost burden
At scale, recursive agents can pressure downstream APIs, databases, and connection pools. Teams therefore need latency budgets, token ceilings, caching where appropriate, concurrency controls, backoff policies, and hard execution limits. Cost should be measured per completed task, not merely per model request.
Get a First Look at the ODSC West Schedule! 👀
Check what’s in store for San Francisco (Oct 27–29), featuring industry-leading tracks on LLM engineering, generative AI, and production data science.
🎟️ Claim 50% OFF with this limited-time discount before prices go up!
Engineering AI Agents for Production
The practical solution is to put deterministic control around probabilistic reasoning. A production agent should not have unlimited authority to decide its execution path, retries, permissions, or completion criteria.
Useful controls include state graphs, schema validation, retry limits, timeout policies, approval gates for high-risk actions, and evaluation checks before irreversible operations. OpenTelemetry’s GenAI guidance supports tracing attributes such as model identity, token usage, and finish reasons, giving teams standardized signals for examining model behavior inside distributed systems.
Teams should also track tool-call accuracy, task completion, trajectory correctness, step count, loop frequency, latency, and human intervention rates. These measures expose failures that endpoint uptime alone will miss.
Conclusion: Production Agents Are Systems Engineering
AI agent production failures are rarely solved by finding one better prompt. The larger challenge is systems engineering: state isolation, validated tool execution, bounded autonomy, fault recovery, observability, and continuous evaluation. Before promoting an agent from prototype to production, teams should audit state boundaries, loop limits, schema validation, permission controls, tracing, and measurable completion criteria.
For technical professionals, that changes the central question from “Can the model do this?” to “Can the system do this reliably, repeatedly, and safely under failure conditions?” That is the standard production-grade agents ultimately have to meet.
Build Production-Ready AI Skills at ODSC AI West 2026
ODSC AI West 2026 takes place October 27–29 in San Francisco.7 Its programming includes agentic AI and an AI engineering stack that covers areas such as LLMOps, AgentOps, observability, evaluation frameworks, infrastructure optimization, and production deployment architectures.8 For data scientists, ML engineers, and technical leaders moving beyond prototypes, those topics map directly to the problems that determine whether an agent survives contact with production.
Explore the speakers, technical tracks, and hands-on training at ODSC AI West 2026.