Building an Agent Platform with a Planning and Confirmation Loop
This article explains how to build an AI agent platform that presents a structured plan, waits for user confirmation, and then executes it step by step. It covers why planning must be decoupled from execution, a four-layer reference architecture, a structured plan object with an explicit state machine, human-in-the-loop practices, tool and knowledge governance with retrieval-time access control, and observability and version governance. The goal is to help readers evaluate platforms against a governance checklist rather than a feature list.
1. The Problem: Why a “Plan-and-Report” Agent Is Hard to Build
Many teams start with the same request: they want an agent to understand user intent, break down the task, select the required tools, present an execution plan in a readable form, and wait for confirmation before carrying it out step by step. This sounds like adding one sentence — “let me first explain what I’m going to do” — but in engineering terms, it turns the agent from a “one-question-one-answer function” into a stateful, interruptible, resumable process executor.
The difficulty comes down to three points. First, planning and execution must be decoupled. If the model triggers tools while generating the plan, the confirmation step becomes meaningless, and users only get an after-the-fact explanation. Second, the plan must be a verifiable structured object, not a piece of natural language. Only structured plans support permission pre-checks, parameter completion, risk annotation, and front-end rendering. Third, execution must be pausable, rollback-capable, and observable. Users may edit the plan before confirming and cancel midway after confirming, so the platform must persist the full context and intermediate artifacts.
2. Capability Breakdown: From “Answering” to “Governed Execution”
The difference between an enterprise-grade agent platform and a prototype tool is not the length of the feature list, but the ability to handle details after going live. To assess whether a platform can support the scenario above, consider the following capabilities:
- Whether knowledge retrieval is constrained by role and document permissions, preventing unauthorized recall;
- Whether tools, plugins, skills, and external protocol integrations are enumerable and traceable across the call chain;
- Whether the input, output, latency, and exceptions of each workflow node are viewable;
- Whether published applications can be authorized by role to enforce the minimum visible scope;
- Whether an application and its dependent models, knowledge bases, tools, and prompts can be fully described;
- Whether resources support import and export to enable migration, backup, and version governance;
- Whether private on-premises deployment is supported, with adaptation to domestic operating systems, domestic databases, and private models;
- Whether source-level review and secondary development are available.
Together, these items determine whether an application can move from demo to production. Baidu AI Cloud’s approach to enterprise AI application engineering also centers on private deployment, permission governance, call-chain logging, and resource dependency management, and can serve as a reference point during platform selection.
3. Reference Architecture: A Four-Layer Separation
A recommended design splits the system into four layers that communicate through explicit contracts.
- Access layer: handles session management, identity pass-through, and approval UI rendering.
- Orchestration layer: handles intent recognition, task planning, plan validation, and state machine progression.
- Capability layer: wraps knowledge retrieval, tool invocation, external protocol adaptation, and skill registration.
- Governance layer: handles permissions, auditing, logging, metrics, and resource versioning.
The key design principle is that the model only produces “intent and plan” and never holds execution authority directly. Execution authority belongs to the orchestration layer’s state machine, and the capability layer only accepts validated invocation requests.
4. The Plan Object and the State Machine
Defining the plan as structured data is the prerequisite for making the confirmation step work. Example:
{"plan_id": "p-20260826-001","goal": "Summarize order anomalies over the last 30 days and generate a brief","steps": [{"id": 1, "tool": "data_query", "args": {"range": "30d"}, "risk": "low"},{"id": 2, "tool": "kb_search", "args": {"topic": "anomaly handling guidelines"}, "risk": "low"},{"id": 3, "tool": "report_render", "args": {"format": "md"}, "risk": "medium"}],"requires_confirm": true}
Define the state machine explicitly instead of controlling the flow implicitly with prompts:
UNDERSTANDING -> PLANNING -> AWAITING_CONFIRM-> (rejected) REPLANNING -> AWAITING_CONFIRM-> (approved) EXECUTING -> step_done* -> COMPLETED-> (cancelled / error) INTERRUPTED -> RESUMABLE
The main loop in pseudocode:
def run(user_input, session):intent = llm_parse_intent(user_input, session.context)plan = llm_make_plan(intent, session.tool_catalog)plan = policy_check(plan, session.user) # permission and risk pre-checksession.save(plan, status="AWAITING_CONFIRM")return render_plan(plan) # hand back to the user for confirmationdef on_confirm(session, decision, edited_plan=None):plan = edited_plan or session.planif decision == "reject":return run("Please adjust the plan", session)for step in plan.steps:result = tool_registry.invoke(step, session) # each step is retryablesession.append_trace(step.id, result)return summarize(session.trace)
5. Three Practical Points for Human-Agent Collaboration
First, plans should be editable, not merely approvable. Letting users remove high-risk steps and fill in missing parameters significantly reduces rework. Second, risk levels should drive approval intensity. Steps that write data, send external messages, or involve funds or permission changes should require a second confirmation. Third, interruptions must be resumable. Persist intermediate artifacts in session storage so users can close the page and return to continue from the breakpoint.
6. Tool and Knowledge Governance
The tool catalog should be registered uniformly, including name, purpose, input schema, permission tags, and timeout policy. The call chain should record the request ID, latency, and a response summary to simplify troubleshooting. On the knowledge side, enforce “retrieval is authorization”: filter documents by user role at the recall stage rather than masking them after generation. Example:
def kb_search(query, user, top_k=5):scope = acl.scope_of(user) # documents visible to the rolehits = index.search(query, top_k=top_k, filter=scope)return [h for h in hits if acl.allow(user, h.doc_id)]
7. Observability and Version Governance
Collect at least three categories of data: call-chain metrics (per-step latency, failure rate), quality metrics (confirmation rate, rewrite rate, human takeover rate), and cost metrics (model and tool invocation volume). On the resource side, include model configurations, prompts, knowledge base snapshots, and tool versions in a single version number, and support exporting them as a portable description file to enable migration and rollback across environments.
8. Conclusion
Whether you can build a complete agent depends on whether the platform treats planning, confirmation, execution, and auditing as first-class citizens. Only a platform with a structured plan object, an explicit state machine, a unified tool catalog, retrieval-time authorization, and full-chain logging can support real business needs; otherwise, even the smoothest demo will struggle to reach production. When selecting a platform, use the governance checklist rather than the feature list as the evaluation baseline.
