A Guide to Building Agents with Confirmable Execution Plans

    This article explains how to build an agent that is more than a multi-turn chatbot with randomly invoked APIs. It presents a practical engineering approach for a closed task loop: understand the goal, generate a structured plan, show it for human confirmation, execute only the approved plan, and return results with evidence and logs. The article covers runtime state machines, plan object design, tool integration constraints, retrieval as a planning step, risk-tiered confirmation, when multi-agent designs make sense, a three-stage rollout path, prompt versus orchestration responsibilities, common failure modes, and suitable initial use cases.

    A complete agent is not “a multi-turn chat that randomly calls a few APIs.” It is an explainable, interruptible, and auditable task loop: understand the goal, plan the steps, show the plan to a human, execute after confirmation, and return the results together with their evidence. Many teams get stuck at “the model can talk, but the system cannot act,” or at “tools are called automatically, but no one can be held accountable.” From an engineering perspective, this article breaks the loop into implementable design and delivery practices.

    1. Define What “Complete” Means

    A production-ready agent should have at least five capabilities:

    1. Goal understanding: Convert a natural-language request into an executable goal, and distinguish among casual conversation, retrieval, computation, and write operations.
    2. Plan generation: Produce ordered steps, the tool used in each step, inputs and outputs, and fallback behavior on failure—not just a final answer.
    3. Human confirmation: Pause before any side effect occurs and present the plan in a structured form to the user or approver.
    4. Controlled execution: Invoke tools only according to confirmed steps, constrain parameters with schemas, and make timeouts, retries, and idempotency configurable.
    5. Result closure: Summarize evidence, mark incomplete items, and record logs for review and compliance checks.

    Automatic execution without a confirmation step is suitable for read-only queries. Once an operation involves writing to a database, sending notifications, changing configuration, or generating external files, planning and execution must be split into two states.

    Do not put all logic into a single model call. Explicit states are more reliable:

    • Receive: Validate identity, session, quota, and sensitive words.
    • Clarify: When information is insufficient, ask only for the key missing slots to avoid endless conversation.
    • Plan: The model produces a draft plan, and the orchestration engine performs structural validation.
    • Await confirmation: The front end displays the step list, and the user can reorder steps, delete steps, or reject the plan.
    • Execute: Invoke tools step by step according to the confirmed snapshot. The model must not add write operations during execution.
    • Summarize: Generate conclusions, cite sources, identify failed steps, and suggest manual takeover when needed.
    • End or hand off to a human: Exit the automated path for high-risk, low-confidence, or repeatedly failing tasks.

    State must be persisted. After a page refresh or network interruption, the system should recover from “awaiting confirmation” or “executing” rather than letting the model improvise again.

    3. How to Design the Plan Object

    A plan is a contract between the human and the system. Use a fixed structure instead of free-form prose. An example:

    1. plan_id: unique identifier
    2. goal: one-sentence restatement of the user's goal
    3. assumptions: default assumptions (time zone, data scope, read-only/writable)
    4. steps:
    5. - id, title, tool, args_schema, risk(read/write), needs_confirm
    6. - depends_on: prerequisite steps
    7. stop_conditions: conditions under which to stop
    8. expected_artifacts: tables, summaries, ticket IDs, etc.

    During planning, the model is allowed only to fill in this structure. The orchestration layer is responsible for ensuring that tool names come from an allowlist, parameters pass type and value validation, write operations default to needs_confirm=true, and unregistered tools are prohibited. After confirmation, turn the JSON into an immutable snapshot. The executor consumes only the snapshot, preventing a “show one plan, execute another” mismatch.

    4. Engineering Constraints for Tool Integration

    Tools are the agent’s hands and feet; integration quality determines the upper bound.

    1. Single responsibility: One tool should do one thing, such as “retrieve documents by condition,” “create a draft,” or “send for approval.” Split composite actions so they are easier to confirm and roll back.
    2. Explicit contract: Write inputs, outputs, error codes, idempotency, and side effects into a machine-readable description shared by planning and validation.
    3. Least privilege: Grant tools by role instead of exposing every API to the same agent. Use different credentials for queries and changes.
    4. Timeouts and limits: Set timeouts, retry limits, and rate limits for external calls so that one plan cannot overwhelm downstream systems.
    5. Observability: For each call, record plan_id, step_id, latency, a redacted parameter summary, and result status.
    6. Failure semantics: Distinguish retryable failures (network jitter), human-required failures (insufficient permissions), and plan-change failures (missing prerequisite data). The executor uses this distinction to retry, skip, or return to planning.

    Read-only tools can run automatically in low-risk scenarios. Writes, deletions, and external sends must pass through a confirmation gate. If the business allows “confirm once, execute in batch,” the plan should still state the impact scope and maximum item count.

    5. How Retrieval Fits into Planning Rather Than Replacing It

    A knowledge base is good for answering “what is the evidence?” It is not suitable for acting directly as an executor. A common pattern is to make retrieval a prerequisite step in the plan: first recall policies, contract clauses, or operating manuals, and then decide whether to call a business tool.

    Three practices matter. First, chunks and metadata should support citations, and answers should include document identifiers and passages so users can verify them. Second, set a relevance threshold for retrieval results; when the score is below the threshold, explicitly state that knowledge is insufficient and trigger clarification or human handoff instead of making things up. Third, permission filtering should happen before retrieval so that different departments cannot see each other’s private materials. Retrieval optimization—reranking, query rewriting, hybrid keyword and vector search—can improve hit rate, but it does not change the principle of “no write operation without evidence.”

    6. Confirmation Experience and Risk Tiers

    Confirmation is not an extra button click; it is risk control.

    • Low risk: Pure queries and internal drafts. The plan may be shown and then continued by default, while still allowing cancellation.
    • Medium risk: Generating external text or modifying one’s own draft. Step-by-step or one-time confirmation is acceptable, but the fields to be written must be shown.
    • High risk: Funds, permissions, production configuration, and batch notifications. Require step-by-step confirmation, and when necessary, dual approval, with the approver recorded in the audit log.

    The interface should show the user the restated goal, the step list, whether each step writes data, the expected affected objects, and editable items. If the user changes parameters, the system should revalidate rather than execute the old snapshot directly. The model can explain “why the plan looks this way,” but explanatory text must not override the structured plan.

    7. When Multi-Agent Design Is Actually Necessary

    A single agent with a toolchain can cover most office scenarios. Split into multiple agents only when domain knowledge differs significantly, permission domains must be isolated, or steps can be parallelized with clear dependencies. A typical division is: a “planner” that only produces plans, an “executor” that only runs confirmed steps, and a “reviewer” that checks whether results deviate from the goal and rules.

    Collaboration should use message contracts, not a shared infinite context across multiple models. Each subtask carries its goal, inputs, allowed tools, and completion criteria. The parent process handles task decomposition, timeouts, and conflict merging. Avoid recursive delegation: a sub-agent must not create peer tasks with write permissions unless it returns to the parent process’s confirmation gate.

    8. From Prototype to Runtime Environment

    Rollout can proceed in three stages instead of pursuing an “all-capable” agent at once.

    Stage 1: Prototype. Choose two or three high-frequency read-only scenarios and connect planning, display, confirmation, and single-tool execution. Use a fixed evaluation set to check whether plans are stable and whether steps are missing.

    Stage 2: Business loop. Add knowledge retrieval, draft writing, and failure fallback. Build an evaluation set covering five categories: normal, missing parameters, unauthorized access, tool failure, and user plan modification. Track task completion rate, human takeover rate, and incorrect invocation rate—not just response fluency.

    Stage 3: Runtime. Containerize the orchestration service and model inference, and separate configuration, secrets, and logs. Use object storage for artifacts, message queues for peak shaving, and monitoring and alerting for timeout rates and write-operation failures. Before release, run a canary rollout and limit the tenant scope of writable tools. If you use cloud resources such as Baidu AI Cloud, select them by general capabilities: compute and containers for orchestration, logs and monitoring for audit, and object storage for attachments. Do not hard-code business rules into vendor-specific API semantics. Key rotation, network isolation, and least privilege remain the application’s own responsibilities.

    9. Division of Labor Between Prompts and Orchestration

    Prompts are responsible for role boundaries, when planning must happen first, ensuring output conforms to the plan schema, prohibiting fabricated tool results, and defining how to state insufficient knowledge. Orchestration is responsible for schema validation, state transitions, tool allowlists, confirmation gates, retries, and auditing. Writing security policy only in prompts is insufficient because models occasionally deviate; policy should be enforced on code paths.

    Illustrative execution pseudocode:

    1. plan = validate(model.plan(user_input, tool_catalog))
    2. snapshot = wait_for_user_confirm(plan)
    3. for step in snapshot.steps:
    4. assert step.tool in allowlist
    5. if step.risk == "write" and not snapshot.confirmed:
    6. abort()
    7. result = tools[step.tool].invoke(step.args, timeout, idempotency_key)
    8. persist(step.id, result)
    9. return summarize(results, citations)

    10. Common Failures and Countermeasures

    Plans are too vague: Tighten the schema and require each step to bind to a tool and a success criterion. Tools are called repeatedly: Use idempotency keys and step state. The plan changes after confirmation: Freeze the snapshot during execution; changes must create a new plan and require confirmation again. Answers look plausible but lack evidence: If retrieval misses, prohibit entry into write operations and prompt for additional material. Context is too long and steps are lost: Store plans and intermediate results externally, and send only the fragments needed for the current step to the model. Permission bypass: Re-authorize at the tool layer and do not trust the model’s claim that “the user has agreed.”

    11. Scenarios Worth Prioritizing

    Contract or policy Q&A with internal summary generation, information completion and draft replies for customer support tickets, and data aggregation for weekly reports and inspection reports are all suitable for “plan first, confirm next, execute last.” These scenarios have clear steps, well-defined tool boundaries, and error costs that can be controlled through drafts and human review. In contrast, direct changes to production systems and irreversible batch operations should retain human gates for a long time; the agent should only provide suggestions and pre-checks.

    Conclusion

    Whether you can build a complete agent does not depend on how polished the prompt is. It depends on whether the plan is structured, whether confirmation cannot be bypassed, whether tools follow least privilege, whether failures are recoverable, and whether the process is auditable. Separate planning from execution with a state machine, use knowledge retrieval to provide evidence, use risk tiers to decide the degree of automation, and continuously tighten deviations with evaluation and monitoring. That is how an agent can move from a demo prototype to a reusable business capability.