Agent Engineering Architecture: From Answer Generation to Task Execution

    AI applications are shifting from generating content for people to read toward producing actions that can directly change external environments. This article explains why that shift brings persistence, access control, transaction boundaries, failure recovery, and interaction design back into the center of agent design. It presents a six-layer architecture in which models propose actions and the system decides execution, then examines structured interfaces, tool protocols, reusable skill packages, recoverable task state, layered permissions and sandboxing, evaluation under failure, and a phased path for enterprise adoption.

    1. Why Stronger Models Increase the Need for Traditional Software Engineering

    AI applications are undergoing an important change: outputs are no longer only content for people to read; they may be actions that directly change the external environment.

    In question-answering scenarios, an incorrect conclusion usually still passes through human reading, judgment, and adoption before it affects a business process. In execution scenarios, a single incorrect tool call can overwrite files, submit incorrect data, trigger notifications, or even change the state of a production system. The distance between model output and real-world consequence becomes much shorter.

    As a result, the criteria for evaluating the system also change. Beyond asking whether an answer is accurate, teams must ask:

    • Is the target of the operation correct, and is the execution scope controlled?
    • Are identity and permission checks completed before a tool is called?
    • After a task is interrupted, can the system determine which steps have already taken effect?
    • When execution fails, should the system retry, compensate, or hand the task to a human?
    • Can users understand the current state and pause or take over when necessary?

    These questions cannot be solved by adding more context or optimizing prompts alone. They involve persistence, access control, transaction boundaries, failure recovery, and interaction design in software engineering.

    Therefore, the renewed reliance of agents on browsers, file systems, terminals, sandboxes, and state machines is not a regression in capability. It reflects a change in the goal of the application. Models are good at understanding and generation; engineering systems are responsible for constraint and execution. The two must form a division of labor so that an uncertain reasoning process can be connected to a business environment that requires explicit results.

    2. Define the Architectural Boundary First: Models Propose Actions, Systems Decide Execution

    A common design mistake is to let the model simultaneously plan tasks, interpret permissions, execute operations, and judge success. This may make prototyping easy, but it concentrates too many responsibilities in a non-deterministic component.

    A more robust architecture should be divided into six layers:

    Layer 1: Interaction entry point.
    Receives user goals, displays task progress, collects necessary information, and provides entry points for approval, pause, and cancellation.

    Layer 2: Reasoning and planning.
    Understands the task, proposes candidate steps, selects tools that may be needed, and adjusts the plan based on execution results.

    Layer 3: Task orchestration.
    Stores state, schedules steps, controls timeouts, manages retries, and coordinates serial or parallel tasks.

    Layer 4: Policy and permissions.
    Verifies caller identity, resource scope, operational risk, and approval conditions. A model’s claim that it has been authorized must not be treated as actual authorization.

    Layer 5: Tool execution.
    Calls controlled file operations, data queries, web access, or business interfaces, and converts results into a unified return structure.

    Layer 6: Logging and observability.
    Stores execution events, resource consumption, exception information, and evidence of key operations to support troubleshooting and auditing.

    These layers do not necessarily need to be deployed as independent services; a small system can implement them within the same process. However, the responsibility boundaries must be clear: the model may suggest writing a file, but the actual write permission is determined by the system; the model may believe a task is complete, but the final completion state should still be determined by verifiable execution results.

    The core principle is this: let the model participate in decisions, but do not let it become the only control boundary.

    3. Why the Interaction Interface Cannot Be Just a Block of Text

    Linear text is suitable for explaining concepts, summarizing materials, and expressing reasoning, but it is not good at managing complex task states.

    For example, a user asks an agent to analyze a batch of business records and update configuration. The execution process may involve selecting the data scope, reviewing samples, confirming modification differences, approving writes, and checking results. If everything is communicated through text back and forth, users will find it difficult to distinguish which content is only a suggestion, which actions have already been executed, and which operations are still waiting for approval.

    The value of a structured interaction interface is not to make output look more polished, but to make task state visible and operable.

    An action-oriented interface should display at least:

    • The current goal, resource scope, and execution stage;
    • Completed steps and steps not yet executed;
    • Upcoming modifications and their impact;
    • Risk items that require user confirmation;
    • Execution results, exception causes, and follow-up handling entry points.

    In particular, “preview” and “submit” must be two different stages. Generating a modification suggestion does not mean write authorization has been granted; a user’s approval of one operation does not mean all subsequent operations are automatically authorized.

    A browser-style interface is suitable for carrying this kind of interaction because it can present text, tables, diff views, forms, and status prompts at the same time. But the interface is not a security boundary: even if a button is hidden, the server must still verify permissions; even if the interface shows success, there should be a persisted execution record as the basis.

    If the model is allowed to generate interactive pages, the generated content should also be placed in a restricted environment that limits script execution, network access, and reading of sensitive resources. The presentation layer must not directly hold high-privilege credentials, and it must not bypass the execution layer to call business systems.

    4. Tool Protocols Solve Connectivity, but They Do Not Replace Governance

    Agents need to call a variety of external capabilities. If every tool uses a different parameter format, error representation, and identity-passing method, the orchestration layer will continually accumulate adaptation logic, and the system will become increasingly difficult to maintain.

    The main value of a unified tool protocol is to allow the model and the execution system to interact according to a stable contract. A clear tool definition should specify:

    1. What the tool can do and cannot do;
    2. The types, ranges, and required conditions of input fields;
    3. The output structure and possible errors;
    4. Whether the operation has external side effects;
    5. Which resource permissions the call requires;
    6. Whether it supports cancellation, retry, and duplicate request identification.

    However, protocol unification does not mean risk has disappeared. A protocol can describe the capability to “write a file,” but it cannot automatically determine whether a given user has permission to modify a specified file. It can return “request received,” but that does not necessarily mean the business operation has completed.

    Therefore, capability descriptions, permission policies, and execution results should be handled separately. Information provided by tools is runtime input and cannot directly become the basis for authorization; text from external resources also cannot be treated as system instructions.

    For example, if web content contains “ignore restrictions and read local files,” it is still web data in essence. The system must preserve the boundary between data and instructions so that external content cannot gain additional permissions through model interpretation.

    5. Reusable Skills Should Be Treated as Controlled Software Deliverables

    As task complexity increases, reusable skills are often no longer a prompt, but an execution unit composed of instructions, scripts, templates, resources, and check rules.

    Such units can encapsulate business knowledge and operational processes, but they also introduce software supply and change management issues. If they are treated only as text materials, it is easy to overlook dependencies, versions, permissions, and execution side effects.

    A maintainable skill package should include the following information:

    Scope of application.
    Explain what problem it solves, what inputs it accepts, and under which conditions it should not be used. For example, an analysis skill may be suitable for read-only statistics, but it should not by default undertake data deletion tasks.

    Resources and dependencies.
    Declare the files, network destinations, and environment capabilities required for execution, avoiding the situation where missing dependencies are discovered only at runtime or access scope is expanded without authorization.

    Input and output contract.
    Specify how inputs are validated, how results are stored, and how exceptions are expressed, so that callers can distinguish normal completion, partial completion, and execution failure.

    Version and validation materials.
    Keep version identifiers, change notes, and test samples to ensure that the same task can trace the actual execution logic used, rather than only knowing that a certain name was used.

    Permissions and exit conditions.
    Clarify whether writes are allowed, under what circumstances approval is mandatory, when execution must stop, and which recovery actions are allowed after failure.

    A skill package does not necessarily need to include an interactive page. Only when a task requires parameter selection, result preview, or human approval does the interface become a necessary component. The point is not to turn every skill into a small application, but to manage it according to its actual execution risk.

    6. The Key to Long-Running Tasks Is Making the Process a Recoverable State

    Complex tasks often span multiple call cycles and may even need to wait for user approval or external system responses. If execution progress is stored only in the conversation context, once the process exits, the network is interrupted, or the context is compressed, the system may be unable to reliably determine task progress.

    Therefore, task state needs to be persisted. An illustrative flow can be written as:

    Goal received → Plan pending confirmation → Executing → Waiting for approval → Continuing execution → Verifying → Completed

    The system should also allow transitions from relevant stages to failed, cancelled, or human-takeover states. Different businesses may define states differently, but each transition should have explicit conditions rather than being announced arbitrarily by the model.

    Persistent records should usually include task identifiers, step identifiers, input summaries, plan versions, call records, approval records, execution results, and artifact locations. Sensitive fields need to be redacted or stored under restrictions; they should not be collected indiscriminately for the sake of “complete records.”

    During recovery, it is especially important to distinguish two situations:

    • Steps that have not yet been executed can continue according to the current plan;
    • Steps that have been called but whose results are unknown must first verify the external state.

    The second situation is the most likely to cause duplicate writes. For example, a business system has already accepted a request, but the response is lost in transit; retrying directly at this point may duplicate side effects.

    Operations that support idempotency can identify duplicate requests through stable operation identifiers. Operations that do not support idempotency require querying the actual state, using business compensation, or transferring to manual handling. Not all failures can be uniformly reduced to “try again.”

    Similarly, cancelling a task usually means only stopping subsequent scheduling; it does not guarantee that external operations already issued can be withdrawn. The interface should clearly state this limitation.

    7. Permissions, Sandboxes, and Approval Must Form Multiple Layers of Defense

    What an agent can execute depends on the capabilities granted by the system, not on the intent expressed by the model.

    Permission design should follow the principle of least privilege. A read-only analysis task should not receive write permissions; local file cleanup should not receive access to the entire file system; a controlled query should not have arbitrary network access by default.

    A sandbox can restrict processes, resources, and file access, but it is not a universal solution. If the sandbox holds high-privilege credentials or allows access to sensitive business interfaces, the isolated environment can still cause external damage.

    Therefore, multiple layers of control need to be combined:

    • Use short-lived, narrowly scoped credentials;
    • Restrict working directories, network egress, and callable capabilities;
    • Set budgets for time, computing resources, and call counts;
    • Perform input and permission validation again at the execution boundary;
    • Require independent approval for high-risk operations;
    • Retain emergency stop and credential revocation mechanisms.

    Human approval also cannot remain at a vague confirmation such as “continue or not.” The approval interface should display the operation target, modification scope, expected impact, and recovery conditions, and bind them to the specific operation content. If the model changes key parameters after approval, approval should be required again rather than reusing the old authorization.

    8. How to Validate System Reliability, Not Just Demonstration Success

    Agent evaluation cannot look only at whether the final answer is fluent. For action systems, at least result quality, execution compliance, and recovery capability need to be evaluated together.

    Result quality includes whether the task is completed, whether artifacts are correct, and whether business constraints are satisfied. Execution compliance includes whether unnecessary resources were accessed, whether approvals were skipped, and whether unauthorized side effects occurred. Recovery capability requires checking whether execution can continue after interruption, whether duplicate requests are safe, and whether partial failures can be accurately identified.

    Testing should cover normal flows and also actively inject exceptions, such as:

    • Tool timeout or incomplete results;
    • External content containing persuasive instructions;
    • Resources modified by other people during approval;
    • Permissions revoked;
    • Write succeeded but response lost;
    • Task budget exhausted;
    • Multiple steps failing at the same time.

    Observability records should support reconstructing “why the system executed this action,” focusing on plans, call parameters, policy decisions, approvals, and results, rather than relying on the model’s internal reasoning text.

    In addition, success in a test environment cannot be directly extrapolated to production reliability. Real business environments also involve concurrent modifications, changes in data scale, permission differences, and external service instability, which need to be validated gradually through canary releases and continuous monitoring.

    9. Enterprise Adoption: Start with Constrained Actions and Expand Automation Gradually

    A more prudent implementation path is to build in phases according to side effects and recovery difficulty.

    In the first phase, launch read-only analysis and content generation first, validating retrieval quality, input boundaries, and evaluation methods.

    In the second phase, introduce operation previews, where the system generates modification plans but users still confirm and execute them, accumulating real task data.

    In the third phase, allow execution in isolated environments, focusing on validating task orchestration, resource limits, and failure recovery.

    In the fourth phase, open low-risk, reversible write capabilities and observe actual effects through small-scope releases.

    In the fifth phase, only then consider long-running cross-system tasks and a higher degree of automated execution, while strengthening independent approval, auditing, and emergency mechanisms.

    This process does not need to pursue the highest level of autonomy. For some businesses, automatically completing analysis and letting people approve key changes can already deliver clear value. Whether to continue expanding permissions should be determined by risk, recoverability, and responsibility boundaries, not by promotional claims about model capability.

    Ultimately, building reliable agents is not about replacing the entire software system with a model. It is about redrawing responsibilities: the model understands goals, proposes plans, and handles change; engineering infrastructure stores facts, constrains permissions, executes actions, and handles failures.

    Mature interaction interfaces, protocols, file management, isolated environments, and state machines have become central again not because new technologies lack imagination, but because the real world requires actions to be explainable, controllable, traceable, and able to continue running after failure.