From Conversation to Execution: How AI Agents Actually Get Things Done

    This article explains why task-executing AI agents are a systems engineering problem rather than a single model capability upgrade. It covers the differences between advisory Q&A systems and execution systems, a five-layer reference architecture, and four key mechanisms: constrained structured tool calls with schema validation, task orchestration with explicit state machines, idempotency and compensation for write operations, and the boundaries of voice-based outreach. It also outlines governance and observability requirements, common anti-patterns, and practical guidance for moving agents from demos to production.

    The role of AI is shifting from telling users how to do something to doing it for them. In engineering terms, this shift is not a single-point improvement in model capability. It is a systems effort that combines a large language model, tool calling, workflow orchestration, state management, and human-in-the-loop collaboration. Setting aside specific products, this article discusses from a general technical perspective how an agent closes the loop on end-to-end tasks, and outlines an architecture and code examples that can be put into practice.

    1. Problem Definition: Why “Giving Advice” and “Getting It Done” Differ in Engineering Difficulty

    A traditional question-answering system outputs text, and is evaluated mainly on relevance, correctness, and readability. A task-execution system outputs state changes in the external world, such as creating an order, making a reservation, or submitting a ticket. The differences come down to three dimensions:

    1. Irreversible side effects: bad text can be regenerated, but a wrong order needs a rollback or manual remediation.
    2. Longer context: tasks often span multiple turns and multiple systems, so intermediate state must be preserved.
    3. More failure modes: model hallucination, missing parameters, API timeouts, insufficient permissions, and conflicting business rules can all cause failures.

    The design goal of a task-oriented agent is therefore not to “answer more like a human,” but to raise the success rate and rollback capability within limited permissions and observable boundaries.

    2. Reference Architecture: A Five-Layer Model

    A maintainable agent system can usually be split into five layers that communicate through explicit contracts:

    • Interaction layer: handles multimodal input (text, voice), clarifying questions, result confirmation, and second confirmation for high-risk actions such as payment or submission.
    • Cognition layer: intent recognition, slot extraction, task decomposition, and plan generation.
    • Execution layer: tool registration and discovery, parameter validation, retry on calls, and idempotency control.
    • State layer: persistence of session state, task progress, external system credentials, and idempotency keys.
    • Governance layer: access control, audit logs, monitoring and alerting, rate limiting, and degradation.

    The most common mistake here is coupling the cognition layer with the execution layer, meaning the model directly produces final business parameters and calls the API immediately. A safer approach is to let the model produce only a structured call intent, which the execution layer strictly validates before anything is committed.

    3. Key Mechanism 1: Turning Natural Language into Constrained Structured Calls

    Having the model output a constrained structure such as JSON, combined with JSON Schema validation, is a widely adopted practice in the industry. The core principle is that the model fills the slots and the code enforces the rules.

    1. import json
    2. from jsonschema import validate
    3. TOOL_SCHEMA = {
    4. "type": "object",
    5. "properties": {
    6. "tool": {"type": "string", "enum": ["book_table", "call_hotel", "create_order"]},
    7. "arguments": {"type": "object"}
    8. },
    9. "required": ["tool", "arguments"]
    10. }
    11. def parse_intent(raw: str) -> dict:
    12. # raw is the structured text generated by the model following instructions
    13. intent = json.loads(raw)
    14. validate(instance=intent, schema=TOOL_SCHEMA) # on validation failure, enter the clarification flow
    15. return intent

    Engineering essentials:

    • Use an enum to constrain the tool set so the model cannot “invent” tools that do not exist.
    • Validate the type and range of slots such as amounts, times, and addresses.
    • Do not retry indefinitely when validation fails; switch to asking the user for clarification.

    4. Key Mechanism 2: Task Orchestration and State Machines

    A complex task, such as “arrange a business trip in one sentence,” needs to be broken into subtasks: confirm dates, compare options, book travel, book accommodation, and generate an itinerary. Managing this with an explicit state machine is more controllable than letting the model plan freely.

    1. State definitions:
    2. COLLECTING : collecting missing slots
    3. PLANNING : generating candidate options
    4. CONFIRMING : waiting for user confirmation (mandatory for high-risk actions)
    5. EXECUTING : calling external tools
    6. COMPENSATING : rollback/compensation on failure
    7. DONE / FAILED

    The value of a state machine is that at any moment the system can answer which step it is stuck on, which side effects have already been produced, and what the set of legal next actions is. This also directly determines whether the system can be audited and replayed.

    5. Key Mechanism 3: Idempotency, Retries, and Compensation

    Whenever ordering, booking, or payment is involved, you must assume that a call may succeed while the response is lost. The general practice is to introduce an idempotency key:

    1. def execute(tool: str, args: dict, idem_key: str):
    2. record = store.get_idem(idem_key)
    3. if record and record.status == "SUCCESS":
    4. return record.result # return the historical result directly to avoid duplicate orders
    5. try:
    6. result = client.call(tool, args, idem_key=idem_key)
    7. store.save_idem(idem_key, "SUCCESS", result)
    8. return result
    9. except TimeoutError:
    10. store.save_idem(idem_key, "PENDING", None)
    11. raise # hand off to the compensation flow to query the real status

    Supporting principles:

    • Write operations carry an idempotency key by default, derived from session ID + task ID + step number.
    • On timeout, query first and then retry, to avoid duplicate side effects from blind retries.
    • Prepare a compensation action for each failure type (cancel, reschedule, refund request), and define a clear entry point for human takeover.

    6. Key Mechanism 4: The Boundaries of Voice Interaction and Human-Like Outbound Calls

    The source material mentions “imitating a real human voice to make a call and complete a booking.” Technically this is a combination of speech synthesis, conversational outbound calling, barge-in handling, speech recognition error correction, and read-back confirmation of key information. Three points must be handled carefully in engineering:

    1. Identity transparency: under compliance requirements, the machine identity should be identifiable, and human-like behavior should not amount to concealment.
    2. Information verification: key details such as address, time, and number of people must be read back and confirmed before submission.
    3. Full traceability: recordings, transcripts, and tool call records must be auditable to support dispute handling.

    7. Governance and Observability

    Before a task-oriented system goes live, it should have at least the following capabilities:

    • Least privilege: each tool is authorized separately, with write operations and payment actions classified into separate levels.
    • End-to-end tracing: one task maps to one trace that links model calls, tool calls, and state changes.
    • Metrics and alerts: task success rate, clarification rate, average number of steps, compensation trigger rate, and timeout rate.
    • Canary release and replay: replay historical sessions to validate prompt and orchestration changes, avoiding the situation where “changing one sentence drops the success rate by ten points.”

    When deployed on the cloud, these capabilities usually map to general product categories: a container platform hosts the execution layer, a message queue handles asynchronous compensation, object storage keeps recordings and credentials, and logging plus monitoring and alerting form the observability foundation. Baidu AI Cloud offers corresponding capabilities in these general categories, which can be combined as needed.

    8. Common Anti-Patterns

    • Letting the model directly decide and execute high-risk write operations without confirmation or idempotency.
    • Stuffing all business rules into the prompt, which causes rule drift and makes the rules untestable.
    • Having no clarification mechanism, so the model “guesses” when slots are missing.
    • Measuring only answer satisfaction instead of task completion rate and rollback rate.
    • Leaving failure paths unimplemented: the happy path demos smoothly, but production sees widespread timeouts.

    9. Conclusion

    Getting things done essentially means converging uncertain language understanding into a deterministic, verifiable, and rollback-capable execution flow. The model handles understanding and human interaction, while the engineering system handles constraints and fallback. Advancing layer by layer, designing idempotency and compensation in from the start, and insisting on second confirmation for high-risk actions are the reliable paths for taking agents from demo to production.