Building AI Agents on Pretrained LLMs: The Second Wave of Agent Development

    This article explains why agent development is entering a second wave built on top of pretrained large language models. It shows how a pretrained base model provides agents with open-ended understanding, contextual reasoning, and cross-modal perception, then breaks down the four-layer architecture behind a production-ready agent: perception, reasoning, action, and memory. A framework-agnostic pseudocode example illustrates the core agent loop, and the article closes with the real engineering constraints that decide success in production: context management, tool-call reliability, observability, security boundaries, and cost/latency control. Developers will come away with a practical blueprint for turning chat models into agents that reliably deliver results.

    1. When the Floor Rises, the Old Benchmarks Stop Working

    There is a striking claim making the rounds in the industry: the frontier model you are using today is very likely the weakest version it will ever be. It sounds like a paradox, but it reflects a plain engineering reality—the iteration speed of large model capabilities now outpaces the rate at which individuals update their own experience. The impression you formed of a model a few months ago may already have been overturned by a new round of training and alignment.

    Understanding this matters more than memorizing the capability boundaries of any specific version. Developers need to adopt a mindset of “making architectural decisions based on the capability floor rather than the ceiling”: the complex reasoning, multi-step planning, and code generation that look like the ceiling today will very likely become an accessible floor in the next iteration cycle. As a result, the optimal model selection and the most elaborate prompt engineering tend to have a short shelf life, while architecture design around “how to organize models to complete tasks” has a far longer lifespan.

    2. The Second Wave of Agents: Why Now

    Agents are not a new concept. Back when rule engines and reinforcement learning were dominant, researchers already tried to let programs explore, decide, and act autonomously in virtual environments. But that generation of agents shared a common pain point: domain knowledge had to be “fed in” bit by bit through hand-designed features, reward functions, or state spaces. Their transferability was terrible—switch environments and you would essentially rewrite everything.

    What sets this new wave of agent development apart is that it stands on the shoulders of pretrained large models, which bring a kind of “innate intelligence.” During pretraining, a model acquires world knowledge, language regularities, and even basic reasoning patterns from massive corpora. When this general capability is used as the cognitive core of an agent, the agent no longer has to learn from scratch what a map is, what an error message means, or how to read a document. It is like an autonomous driving system that has already internalized most driving common sense through vast real-world road data before it ships: the engineers’ job is simply to fill in the policy for specific scenarios, not to build common sense from zero.

    This is precisely the fundamental dividing line between the second wave and the first. Earlier agents poured their energy into “teaching machines common sense.” Today’s agents direct their energy toward “letting machines that already have common sense complete specific tasks.”

    3. Three Inherent Capabilities from the Pretrained Base

    Using a pretrained large model as an agent’s cognitive core mainly brings three general capabilities that were previously hard to obtain:

    • Open-ended understanding and generalization: The model can read natural-language instructions, unstructured documents, and semi-structured logs, and turn them into executable intent—without a bespoke parser for every input type.
    • Contextual reasoning and planning: Within a limited context, the model can decompose, weigh, and correct multi-step tasks, breaking “one big goal” into “several executable sub-steps.”
    • A foundation for cross-modal perception: As multimodal capabilities become widespread, models can directly understand images, UI screenshots, audio, and other inputs, letting agents “see” in digital and even physical environments.

    It is worth emphasizing that these are broadly accepted industry understandings of the general capability boundaries of large models, not exclusive features of any single product. When choosing a base model, focus on publicly evaluable dimensions such as general reasoning quality, context window capacity, and tool-calling stability.

    4. The Four-Layer Architecture of a Modern Agent

    A deployable agent is typically made up of four layers, none of which can be missing:

    1. Perception: Receives and parses information from the environment, including user instructions, file contents, tool return values, and interface state. In multimodal scenarios, this layer also has to handle image and audio inputs.
    2. Reasoning: The agent’s “brain,” driven by a pretrained large model and responsible for task decomposition, policy selection, and reflection on results. This is the core that determines the agent’s upper bound.
    3. Action: Turns the reasoning layer’s decisions into operations on the external world, typically in the form of “tool calls”—running code, querying data, reading and writing files, issuing network requests, and so on.
    4. Memory: Maintains both short-term context and long-term knowledge. Short-term memory carries the working state of the current session, while long-term memory persists key information through external storage for reuse across turns and tasks.

    The four layers are continuously coupled through an “observe—think—act—observe again” loop, forming a closed loop that can correct itself.

    5. From “Chatting” to “Doing”: A Minimal Viable Agent Loop

    A chat model only performs a single “input—output” mapping, whereas the core of an agent is a continuously looping controller. The following framework-agnostic pseudocode illustrates the running skeleton of an agent:

    1. def run_agent(task: str, tools: dict, model, memory):
    2. # Write the task into short-term memory (context)
    3. memory.append({"role": "system", "content": SYSTEM_PROMPT})
    4. memory.append({"role": "user", "content": task})
    5. for step in range(MAX_STEPS):
    6. # Reasoning layer: the model decides the next step based on current context
    7. decision = model.generate(memory, tools=tools)
    8. if decision.type == "final_answer":
    9. return decision.content # Task complete
    10. elif decision.type == "tool_call":
    11. # Action layer: run the tool and get feedback from the environment
    12. tool = tools[decision.tool_name]
    13. observation = tool.run(**decision.arguments)
    14. # Write the action result back to memory for the next reasoning step
    15. memory.append({"role": "assistant", "content": decision.content})
    16. memory.append({"role": "tool", "content": str(observation)})
    17. return "Reached max steps without converging; needs human intervention or a strategy change"

    What matters in this code is not the syntax but three design points: separation of decision and execution (the model only outputs “which tool to call and what arguments to pass,” while the actual execution is done by controlled code), writing observations back into the context (every step’s environmental feedback enters memory so the next reasoning step is grounded in the latest facts), and controllable step count and termination conditions (to avoid infinite loops and leave room for handling exceptions).

    6. Real Constraints in Production

    Moving the skeleton above into production, the real difficulties lie in engineering constraints rather than model capability:

    • Context management: A model’s context window is finite. Long tasks fill it quickly, so you need to manage memory through summarization and compression, extraction of key information, chunked retrieval, and similar techniques—otherwise early information gets “pushed out” and forgotten. You can also store the full trajectory in external object storage and keep only a distilled summary in the context.
    • Tool-call reliability: Tools are the only outlet through which an agent interacts with the real world, and they are also where failures cluster. Define clear input validation, timeout control, and idempotent semantics for every tool, and return structured error information on failure so the model can understand it and choose to retry or take another path.
    • Observability: An agent is multi-step and non-deterministic, so the success of a single task is hard to reproduce. Log every step’s decision, tool inputs and outputs, elapsed time, and state transitions to a logging service, and set up monitoring and alerting so that when a task fails you can quickly locate whether the problem is that “reasoning went off track” or that “a tool errored.”
    • Permission and security boundaries: When an agent can run code, read and write files, and issue requests, its ability to act is itself an attack surface. Follow the principle of least privilege, require confirmation or sandbox isolation for high-risk operations, and stay alert to content coming from external inputs to prevent the agent from being induced into performing operations beyond its authority.
    • Cost and latency: A multi-step loop means multiple model calls, so cost and latency grow linearly with the number of steps—or even faster. Set reasonable step limits based on task difficulty, and in appropriate scenarios bring in smaller, faster models to handle simple sub-tasks, forming a tiered scheduling scheme.

    7. Conclusion

    The capability of today’s frontier models is at a “historical low point,” and this is both a reminder and an opportunity: it means the floor has been raised while the ceiling has yet to be touched. Agent development is undergoing a paradigm shift from “manually instilling common sense” to “orchestrating capabilities on top of a pretrained base.” For developers, the most valuable thing is not to chase the short-term capability of any specific version, but to build an engineering framework with clear perception–reasoning–action–memory boundaries, manageable context, controllable tools, and an observable process. As the base capability keeps rising, a robust agent architecture can automatically capture the benefits of each model upgrade—and this is precisely the key to genuinely transforming a “chat model” into an agent that delivers results.