Building Production-Ready AI Agents: A Practical Guide to Planning, Confirmation, and Execution

    This article explains how to build a complete AI agent beyond visual workflow orchestration. It breaks down the six capabilities that define a complete agent, proposes a five-layer architecture, and details four core mechanisms: structured plan modeling, plan externalization with human confirmation, tool registration with idempotency, and failure recovery with replanning. It also covers integration with visual orchestration platforms, evaluation and observability practices, common pitfalls, and a phased adoption roadmap.

    1. What Counts as a “Complete” Agent?

    Once visual AI orchestration platforms became common, many teams started asking the same question: can drag-and-drop workflow orchestration alone produce a truly complete agent? To answer this, it helps to break “complete” into a verifiable capability checklist instead of arguing about concepts.

    A complete agent typically needs at least six capabilities:

    1. Perception and understanding: correctly parsing user intent, slots, and constraints;
    2. Planning: decomposing a complex goal into ordered steps and selecting the required tools;
    3. Plan externalization: presenting the plan in a human-readable form;
    4. Human confirmation: adding interruptible confirmation checkpoints before execution, allowing users to modify or reject the plan;
    5. Execution and feedback: calling tools, parsing results, and replanning on failure;
    6. Observability and governance: end-to-end logging, metrics, permissions, and auditing.

    The conclusion up front: a visual orchestration platform can host the skeleton of these capabilities, but production readiness requires adding state management, confirmation mechanisms, idempotency and rollback, and an evaluation system outside the orchestration layer. In other words, the platform solves orchestration and integration, while completeness comes from engineering constraints.

    2. Overall Architecture: Layering Is Key

    Split the system into five layers that communicate through explicit contracts, rather than stuffing all logic into a single workflow.

    • Access layer: session entry points, authentication, rate limiting, and quotas;
    • Orchestration layer: visual workflows plus a small number of custom code nodes;
    • Capability layer: model inference services, vector retrieval, and tool sets (internal APIs, databases, file processing);
    • State layer: persistent storage for session state, plan objects, and execution records;
    • Governance layer: logging, metrics, tracing, evaluation, and alerting.

    The state layer is the easiest to overlook. If plan and confirmation state live only in the conversation context, session rebuilds or concurrent requests will cause lost plans and duplicate executions. Modeling the plan as an independent object is the first cornerstone of completeness.

    3. Core Mechanism 1: The Planner and Plan Object Modeling

    The planner’s job is to turn a goal into a structured plan, not to directly generate natural-language steps. Use schema-constrained structured output with fields for step ID, goal description, candidate tools, dependencies, expected artifacts, and risk level.

    An illustrative structure:

    1. {
    2. "plan_id": "p-20240612-001",
    3. "goal": "Summarize last quarter's contract risks and generate a briefing",
    4. "steps": [
    5. {"id": 1, "action": "retrieve", "tool": "doc_search", "depends_on": [], "risk": "low"},
    6. {"id": 2, "action": "analyze", "tool": "llm_extract", "depends_on": [1], "risk": "low"},
    7. {"id": 3, "action": "write", "tool": "report_gen", "depends_on": [2], "risk": "medium"}
    8. ],
    9. "require_confirmation": true
    10. }

    Engineering essentials:

    • Constrain output: use JSON Schema or an equivalent validator to reject free text; a parse failure triggers one repair retry;
    • Make dependencies explicit: describe topological order with depends_on to enable parallelism and resume-from-checkpoint;
    • Grade risk: the risk field determines whether human confirmation is needed and how strong the approval should be;
    • Version plans: generate a new version when the user edits a plan, preserving an audit trail.

    4. Core Mechanism 2: Plan Externalization and Human Confirmation Nodes

    “Telling the user the execution plan and waiting for confirmation” is the dividing line between a toy agent and a usable one. Model confirmation as an explicit state rather than relying on the model to stop on its own.

    A simplified state machine:

    1. CREATED -> PLANNED -> AWAITING_CONFIRM -> APPROVED -> RUNNING -> DONE
    2. | |
    3. v v
    4. REJECTED FAILED -> REPLAN

    Accompanying pseudocode:

    1. if plan.risk_level in ("medium", "high") or plan.require_confirmation:
    2. state = "AWAITING_CONFIRM"
    3. save(plan, state)
    4. return render_plan(plan) # Output a readable plan and wait for user action
    5. if event.type == "CONFIRM":
    6. plan = load(event.plan_id)
    7. plan.apply_user_edits(event.patch) # Support deleting/replacing steps
    8. state = "APPROVED"

    For interaction design, the plan presentation should include: a restatement of the goal, the step list, the tools and data scope used by each step, expected side effects (database writes, messages, file changes), and entry points for editing and canceling. For high-risk actions, add a second confirmation and operator identity verification.

    5. Core Mechanism 3: Tool Registration, Invocation, and Idempotency

    Tools are the agent’s hands and feet, and their quality sets the ceiling. Build a unified registry that declares each tool’s name, purpose, input/output schema, timeout, retry policy, permission scope, and whether it is idempotent.

    1. TOOLS = {
    2. "doc_search": {"schema": SearchIn, "timeout": 8, "retry": 2, "idempotent": True, "scope": "read"},
    3. "report_gen": {"schema": ReportIn, "timeout": 30, "retry": 1, "idempotent": False, "scope": "write"},
    4. }

    The invocation side must enforce three rules:

    • Idempotency keys: write operations carry a unique request_id, and the server deduplicates to prevent duplicate writes from retries;
    • Least privilege: grant read or write scope per tool, and route write operations through separate credentials;
    • Timeouts and circuit breaking: a single-step failure must not bring down the whole run; structured failure information is fed back to the planner for replanning.

    6. Core Mechanism 4: Failure Recovery, Rollback, and Replanning

    Failures are the norm in real environments. Combine three strategies: single-step retry, step-level compensation, and overall replanning. For irreversible side effects (such as an already-sent notification), mark them in the plan and surface them at the confirmation stage so the user makes an informed decision.

    1. for step in plan.topological_order():
    2. try:
    3. result = run(step, idempotency_key=plan.id + step.id)
    4. except TransientError:
    5. result = run(step, retry=2)
    6. except PermanentError as e:
    7. plan = planner.replan(goal=plan.goal, failed=step, error=e)
    8. return to_confirmation(plan)

    Also record an input summary, output summary, duration, and status for each step, forming a replayable decision chain that makes it easy to determine afterward whether the issue was a planning error, a tool error, or a data problem.

    7. Integrating with Visual Orchestration Platforms

    When implementing on a visual orchestration platform, follow the division of labor: “the platform handles orchestration, code handles constraints.”

    • Use visual nodes for model calls, knowledge retrieval, conditional branching, and message output;
    • Use a small number of code nodes for schema validation, state reads and writes, and idempotency key generation;
    • Use external state storage for plans and execution records, with the platform holding only references;
    • Use environment variables and credential management to isolate model services and tool endpoints across environments.

    This preserves the efficiency of low-barrier orchestration while avoiding critical logic being locked into a graphical interface that is hard to test and review.

    8. Quality Assurance: Evaluation, Observability, and Cost

    Completeness is ultimately proven by evaluation data. Build three layers of evaluation: intent recognition accuracy, plan quality (step redundancy rate, tool selection accuracy), and end-to-end task success rate. Run a regression set after every prompt or model version change.

    For observability, collect at least: session success rate, average number of steps, confirmation wait time, tool failure rate, and per-task token and invocation cost. Set alert thresholds for anomalies, such as a sudden spike in tool failure rate or replanning rate.

    For cost control, use a small model for intent classification and routing, and reserve the large model for planning and complex reasoning; cache retrieval results; and segment and summarize long documents before they enter planning.

    9. Common Pitfalls

    • Treating “can generate steps” as “can execute reliably,” while ignoring idempotency and rollback;
    • Relying on the model to self-regulate confirmation, lacking explicit state and timeout policies;
    • Making plans non-editable, so users can only accept or abandon them wholesale, losing both experience and trust;
    • Tools without schema constraints, patching parse failures with string manipulation, which is fragile and hard to test;
    • Focusing only on build speed while lacking an evaluation set, so iteration relies on guesswork.

    10. Adoption Roadmap

    Phase one: build a minimal closed loop with a single goal, three to five tools, explicit confirmation, and structured logs. Phase two: add robustness with idempotency, retries, compensation, and permission isolation. Phase three: scale with multi-agent division of labor, task queues for peak shaving, automated evaluation, and a cost dashboard. If an organization already uses relevant Baidu AI Cloud capabilities, it can map model services, object storage, message queues, container platforms, and monitoring and alerting to the layers above, keeping interfaces neutral and easy to replace.

    In summary, a visual orchestration platform is enough to build an agent’s skeleton, but “complete” depends on whether you design planning, confirmation, idempotency, recovery, and evaluation as first-class citizens.