Self-Improving Agents: Closed-Loop Execution and Skill Distillation
Personalized agents are limited less by model intelligence than by their ability to execute and adapt in real tasks. This article explains a controlled closed loop—execution, observation, learning, and iteration—for distilling versioned, reviewable skills from task traces, with white-box controls, two-layer skill sourcing, memory and evaluation governance, and a minimal rollout plan.
Personalized agents face a practical question: not whether the model is “smart enough,” but how the model can keep landing in real tasks. The industry has broadly accepted that foundation models are strong at reasoning, code, and tool calling. Yet without a task environment, feedback, and reusable experience, such a model is more like an engine idling. What really determines the experience is the execution and adaptation layer around the model—a kind of “gearbox” for the agent. It shifts according to task difficulty and turns one-off reasoning into a closed loop that can be observed, corrected, and accumulated.
Why Self-Improvement Matters More Than Stacking Skill Packs
A common approach is to attach a set of external skills to the agent: retrieval, file writing, command execution, and API calls. This quickly fills capability gaps, but those skills come from public templates and often do not match a specific user’s directory structure, terminology, or acceptance criteria. Users keep correcting the same class of errors, while the agent cannot turn those corrections into default policy for the next run.
The point of self-improvement is not to let the model rewrite itself freely without supervision. It is to extract controlled skills after a complex task: why this run succeeded, where it got stuck, and what the user ultimately accepted. Skills should be versioned, rollback-capable, and open to human review. Over time, the system should better understand this user’s preferred granularity, risk appetite, and delivery format instead of requiring a from-scratch explanation every time.
The Loop: Execute, Observe, Learn, Iterate
A workable closed loop has at least four steps.
Execute. Break the goal into checkable sub-steps. Each step should declare its inputs, tools, expected artifacts, and stopping conditions. For long tasks, do not provide only a final result. Intermediate state must be persisted, such as the plan, changed files, failure logs, and items awaiting confirmation.
Observe. Collect three types of signals: whether the tool succeeded, whether the artifact meets acceptance criteria, and whether the user corrected the direction. The model saying “done” is not enough. Use file diffs, test results, retrieval hits, or business validation as the source of truth.
Learn. Extract patterns from both successful paths and rejected paths. What can usually be distilled includes retrieval scope, command order, code style, risk checklists, and reporting format. What should not be distilled includes one-time secrets, private data, and unconfirmed business rules.
Iterate. Replace or tighten old skills with new ones, and prioritize them on similar tasks next time. If a new skill raises the failure rate, automatically downweight or roll it back. Self-evaluation can be rule-based scoring plus sampled human review; there is no need to mythologize it as unconstrained reinforcement learning. The essence of policy optimization is to improve task success, reduce wasted steps, and shorten user wait time within safe boundaries.
The schematic structure below illustrates control flow only; it is not an interface for any specific product:
task = plan(goal, memory, skills)while not task.done and not task.stalled:step = task.next()result = run_with_timeout(step)trace.append(result)report_progress(step, result) # proactive sync to avoid apparent hangsif result.needs_user: ask_user()task.update(result)skill = distill(trace, user_edits) # generate or refine skillif evaluate(skill) > baseline: save(skill)else: reject_or_rollback(skill)
White-Box Process: Prevent Errors Before Looking Fast
A self-improving agent should prioritize “making fewer unrecoverable errors” over appearing fast. White-box does not mean dumping the entire chain of thought on the user. It means making key actions visible: the current step, the tool used, input and output summaries, whether a retry happened, and whether the agent is blocked by permissions or by logic. During long tasks, proactively reporting “still running, which part is complete, and what comes next” helps distinguish a real deadlock from normal latency.
Practical controls include step timeouts, repeated-action detection, a maximum failure count for the same command, diff previews before write operations, and confirmation for high-risk actions. When a loop is detected, the agent should downgrade to asking the user rather than continuing to spin. Error suppression also means conflict checks before writing a skill, so two skills do not give opposite instructions for the same scenario.
Where Skills Come From: Public Templates and Personal Distillation
External skills are suitable for cold start and answer “can it do this.” Personal distillation is suitable for long-term adaptation and answers “what counts as correct.” The two layers should coexist.
The first layer is stable general capability: reading and writing the workspace, retrieving material, running tests, and organizing logs. These have simple interfaces, clear permissions, and rarely change with the user.
The second layer is personal skills extracted from traces, stored in a unified, self-describing format—for example, name, applicable conditions, steps, prohibitions, success examples, failure examples, and version. Applicable conditions must clearly state the trigger scenario; otherwise, the skill will fire incorrectly on unrelated tasks. Each skill should record the source task ID for auditing.
Follow a “few and concrete” rule during extraction: one skill covers only one repeatable pattern; steps use executable descriptions, not vague slogans; and user rejections become constraints, such as “do not change public interfaces unless requested” and “provide a comparison before changing files.” Cross-session memory stores preferences and project facts separately from skills: memory answers “who the user is and what the project is like,” while skills answer “how to do this type of task.”
Memory, Evaluation, and Governance
Cross-session modeling should have scope and expiration policies. Stable preferences—language, level of detail, whether to present a plan first—can be retained long term. Temporary context—the current branch name or one experiment parameter—should be archived when the task ends. Accounts, secrets, and non-public data should not enter a shareable skill library by default.
Evaluation should not rely only on “the user said thanks.” More reliable metrics include first-pass success rate, rework count, share of wasted tool calls, number of human confirmations, and whether time on similar tasks decreases. When launching a new skill, use shadow comparison: the new skill only records suggestions while the old policy still executes; switch only after confirming there is no regression.
Personalized agents can easily grow from “small and focused” into platform capability. Once the closed loop, skill format, and memory model are validated, general coding and office entry points often provide official branches that cover similar needs. A self-built system should therefore place differentiation in portable parts: its own task definitions, acceptance criteria, permission model, and skill governance, rather than being locked into a non-exportable black box. Skills and memory should ideally be exportable as plain text or structured files, making it easier to change the underlying model.
A Minimal Starting Set for Deployment
Start with one high-frequency task that can be automatically validated—for example, editing documents according to a fixed specification or adding tests—rather than covering every office scenario at once. Save the trace and user edit diff for every run. Define skill write permissions: by default, skills may be proposed; merging requires human or rule approval. Add heartbeat reporting and stall detection for long tasks. Every two weeks, review rejected skills to see whether the trigger conditions are too broad or the steps themselves are unreliable.
The model is responsible for generating candidate actions and explanations; the closed loop is responsible for constraints, evidence, and accumulation. Keep the two separate, and the agent will grow usable “roots” from task to task instead of restarting and idling every time.
