Agent Experience Resets to Zero After Every Requirement: Close the Second Loop to Make It an Expert
A near-identical requirement arrived three weeks after one went live. The business side sent over the PRD, and I stared at it, thinking: this time I have to explain from scratch again "why this calculation is done this way", "whether that switch defaults to on or off", "where the pitfalls we stepped into last time are".
The code was written by the Agent, and quickly. But to explain the business clearly, I still had to fill in the gaps. At that moment I realized a somewhat cruel fact: if you go through a hundred requirements and each one starts from zero understanding of the business, then the Agent is just a faster code generator, not an expert that knows the business increasingly well.
Over the past two years we have seen plenty of demos of "AI writing code"; code generation itself is no longer the bottleneck. What is really expensive is everything around the code: requirement clarification, plan confirmation, implementation, code review, acceptance, release observation, closing out. Code generation is only the most standardized slice of that chain. And in the whole chain, the most overlooked yet most valuable part is whether something can be left behind after the work is done.
I want to use this article to explain one thing: a requirement Agent that can keep improving needs two closed loops. Most people only build the first one.
1. Two loops: one for finishing, one for getting better
Let me define the concepts first, because they are the skeleton of the whole piece.
The first is the execution loop — push a requirement from intake to closing, clarifying what needs clarifying, confirming what needs confirming, verifying what needs verifying. It answers "how to do this thing right this time". Most Agent workflows stop at this layer: take a requirement, call a bunch of tools, produce code, done.
The second is the experience loop — turn the judgments, pitfalls, and corrected calculations produced during this requirement into context for the next one. It answers "how to avoid detours next time". This loop is the source of the word "expert": an expert is not someone who remembers a lot, but someone who understands more after each task than before.
Here is a diagram of how the two relate:
Most systems break at that dashed line: the requirement is done, the process materials stay in the chat history, and they evaporate when the session closes. When the second requirement arrives, it is a blank page again. What is missing is not a smarter model; it is the circuit that turns "the process of doing" into "the input for next time".
I will unpack how to build each loop later. But let me state the conclusion first: to judge whether a set of Agents can really keep improving, look at whether that dashed line is connected, and whether it is connected cleanly.
2. First, the execution loop: carrying the cost of orchestration
The execution loop addresses that old saying — AI writing code is not the bottleneck; the orchestration outside the code is.
From PRD to launch, a person repeatedly performs three kinds of actions: gathering scattered context, manually switching between a dozen platforms, and deciding what to do next. These actions look trivial, but when the frequency rises, context switching and experience differences drag the whole chain down.
These break down into three engineering problems.
First, can context be organized? When an Agent performs poorly, often it is not that the model cannot reason, but that the context it receives is incomplete. Requirement documents, user clarification, historical business knowledge, code facts, configuration platforms, logs, human experience — these are scattered across seven or eight places.
Second, can tools be chained together? Requirement management, code review, code repository, configuration platform, logging system, RPC framework, monitoring, documentation — every extra platform switch adds context loss and manual judgment.
Third, can feedback compound? I will leave this as a teaser; it is the entrance to the second loop.
2.1 Statically, four layers
Structurally, the system can be split into four layers. Note that they are not side-by-side functional modules, but a chain of "fact input → stage judgment → tool landing → feedback recycling":
- Context input layer: answers "what the Agent relies on to understand the business". It does not stuff all materials into the prompt; instead, it pulls long-term business knowledge, current requirement materials, code facts, and runtime evidence by stage. If this layer is wrong, the harder you try later, the more off you go.
- Business expert orchestration layer: answers "what to do next". Is it clarification, planning, or implementation? Where must it stop for human confirmation? When evidence is insufficient, should it fall back to supplementing context or call a human? If these judgments all depend on a person watching, that is both expensive and unreproducible.
- Tool execution layer: answers "how actions land". It turns the platforms that people used to switch between manually into capabilities callable by stage.
- Feedback learning layer: answers "whether next time can be better". This is the carrier of the second loop, covered in detail later.
2.2 Dynamically, stages with gates
Static architecture is a map of capabilities; running it is a vertical process. I list the key gates of each stage below, because the designs most worth copying are hidden there.
| Stage | What the Agent does autonomously | Gates that must be confirmed by a human | Key artifact |
|---|---|---|---|
| Requirement intake | Pull requirement materials + long-term business knowledge, generate context snapshot | Only call humans when fact sources are missing or materials conflict | Context snapshot |
| Requirement clarification | Structurally organize into requirements (goal / non-goal / acceptance / risks / to-be-confirmed) | First gate: whether requirements accurately express the requirement | requirements |
| Technical plan | Write plan, set acceptance method, config schema, test strategy in advance | Second gate: plan confirmation; no coding without confirmation | plan |
| Implementation | TDD-driven code writing, test completion, commit | None (internal hard gate, see below) | Code + tests |
| CR collaboration | Read unresolved comments, modify docs/code, reply and resolve | Comments are collaboration; semantic changes fall back to reconfirm | CR records |
| Acceptance | Deploy to independent environment, gather evidence via HSF calls + logs + monitoring | Third gate: before going to pre-release/production, human confirms | Acceptance evidence |
| Release observation | Read logs back, check runtime metrics | Release action executed manually | Observation records |
| Closing and distillation | Distill stable knowledge, generate improvement candidates, archive | Each type of write is confirmed item by item | Long-term knowledge + improvement candidates |
There is a restraint I like here: humans backstop in three places — requirement interpretation, plan, and release. Coding, testing, and evidence gathering in the middle are as autonomous as possible. Human attention is a scarce resource; it should be spent on "judging whether it is right", not "whether it is fast to operate".
3. Hardening gates: from prompt discipline to engineering checkpoints
This next section is what I most want to emphasize in the whole practice, because it points to a common misconception.
Many people build Agent quality control by writing prompts: "run tests before you push", "be sure to check code standards". That helps a little, but in complex tasks, the Agent will skip it. A prompt is a soft constraint; when the context is long and the task is complex, it can be squeezed out.
The real approach is turning soft constraints into hard gates — making it impossible for the Agent to bypass them.
Three things stack together:
First, use TDD to define "what is right". Test-driven development (TDD) old rules say write tests before implementation. But AI writing tests has a common failure mode: after the code is done, it adds a bunch of tests that "make the code pass". That is not a constraint; it is stamping your own implementation. The genuinely valuable order is the reverse — write tests against the acceptance criteria set in the plan first, let the tests define correct behavior, then let the implementation satisfy them.
Second, diff-to-test mapping. Every behavior change in production code must have a concrete test anchor; you cannot get away with "I ran a module regression". This turns "tested" into "every change is watched by a specific assertion".
Third, and the sharpest trick — inject checks into git's pre-push hook. When the Agent executes push, the hook automatically triggers PMD checks and coverage validation; if they fail, it rejects the push. This turns the quality gate from "the Agent should do it" into "it will not push unless it does".
This shift looks small but is essential: a prompt is negotiating with the Agent; a hook is legislating the environment. Any rule you can enumerate and automatically judge should not stay at the negotiation stage.
A counterintuitive observation along the way: the stage with the densest comment collaboration is not code implementation, but clarification and planning. When the requirement is understood correctly and the plan is confirmed, with the current capability of Agents, writing code does not need that much fine-tuning. So instead of watching the code stage layer by layer, move the confirmation gate forward to requirements and plan.
4. Acceptance: from "a human clicking" to "readable evidence"
Passing unit tests does not mean the business is right. The last mile of the execution loop is proving the result with real evidence in a real environment, not having a human click around in the pre-release environment.
Three key designs:
- Independent environment verification: create or reuse an independent project environment, deploy the current branch to it and run, rather than directly messing with the shared pre-release. No interference, and the evidence is clean.
- Three kinds of cases are all required: positive (core scenario works as expected), negative (boundaries and exceptions handled correctly), regression (unaffected areas are not touched). Acceptance that only tests positive cases is self-deception.
- Evidence is written to disk: acceptance results are written into a readable verification file, referenceable in CR review and closing. "I verified" becomes "here is the verification record, look for yourself".
There is also a boundary to draw clearly: the Agent verifies up to the independent environment; it does not automatically execute primary pre-release deployment or production release. The release action, change materials, risk assessment, and rollback plan can be prepared with the Agent's help, but the final push is done by a human. Capability can be strong, but boundaries must be hard — this is the same logic as "read operations can be let go, write operations must be confirmed".
5. The second loop: letting requirement experience compound
Now back to the core of this article. The first four sections talked about "how to finish this time"; this one is about "what to leave behind when it is done".
5.1 Three-tier memory, and a "no direct upgrade" principle
The carrier of the experience loop is a three-tier memory warehouse:
- Code repository: stores code and tests.
- Project memory repository: pulls a feature branch per requirement; requirements, plan, progress, acceptance evidence, and CR comments accumulate here continuously.
- Long-term knowledge repository: stable business knowledge, system boundaries, historical interpretations, always on the main branch.
The key design is the "no direct upgrade" principle: facts produced during a requirement first stay in the project memory layer, and only after closing review and human confirmation do they selectively enter long-term knowledge.
This design solves the most common way knowledge bases die — noise pollution. If every conversation and every temporary conclusion from the process is stuffed into the long-term wiki, before long nobody trusts that wiki. Layering plus human gates ensures that every entry entering long-term knowledge has been reviewed.
5.2 Leaving traces: feedback should land on platforms, not stay in the chat box
The fuel of the second loop is feedback. Whether feedback can be recycled depends on where it lands.
If the Agent's clarification, CR opinions, and acceptance conclusions stay in the chat box, they all evaporate when the requirement ends. So the design requires: feedback should land in the platform's own comment system as much as possible — confirmation comments on requirements, review feedback and resolve records on MRs, milestone comments in the requirement management system. Each comment carries a commit link, a CR link, and verification evidence.
This kills two birds with one stone: it is easy to trace now, and at closing it becomes analyzable first-hand material. Which clarifications recur, which code patterns are repeatedly flagged, which manual interventions could have been automated — these patterns can only be seen if they stay on the platform.
5.3 Closing distillation: turning one-time processes into reusable assets
Closing is not writing "done". It is looking back over the whole requirement and answering three questions:
| Category | Judgment | Destination |
|---|---|---|
| Stable knowledge | Business rules, system boundaries, acceptance conventions, troubleshooting experience — things the next similar requirement need not relearn | After CR confirmation, enter long-term wiki and codemap |
| Process improvement | Where the Agent made mistakes, went down detours, or was repeatedly corrected | Becomes iteration candidates for skills / prompts |
| One-time materials | Implementation details, temporary debug records, intermediate states | Archived into closeout raw log as an audit trail |
The grading of these three is important: not all experience is worth distilling, and not all materials belong in long-term knowledge. Separating what should stay from what should only be archived is itself a form of judgment.
Once this loop is closed, the flywheel turns: the stable knowledge distilled at closing returns to the long-term repository, becoming the background for the next requirement. Every requirement completed raises the Agent's baseline of understanding the business, and the context humans need to explain shrinks. A requirement is not a consumable; it is an asset.
6. Honest limits: what this system has not solved yet
I will not sell this practice as a silver bullet. It itself admits several unsolved problems, and these "unsolved" points are more valuable than pretty numbers.
Integration cost is still high. First integration is mainly held up by authentication and runtime initialization. Many platform tools only support web-based login authorization, and are not adapted for the Agent's command-line sandbox. This is a transitional state that will ease as platforms add CLI/API authentication, but right now it is real money and time spent.
The most serious issue is the lack of a measurement system. You ask the Agent to distill process improvements back into skills and prompts at closing, forming "self-iteration". But how do you know whether each round is real progress or regression? Without a baseline, so-called "self-growth" is just going by feel. At least four dimensions should be observed: human effort (intervention counts, review round counts, whether the ratio of manual corrections is dropping), requirement quality (whether plan rework rate and one-pass acceptance rate are rising), production stability (whether production issues and rollback counts are decreasing), collaboration efficiency (whether the rate of cross-platform information loss is controllable). Iteration without measurement is blind modification.
From single Agent to Agent Team. Currently this loop is run by a single Agent in the backend. Pure backend requirements are sufficient, but complex requirements need frontend, backend, and testing each doing their part, with a team lead above to decompose and dispatch. Upstream, there could even be a PD Agent producing the PRD directly, turning the most human-intensive clarification stage into alignment between Agents.
But there is a restraint I admire here: do not mechanically split by process steps; instead, look at whether there is real independent judgment, independent artifacts, parallel execution, and responsibility isolation — before enough real complex requirements have validated it, do not rush to spread out. This "not getting carried away" is harder in engineering than "throwing everything in". And the key constraint of the team is already clear: shared long-term knowledge ensures consistent understanding, while each one maintains its own perspective and artifacts.
Conclusion
Looking back, what this system does can be summed up in one sentence: organize the complete process of a requirement from entry to closing into a closed loop where the Agent can push forward autonomously and humans only confirm at key nodes — and make every requirement the context for the next one.
The first half is the first loop, which many are already building; the second half is the second loop, and that is where the gap widens.
The deeper change is in the collaboration model: humans should not repeatedly fill gaps in every requirement; instead, they should sink the gap-filling action into the system. If the Agent lacks context, add knowledge and project memory; if it lacks capability, add tool interfaces; if the process tends to drift, add confirmation gates and quality gates; if feedback is easily lost, add traceability and closing distillation.
To judge whether a team's Agent is really being used and used well, I think you only need to look at one signal: is their 100th requirement explained less, confirmed more accurately, and reworked less than their 1st? If the answer is yes, the second loop is really spinning. If every requirement still feels like day one, then no matter how much automation, it is only faster repetition.
References
- How to build an end-to-end business requirement expert Agent — Taotian Group User & Content Technology Team, Senye
- Martin Fowler. Test Driven Development
- Git Documentation. githooks — pre-push
- PMD. PMD Source Code Analyzer
Top 1 from juejin.cn, machine-translated. The original thread is authoritative.
No problem — prompts are negotiating, hooks are legislating, that hits the nail on the head. Self-iteration without metrics is blind tweaking; I'm sold on that too.