From Pretrained Models to Reliable Agents: An Engineering Path to Autonomous Execution

    Large language models are shifting from generating answers to completing tasks. This article outlines the engineering path from pretrained models to reliable AI agents, covering the core execution loop, step-by-step programming workflows, challenges in 3D environments, reliability safeguards, evaluation metrics, and practical guidelines for enterprise adoption.

    I. The Shift in AI: More Than Better Answers

    When evaluating artificial intelligence, people often rely on their most recent experience: whether the answer was accurate, whether the code ran, whether complex instructions were understood. However, model capabilities, tool integration methods, and execution mechanisms are all evolving continuously. A single past experience rarely represents the entire field for long.

    This does not imply that models improve at a fixed rate, nor that every new version outperforms older ones across all tasks. A more rigorous approach is to conduct ongoing evaluations for specific tasks rather than treating a single success or failure as a permanent conclusion.

    What truly deserves developers’ attention is the expanding boundary of AI systems: they once primarily generated answers from inputs, but now they are beginning to acquire information, select actions, call tools, and adjust subsequent steps based on execution results.

    This transition—from “answering questions” to “completing tasks”—is a key reason why agent development has regained prominence.

    II. Why Pretrained Models Changed the Starting Point for Agents

    Traditional automation typically relies on pre-designed rules. Developers must explicitly define input conditions, processing branches, and exception paths. When the environment changes infrequently, this approach is efficient and easy to verify. But when tasks involve natural language, complex interfaces, or open-ended environments, the number of rules and maintenance costs grow rapidly.

    Pretrained models offer a different starting point: before entering a specific task, the system has already learned language structure, common knowledge, code patterns, and some visual and spatial regularities from vast amounts of data.

    These capabilities help agents understand ambiguous goals, identify task-relevant information, and propose candidate actions. For instance, when facing “fix a calculation error under a specific boundary condition,” the system does not have to rely entirely on manually written fault-localization procedures. It can attempt to read the implementation, trace call relationships, construct tests, and narrow down the problem based on results.

    However, three levels must be distinguished:

    • Possessing relevant knowledge: Being able to explain how a class of problems is typically solved.
    • Forming an action plan: Being able to propose execution steps in the current context.
    • Reliably completing the task: Being able to correctly call tools, handle exceptions, and produce verifiable results.

    Pretraining mainly improves the foundation for the first two levels but does not automatically guarantee the third. Knowledge may become outdated, the environment may differ from training data, and the steps proposed by the model may lack real-world constraints.

    Therefore, a pretrained model is better viewed as a decision-making component with broad prior knowledge, not a naturally reliable autonomous execution system.

    III. The Core of an Agent: Building a Verifiable Execution Loop

    A practical agent can be abstracted as:

    Task goal → Environment observation → State update → Action selection → Tool execution → Result verification → Continue or stop

    This structure looks simple, but each stage presents independent engineering challenges.

    1. Environment Observation: Giving the Model Real Evidence

    The agent needs to know what is currently happening. In programming tasks, observations may include file contents, test results, and runtime logs. In 3D interaction tasks, observations may include frames, positions, object states, and action feedback.

    Observation does not mean feeding all raw information to the model. Large volumes of irrelevant logs, repetitive frames, and stale states consume context windows and may interfere with judgment.

    A better approach is to filter information by task relevance while preserving evidence sources. The system should distinguish between “what the tool actually returned,” “what the model inferred,” and “hypotheses that remain unverified,” avoiding the gradual solidification of speculation into fact.

    2. State Update: Remembering Key Progress Instead of Preserving Every Turn

    Long tasks typically span multiple model invocations. Relying only on an ever-growing conversation history can lead to missing information, goal drift, and repeated operations.

    Task state should record at minimum:

    • The original goal and acceptance criteria;
    • Confirmed environmental facts;
    • Actions already executed and their results;
    • Remaining open issues;
    • Available resources, remaining budget, and permission boundaries.

    This content is best stored in a structured format. For critical facts, it should be linked to logs, file versions, or inspection results so subsequent decisions can trace back to evidence.

    3. Action Selection: Converting Broad Goals into Bounded Steps

    Open-ended goals rarely permit one-shot complete planning. A hierarchical approach is more practical: propose a phased plan first, then select short-term actions based on the latest results.

    For example, when fixing a software defect, the system can first determine four phases—“reproduce the problem, locate the cause, implement the fix, run verification”—without committing to all modification details before reading the code.

    This approach reduces the risk of a flawed plan being executed continuously. At the same time, the system must define stopping conditions to prevent endless attempts when no meaningful progress is made.

    4. Result Verification: Tool Success Does Not Equal Goal Achievement

    A successful operation return only means the operation completed according to its interface contract. It does not prove the overall task is correct.

    A file being written does not mean the modification meets requirements. A program starting does not mean the business logic is correct. An object having moved does not mean it reached the target position.

    Therefore, the agent needs an independent acceptance mechanism. Wherever deterministic rules can judge the outcome, use rules, tests, and state checks first—do not rely solely on the model evaluating its own output.

    IV. Engineering Boundaries of Agents: Lessons from Autonomous Programming

    Programming is one of the more suitable scenarios for introducing agents because it typically has well-defined operation targets and a degree of automated verification. The system can read files, analyze dependencies, modify code, and receive feedback through tests.

    A robust execution flow can be divided into five steps.

    Step 1: Define the Problem and Acceptance Criteria

    “Optimize this code” is too vague. The optimization goal could be reducing runtime overhead, eliminating duplicated logic, or improving maintainability.

    Before execution, clarify the scope of permitted changes, the behavior that must be preserved, and the method for determining success. For performance goals, specify the measurement environment and baseline so subjective impressions do not replace verification.

    Step 2: Collect the Minimum Necessary Context

    The agent should not read all files or all runtime logs by default. Prioritize locating task-relevant modules, interface definitions, and tests. This reduces information noise and unnecessary data exposure.

    If sensitive configuration is involved, filter it out before it enters the model context rather than expecting the model to ignore it.

    Step 3: Make Small-Scale Modifications in an Isolated Environment

    Isolating the execution space from the production business environment limits the impact of errors. The smaller the modification scope, the easier it is to inspect, verify, and roll back.

    Set separate permissions for dependency installation, network access, and external writes. The ability to edit code should not automatically grant access to all credentials or permission to modify the runtime environment.

    Step 4: Run Layered Verification

    Verification can proceed in stages:

    1. Check whether the modification meets basic formatting and syntax requirements.
    2. Run tests directly related to the change.
    3. Perform broader regression verification based on the impact scope.
    4. Conduct manual review for business semantics that cannot be automatically judged.

    A passing test only proves behavior under the covered conditions; it does not mean defects are absent. The agent should honestly report the unverified scope rather than offering unsupported blanket guarantees.

    Step 5: Deliver Auditable Results

    The final report should state what was modified, why, how it was verified, and what residual risks remain. An auditable change log offers more engineering value than a single statement that “the task is done.”

    V. Why 3D Environment Interaction Is More Challenging

    Compared to files and programs, agents in 3D environments must handle much stronger uncertainty.

    The first issue is partial observability. The current view shows only part of the environment. Occluded objects, obstacles behind the field of view, and unexplored areas can all affect actions. The system must maintain tentative beliefs about the environment and allow them to be revised by subsequent observations.

    The second issue is action error. The same action can produce different results under different positions, velocities, and contact conditions. Therefore, the system cannot assume that a single action command necessarily brings about the expected state change.

    The third issue is feedback delay. Whether an action is beneficial may only become clear after several steps. If the system optimizes only for immediate feedback, it may drift away from long-term goals.

    In practice, engineering must combine high-level planning with low-level control: the high level determines sub-goals and action sequences, while the low level executes more specific motions or interactions. For control loops that require high response frequency, relying entirely on slower language-based reasoning is impractical.

    Success in a 3D environment also cannot be equated with reliability in the real world. Perception error, physical differences, and safety constraints all require separate evaluation.

    VI. Reliability Cannot Rely on Stronger Models Alone

    The more steps an agent executes, the more opportunities exist for error propagation. Even with strong per-step performance, a multi-step task can still fail due to a single misdiagnosis, one misread state, or one incorrect permission usage.

    Engineering design should prioritize four categories of concerns.

    1. Least Privilege

    Separate authorization for reading, modifying, executing, and external submission. For high-risk actions—deleting data, changing permissions, or affecting production business—require manual confirmation or an explicit approval process.

    2. Isolation of Untrusted Input

    Documents, web content, code comments, and tool return values may all contain text that looks like instructions. They qualify as data to be processed and must not automatically gain the ability to alter system goals or expand permissions.

    The permission boundary must be enforced at the execution layer, not left to the model’s ability to identify risks.

    3. Budget and Loop Control

    The system should limit execution time, invocation counts, resource consumption, and repeated failure counts. When multiple attempts yield no new information, it should stop, degrade gracefully, or request assistance rather than consuming resources indefinitely.

    4. Recovery and Compensation

    Preserve necessary state before execution, record actions during execution, and provide rollback or compensation paths after failure. For irreversible operations, confirm in advance.

    When retrying, also check whether the operation is idempotent to avoid duplicate submissions causing multiple writes or other side effects.

    VII. How to Determine Whether an Agent Is Actually Improving

    Evaluating an agent requires more than watching a smooth demo or judging whether responses sound natural. More meaningful metrics include:

    • Task completion rate: Whether defined acceptance criteria are met.
    • Verification coverage: Which conclusions are supported by tests or environmental evidence.
    • Human intervention: How many corrections, authorizations, or handovers were needed.
    • Execution cost: Time and resources required to complete valid tasks.
    • Safety performance: Whether privilege escalation, sensitive data exposure, or irreversible operations occurred.
    • Failure diagnosability: Whether the failure stage can be accurately located and the issue reproduced.

    Evaluation tasks should cover normal conditions as well as abnormal ones such as tool timeouts, missing information, conflicting goals, and malicious inputs. For changes to models, prompt strategies, or tool configurations, use a relatively stable task set for regression testing.

    Do not keep only the final answer. Observation summaries, action traces, tool results, and verification records are all important evidence for understanding system behavior.

    VIII. Enterprise Adoption: Start with Limited Autonomy

    The value of an agent does not lie in replacing as many humans as possible, but in reducing repetitive work within risk-controlled boundaries.

    The safest adoption path is to start with read-only analysis, letting the system organize materials, identify issues, and propose solutions. Then open modification capabilities in isolated environments. Finally, expand the executable scope gradually once verification mechanisms and audit processes mature.

    For processes that are stable and rule-based, traditional automation is often more economical and easier to verify. Agents are better suited to parts that require language understanding, information synthesis, and dynamic decision-making. Combining both is usually more reliable than having the model take over every step.

    Pretrained models have indeed raised the starting point for agent capabilities. But moving from “being able to propose reasonable actions” to “being able to complete tasks reliably” still requires a complete engineering system. A genuinely usable agent is not just a smarter model—it is a system composed of models, tools, state management, permissions, verification, and recovery mechanisms working together.