Why AI Agents Can Code but Can't Work: Dual-System Decision-Making and Two-Layer Self-Evolution for Faster Deployment and Lower Cost
This article explains why AI agents often perform well on benchmarks yet struggle with real enterprise tasks, and how two technical approaches address the problem. It examines where agent costs actually come from, then breaks down dual-system decision-making (a fast path for routine actions and a slow path for complex reasoning) and two-layer self-evolution (in-task adjustment and cross-task experience reuse). It also covers reducing adaptation costs for physical environments, standardizing interfaces and constraints, and using observability metrics to measure efficiency gains. Readers will find practical engineering guidance, sample code and data structures, and a clear view of what can be reused as methodology.
1. The Starting Point: Why Agents Can Write Code but Can’t Do the Job
The business model of traditional enterprise software can be summed up in one simple equation: high upfront development cost, low adaptation cost per customer. The software is written once and sold to many customers, so the initial investment is continuously amortized.
Generative models and AI coding tools have rewritten that equation. The marginal cost of initial development has dropped sharply, but the cost of adapting a system to truly understand a specific customer’s environment has stayed almost unchanged.
The reason is not mysterious. Enterprise adaptation is fundamentally about making an agent re-identify each customer’s business processes, toolchains, device interfaces, and on-site constraints. Most agents are still confined to “digital workstations” such as browsers and terminals. They perform well on public benchmarks, but the moment they need to control a production line conveyor, read values from an industrial weighing station, or operate a robotic arm for precision assembly, their capability limits are exposed. They need to be taught on-site knowledge all over again, and once taught, they often show a “seven-second memory”: the error made on the 100th run in the same scenario is nearly identical to the one made on the first run.
This creates two problems that must be solved at the same time:
- How to help agents adapt quickly to new tasks and new environments.
- How to turn execution experience into reusable assets.
Two key technical approaches have emerged around these problems: dual-system decision-making and two-layer self-evolution.
2. Rethinking the Cost Structure: Where the Money Actually Goes
To cut costs, you first need to understand the cost distribution. In most agent systems, the largest expense is not model weights or infrastructure, but the large model calls themselves. Many systems are “slow and expensive” not because the model is not capable enough, but because it is too capable and everything is pushed onto it: intent recognition, path planning, parameter assembly, format validation, and exception handling are all handed to the same large model in a single pass.
This “single system does everything” pattern creates three kinds of waste:
- Inference waste: simple, deterministic steps still consume expensive inference resources.
- Context waste: large amounts of background information are stuffed in for safety, linearly driving up input length and cost.
- Repetition waste: similar tasks are reasoned from scratch every time, with historical experience never reused.
So the first principle of cost reduction is not switching to a cheaper model, but restructuring the decision architecture: route tasks of different complexity through paths with different cost levels.
3. Dual-System Decision-Making: Separating “Fast Thinking” from “Slow Thinking”
The core of dual-system decision-making is splitting the decision process into two layers. The fast system handles high-frequency, low-uncertainty, enumerable actions, such as fixed-format queries, field extraction, state reading, and routine validation. It prioritizes low latency and low cost per call. The slow system handles low-frequency, high-uncertainty tasks that require multi-step reasoning and trade-offs, such as anomaly diagnosis, cross-system process orchestration, and strategy replanning after failures.
A simplified scheduling example (logic illustration only, not a specific product API):
def decide(task):if fast_system.can_handle(task):return fast_system.act(task) # low-cost, low-latency pathplan = slow_system.plan(task) # high-cost, reasoning-heavy pathfast_system.learn_from(plan) # push reusable fragments down to the fast systemreturn slow_system.execute(plan)
This structure delivers three direct benefits. First, cost is “diverted” rather than “spread evenly”: the vast majority of requests take the cheap path, significantly lowering the average cost per call. Second, the latency distribution becomes more predictable, so interactive scenarios are no longer slowed down by long reasoning chains. Third, the slow system’s output can be “distilled” into rules, templates, or retrieval snippets for the fast system, creating a positive feedback loop.
Three points need attention in engineering practice:
- Routing decisions must be observable to avoid misclassification that degrades quality.
- The fast system needs clear fallback and escalation conditions.
- Logs from both paths should use a unified format to support later root-cause analysis.
4. Two-Layer Self-Evolution: Moving Experience from Within a Session to Across Sessions
If dual-system decision-making addresses per-call cost, two-layer self-evolution addresses long-term efficiency. The first layer is in-task evolution: during a single task execution, the strategy is adjusted dynamically based on intermediate feedback. For example, if a tool selection fails, the agent immediately switches to an alternative instead of mechanically retrying. The second layer is cross-task evolution: successful trajectories, failure reasons, and constraint clauses are stored in a structured form as a searchable experience library, so the next similar task does not start from zero.
The key to experience accumulation is that it must be “searchable, verifiable, and rollbackable.” Searchable means experience exists as structured entries rather than long natural-language text. Verifiable means each entry carries applicable conditions and a historical success rate. Rollbackable means incorrect experience can be flagged, down-weighted, or deleted, preventing “one mistake, long-term contamination.”
Experience entry structure (illustrative){"scenario": "industrial weighing station reading collection","preconditions": ["device is connected", "range is calibrated"],"steps": ["call the collection API", "perform range validation", "retry once on error"],"success_rate": 0.93,"last_verified": "2024-05-11"}
Only when the experience library has these properties can the system’s 100th run truly outperform the first, instead of repeating the same mistakes.
5. From Digital Workstations to the Physical Field: Where Adaptation Costs Are Really Cut
Another reason adaptation costs remain high is that agents lack the ability to model the physical world. Cutting this “hard bone” requires filling gaps at three levels:
- Interface standardization: abstract device readings, action commands, and state callbacks into unified semantics, reducing the marginal work of re-integrating for each customer.
- Explicit constraints: write safety boundaries, range limits, and cycle-time requirements as machine-readable constraints instead of relying on the model to “guess.”
- Automated validation: build repeatable regression cases for each adaptation to ensure experience reuse does not introduce regression risk.
Once these three levels are in place, adaptation work shifts from “re-teaching every time” to “configuration plus validation,” and the cost curve finally moves down.
6. Observability and Cost Control: Making Efficiency Gains Measurable
Any optimization that cannot be measured cannot be sustained. At minimum, four types of metrics are recommended: average cost per task call, fast-system routing hit rate, experience library reuse rate, and first-attempt task success rate. Combined with general cloud capabilities such as logging services and monitoring alerts, this forms a “measure, attribute, optimize” loop.
It is worth emphasizing that the specific multiples of efficiency improvement and cost reduction depend heavily on the scenario, task distribution, and engineering maturity, and should not be treated as a universal promise. What is truly reusable is the methodology: layered decision-making, structured experience, standardized adaptation, and a closed measurement loop.
7. Conclusion
The bottleneck in agent deployment has never been that the model is not smart enough. It is that the decision structure is too monolithic, experience cannot be accumulated, and on-site adaptation lacks standards. Separating fast thinking from slow thinking, moving experience from within sessions to across sessions, and writing physical-world constraints as executable configuration is the real path to solving the problem of “development costs plummeting while adaptation costs stay flat.”
