AI Agent Architecture: From Instruction Execution to Self-Evolution
This article examines the debate between instruction-driven and self-evolving AI agents, comparing their differences in control flow, state and memory, and tool ecosystems. It also outlines a model gateway approach to avoid vendor lock-in, a five-dimension framework for evaluating route fit, and a phased plan for moving from an observable baseline to built-in governance.
1. The Signal Behind the Hype
A recent open-source agent project gained more than 55,000 stars in two months, adding thousands of stars per day during certain periods and staying near the top of open-source rankings. The numbers matter less than the signal they send: attention around AI agents is shifting from “can it run a demo” to “can it keep growing inside production.”
From an engineering perspective, this reduces to a competition between two routes:
- Instruction-driven route: Developers break a workflow into explicit steps, conditions, and tool calls, and the agent executes them strictly. Behavior is predictable, but migration costs are high.
- Self-evolving route: The agent interacts with its environment, accumulates experience, and builds up skills, gradually reducing reliance on manual orchestration. The ceiling is higher, but it demands more from evaluation, memory, and governance.
This article does not review any specific product. It addresses a general technical question: how to move an agent from “you tell it how to do the work” to “it learns how to do the work,” while staying controllable, observable, and reusable in an enterprise environment.
2. Architectural Differences Between the Two Routes
2.1 Control Flow: Hard-Coded Orchestration vs. Goal-Driven Planning
The instruction-driven route typically relies on a workflow engine or state machine, where nodes, branches, and retry policies are fixed at design time. Its strength is determinism, which suits stable processes such as fixed-format data extraction and standardized approval flows.
In the self-evolving route, control flow is generated by the model at runtime: given a goal and constraints, the model decomposes subtasks, selects tools, evaluates results, and decides the next step. Engineering practice usually introduces three layers:
- Planning layer: breaks high-level goals into executable subgoals;
- Execution layer: calls tools, reads and writes data, and interacts with external systems;
- Reflection layer: validates execution results and falls back or switches paths on failure.
Illustrative pseudocode:
while not goal_reached(step_budget):plan = planner.propose(context, constraints)result = executor.run(plan) # isolate tool calls and side effectscritique = reflector.review(result) # validate results and identify risksmemory.write(plan, result, critique) # persist experiencecontext = context.update(critique)
2.2 State and Memory: Stateless Calls vs. Accumulated Experience
In the instruction-driven route, state is mostly held by external systems, and the agent itself is close to a stateless service. The self-evolving route must solve how experience gets reused, usually across three layers:
- Short-term memory: context and intermediate results for the current task;
- Long-term memory: user preferences, project conventions, and past conclusions across sessions;
- Skill accumulation: abstracting successful solution paths into reusable capabilities rather than one-off scripts.
The most common mistake here is treating memory as dumping logs into the context. Usable memory requires retrieval strategies, conflict resolution, and expiration or eviction mechanisms; otherwise the context balloons quickly and fills with noise.
2.3 Tool Ecosystem: Piling Up Tools vs. Discoverability and Composability
Shipping many built-in tools and skills can significantly lower cold-start costs, but a growing tool count creates selection difficulty and raises the risk of wrong calls. Mature designs usually include:
- Standardized tool descriptions: name, purpose, input/output schema, and side-effect level;
- Tiered permissions: read-only, writable, deletable, and able to send externally, granted level by level;
- Composition: wrapping multiple atomic tools into high-level skills expressed in business terms.
3. Model Adaptation: The Engineering Value of Not Locking Into One Vendor
Agent capability is closely tied to the model, but binding a system to a single model introduces cost, availability, and compliance risk. A sounder approach is to abstract a model gateway:
- A unified interface hides differences between models in function calling, structured output, and context length;
- Tiered selection by task: strong reasoning models for planning, low-cost models for bulk extraction, locally deployed models for sensitive data;
- Support for canary releases and fallback, with automatic downgrade to a backup channel when a model misbehaves.
On Baidu AI Cloud, this kind of requirement is typically served by general capabilities such as model services, container platforms, logging services, and monitoring and alerting, with a unified gateway handling routing, rate limiting, and observability instead of scattering vendor interfaces across business code.
4. A Practical Evaluation Framework: Five Dimensions for Route Fit
- Task determinism: If steps are fixed and results are easy to verify, prefer the instruction-driven route; if goals are open-ended and paths vary, consider self-evolution.
- Cost of errors: For irreversible operations involving money, deletion, or external sending, keep human confirmation and rollback points.
- Observability: Are planning traces, tool call chains, tokens, and latency recorded? Can a complete decision be replayed?
- Evolution cost: Does adding a business scenario mean changing configuration or changing code? Can skills be reused rather than rewritten?
- Governance boundaries: Are data classification, masking, audit trails, and least privilege built in?
5. Phased Implementation Advice
Phase 1: A runnable baseline. Use a minimal tool set to close the loop of goal, execution, and validation. Secure success rate and observability first; do not chase tool count.
Phase 2: Introduce memory and skill accumulation. Turn frequent successful paths into skills, establish retrieval and eviction policies, and keep context size under control.
Phase 3: Multiple models and canary rollout. Use the model gateway for tiered selection and automatic downgrade, and build a dashboard for cost, latency, and success rate.
Phase 4: Governance by design. Require approval and two-person review for high-risk tools, audit the full chain, and run red-team adversarial testing regularly.
6. Conclusion
Star growth is only surface appearance. The real dividing line is whether an agent can keep accumulating useful experience in production while remaining controllable and auditable. Instruction-driven and self-evolving approaches are not mutually exclusive: orchestration guarantees determinism for stable processes, while autonomous planning buys headroom for open-ended tasks, with both connected through a shared tool layer, memory layer, and model gateway. For developers, the lowest-risk path with the most certain payoff is to first establish an observable closed loop, then gradually loosen autonomy.
