From Instructions to Execution: An Engineering Guide to Conversational AI Agents

    This article breaks down the engineering architecture behind task-executing conversational AI agents, moving beyond text-based Q&A to reliable state changes. It covers a five-layer execution pipeline, tool-calling constraints, transaction and compensation design, RAG grounding, multi-format rendering, voice compliance, and a phased rollout strategy for building agents that are safe, reversible, and auditable.

    The original requirement was simple: users do not want to be told what they should do; they want to state something once and have it done. Translated into technical terms, this means upgrading from an information-returning Q&A system to a task-executing agent. This article does not focus on any specific product. Instead, it abstracts a general architecture and its engineering constraints, and discusses how to let a model actually take action safely and reliably.

    1. Problem Definition: From Answers to Actions

    The output boundary of a traditional Q&A system is text. The output boundary of a task-executing agent is state change: an order is created, an event is written to a calendar, a file is generated. This shift introduces three fundamental differences:

    1. Different failure costs. A wrong sentence can be ignored, but a wrong order involves money and irreversible operations.
    2. Different evaluation methods. Text can be evaluated by similarity, but a task can only be evaluated by “whether the user’s true intent was achieved” and “whether it can be rolled back.”
    3. Different security models. Execution requires credentials, credentials imply permissions, and permissions must be minimized and auditable.

    So the engineering focus is no longer “how smart the model is,” but “how controllable the execution pipeline is.”

    2. Reference Architecture: A Five-Layer Pipeline

    1. User natural language
    2. ↓
    3. ① Intent understanding and slot filling (NLU + context completion)
    4. ↓
    5. ② Task planning (Plan: decompose into executable steps / select tools)
    6. ↓
    7. ③ Tool invocation layer (Tool Registry: parameter validation, idempotency, retry, rate limiting)
    8. ↓
    9. ④ Execution and state management (transactions, compensation, rollback, human confirmation)
    10. ↓
    11. ⑤ Result generation and observability (structured receipts, logs, metrics, audit)

    2.1 Intent Understanding and Slot Filling

    Vague expressions need to be mapped to structured semantics: action type, object, time, location, quantity, and constraints. The engineering recommendation is to output a strongly constrained JSON Schema rather than free text, so that downstream validation is straightforward.

    1. {
    2. "action": "book_table",
    3. "slots": {
    4. "time": "2026-08-26T19:00+08:00",
    5. "party_size": 4,
    6. "location": "authorized location",
    7. "preference": ["window seat"]
    8. },
    9. "missing": [],
    10. "confidence": 0.86
    11. }

    Missing slots should trigger a clarifying follow-up question rather than a guessed fill. When confidence falls below a threshold, falling back to a safe scripted response is the cheapest way to control the incident rate.

    2.2 Task Planning and Tool Selection

    A recommended approach is a “limited tool set + explicit declaration”: each tool is described with a uniform structure covering its name, purpose, parameter schema, side-effect level, and required permissions. The model only selects; it does not fabricate. As the number of tools grows, first use semantic retrieval to recall candidate tools, then let the model fill in the parameters. This can significantly reduce wrong invocations.

    2.3 Four Hard Constraints at the Tool Invocation Layer

    • Parameter validation: schema validation plus business-rule validation (for example, whether the time is within business hours).
    • Idempotency design: generate an idempotency key for each execution to avoid duplicate orders caused by network retries.
    • Tiered confirmation: read-only operations execute automatically; operations involving payment, deletion, or external sending require mandatory secondary confirmation.
    • Rate limiting and circuit breaking: enforce quotas per user and per tool, fail fast on anomalies, and fall back.

    2.4 Execution, Transactions, and Compensation

    Cross-system tasks cannot rely on a single database transaction. They should adopt a two-phase “reserve–confirm–cancel” approach or a compensation transaction: lock the resource first, then confirm, and release it if the process fails. All intermediate states must be persisted so that tasks are recoverable and replayable.

    2.5 Result Receipts and Observability

    A receipt should contain both structured fields and a human-readable summary, making it easy for the frontend to render and for users to verify. The pipeline needs logging services, metrics monitoring, and alerting, and it must retain a complete audit trail for high-risk actions.

    3. Knowledge Augmentation: Grounding Answers in Evidence

    When a task needs factual support, use retrieval-augmented generation: document parsing and chunking, vectorization and indexing, hybrid retrieval (keyword + semantic), reranking, and citation backfilling. The key requirement is that answers must carry source snippets, and when nothing matches, the system should clearly say “no supporting evidence was found” instead of smoothly fabricating. This kind of capability is typically carried by a combination of general cloud product categories such as object storage, vector retrieval, and logging and monitoring.

    4. Multi-Format Output: Parse Once, Render Many Ways

    The same source material can be turned into a mind map, a summary, a study guide, quiz questions, memory cards, a slide deck, illustrated notes, or a voice or video script. The engineering approach is to decouple “content understanding” from “format rendering”:

    1. Source material → structured intermediate representation (sections / key points / entities / relations)
    2. → Renderer A: mind map (nodes = concepts, edges = relations)
    3. → Renderer B: quiz (key points → question stem + distractors)
    4. → Renderer C: spoken script (key points → colloquial connectors + duration control)

    When the intermediate representation is stable, adding a new format only requires adding a renderer, so the marginal cost is very low.

    5. Compliance Boundaries for Voice Interaction

    Speech synthesis and speech recognition are general capabilities, but when used for outbound calls they must satisfy the following: clearly inform the other party that the interaction is automated, comply with telecommunications and privacy regulations, retain authorization records, and provide a channel to transfer to a human. “Human-like” designs that avoid disclosure carry compliance and trust risks and are not recommended as a product capability.

    6. Reliability and Cost

    • Evaluation set: accumulate real instruction samples covering four categories of cases—ambiguity, missing parameters, privilege escalation, and adversarial inputs—and run regression on every change.
    • Degradation strategy: when the model is unavailable, fall back to a rule-based flow; when a tool is unavailable, give a clear failure reason.
    • Cost control: use a small model for intent classification and slot filling, and reserve the large model for complex planning; cache repeated requests; run batch tasks during off-peak periods.
    1. Start with a read-only scenario (query, summarization, draft generation) and validate intent accuracy.
    2. Introduce tiered confirmation and idempotency mechanisms, then open up low-risk write operations.
    3. Complete the audit, monitoring, and evaluation loop, and gradually expand the degree of automation.
    4. Build on Baidu AI Cloud with a combination of general capabilities: a container platform to host services, a message queue to decouple long-running tasks, object storage to hold source material, and logging and monitoring to ensure observability.

    The real leap in experience does not come from whether the model can chat better, but from whether the engineering pipeline can turn “one sentence” into a correct execution in a stable, reversible, and auditable way.