Jul 11, 2026

Five Gates Between an AI Agent Demo and Production

A practical review framework for moving LLM agents from happy-path demos to bounded, observable, and reversible production systems, with a Chinese quick-reference section.

A polished AI agent demo can be built in an afternoon. The model handles the happy path, calls one tool, and returns an answer that looks convincing. Production begins when the happy path stops being the only path.

The gap is rarely solved by a longer system prompt. It is closed by making the task bounded, the context inspectable, the tools constrained, the evaluation repeatable, and the whole workflow reversible. The following five gates are a practical review framework for deciding whether an agent is ready to move beyond a demo.

Gate 1: The task has an explicit boundary

An agent needs more than a goal. It needs a contract for what counts as complete, what it must never do, and when it must stop.

Before implementation, write down four things:

  • Success condition: the observable result that proves the task is complete.
  • Allowed actions: the systems, records, files, or APIs the agent may touch.
  • Stop condition: iteration, time, cost, or error thresholds that terminate the loop.
  • Escalation condition: situations that require a person to decide.

“Resolve the customer issue” is not bounded. “Classify the ticket, retrieve the relevant policy, draft a cited reply, and request approval before sending” is bounded. The second version separates reasoning from consequential action and produces artifacts a reviewer can inspect.

A useful test is to remove the model from the description. If a new team member could not tell when the workflow is finished, the agent will not know either.

Gate 2: Context is treated as a controlled data plane

Production agents fail when important information is missing, stale, untrusted, or buried under low-value text. Context should therefore be assembled deliberately rather than accumulated indefinitely.

Separate it into four layers:

  1. Policy: stable rules, permissions, output constraints, and safety boundaries.
  2. Task state: the current objective, completed steps, pending decisions, and budget.
  3. Evidence: retrieved documents, database records, and other sources relevant to the current decision.
  4. Observations: tool results, validation output, and errors produced during execution.

Each layer needs an owner and a retention rule. Policy should be protected from summarization. Task state should remain concise and current. Evidence should carry source and freshness metadata. Observations should be preserved long enough to explain decisions, then compacted when they no longer affect the next step.

This is why context engineering is more than prompt writing. The Chinese deep dive on Agent loops, context engineering, MCP, and prompt-injection boundaries provides a fuller map of these layers.

Gate 3: Every tool is a narrow, auditable contract

Tool access turns a language model from a text generator into an actor. That makes schema design, authorization, and failure behavior more important than the number of tools available.

For every tool, verify:

  • The name and description say both when to call it and when not to call it.
  • Parameters are narrow, typed, and validated outside the model.
  • Credentials grant the minimum permissions required for the task.
  • Read and write operations are distinguishable before execution.
  • Retried operations are idempotent, or carry a unique operation key.
  • High-impact actions require confirmation based on the action, not merely model confidence.
  • The result contains enough structured detail for the next step to verify success.

Do not expose a generic run_command or execute_sql tool when the real workflow needs three constrained operations. A small tool surface lowers selection errors, reduces prompt cost, and makes authorization review possible.

Reusable skills can package multi-step procedures, but they should not hide permissions or remove checkpoints. The practical patterns in AI Agent workflow skills: five reusable structures are most useful when each skill still exposes inputs, evidence, and completion criteria.

Gate 4: Evaluation follows a failure taxonomy

A single “answer quality” score cannot explain why an agent failed. Evaluation should mirror the architecture so that a regression points to a repairable layer.

Track at least these dimensions:

DimensionQuestionEvidence
Task completionDid the workflow satisfy the explicit success condition?Final state and acceptance checks
RetrievalWere the right sources found and ranked?Expected-source recall and relevance labels
GroundingAre important claims supported by retrieved evidence?Citation and entailment review
Tool choiceDid the agent select the correct action at the correct time?Trace comparison against expected actions
ArgumentsWere tool parameters valid and safe?Schema validation and policy checks
RecoveryDid the workflow respond correctly to timeouts, empty results, and partial failure?Fault-injection scenarios
EfficiencyWas the result achieved within latency, token, and cost budgets?Per-step telemetry

Create a small, versioned evaluation set from real tasks and known failures. Run it whenever the model, prompt, retrieval pipeline, tool schema, or orchestration logic changes. Keep adversarial cases separate from ordinary regression cases so a higher average score cannot hide a new safety failure.

RAG evaluation deserves its own decomposition because retrieval and generation fail differently. The guide to moving beyond naive RAG with ingestion, query, reranking, and hybrid strategies is a useful companion when the agent depends on external knowledge.

Gate 5: Operations are observable and reversible

An agent is not production-ready if the team cannot reconstruct what happened after a bad outcome.

At minimum, record a trace identifier, model and prompt version, retrieved source identifiers, tool requests and results, policy decisions, token and latency totals, and the final completion status. Sensitive values should be redacted at collection time rather than after they reach a logging platform.

Reversibility requires design work before deployment:

  • Prefer drafts, previews, and staged writes over immediate side effects.
  • Store the pre-change state for operations that support rollback.
  • Put circuit breakers around repeated errors and unexpected cost growth.
  • Make partial completion visible instead of reporting the entire task as successful.
  • Provide a replay mode that can reproduce reasoning inputs without repeating side effects.

Human review should be risk-based. Reading a public document may need no approval. Sending a message, modifying production data, changing permissions, or spending money should usually cross an explicit confirmation boundary.

A compact release review

Before enabling an agent for real users, ask:

  1. Can we state success, refusal, stop, and escalation conditions in one page?
  2. Can we identify which context influenced every consequential decision?
  3. Can every tool call be schema-validated and permission-checked outside the model?
  4. Do regression tests cover retrieval, generation, tool use, and recovery separately?
  5. Can an operator inspect, interrupt, retry, and roll back the workflow?

If any answer is “no,” the missing work is engineering work, not prompt polish.

中文速查

AI Agent 从 Demo 走向生产,至少要通过五道门:

  • **任务有边界:**明确成功、禁止、停止和人工升级条件。
  • **上下文可治理:**把规则、任务状态、检索证据和工具观察分层管理。
  • **工具有契约:**参数收窄、权限最小化,高风险写操作必须确认。
  • **评测可定位:**分别检查检索、生成、工具选择、参数、恢复和成本。
  • **运行可回滚:**完整留痕,支持中断、重试、故障隔离和副作用回滚。

AI全书的中文系统学习路径按模型基础、Prompt、RAG、Agent/MCP 和生产工程组织相关资料,适合继续向下拆分每一道门。

Editorial note: prepared by the AI Book editorial workflow with AI-assisted drafting and manual review. The framework is intended as an engineering checklist, not a benchmark claim.