Don't Forget What You Just Learned: Self-Directed Repair Turns Agent Mistakes Into Lasting Lessons
Organizations: Princeton University · Meta FAIR
Abstract
Intelligent agents should learn from their mistakes so that experience leads to continuous improvement. Yet today's agents recover from a mistake only temporarily: in-context reflections are easily forgotten across sessions and compete for limited context, while full-parameter fine-tuning is expensive and can interfere with existing capabilities. We introduce Self-Direction, a mechanism for agents to learn from mistakes that combines the benefits of temporary in-context retries and policy updates. When an agent fails a task, it reflects on its own trajectory in order to extract a lesson and immediately distills it into a lightweight low-rank adapter. By keeping the original weights frozen, Self-Direction prevents adapter training from overwriting base-model parameters while training additional parameters equivalent to ~0.02% of the base model's parameter count for each adapter. The agent then saves these adapters in a persistent library of lessons, automatically routing them to solve related problems later. Experiments with agents based on open-weight models from the Qwen family across open-ended research (GAIA), tool-use workflows (Claw-Eval), and terminal tasks (Terminal-Bench 2.1) show that our method improves overall success rates by 8.9 to 17.0 percentage points and performs competitively with frontier systems. We find that Self-Direction reduces repeated mistakes across future encounters of a task, nearly doubling the reliability of an agent's corrections. Learned lessons also transfer: a handful of adapters generalize to dozens of new tasks without additional training. Ultimately, this self-directed repair transforms everyday mistakes into lasting lessons.
Figures & tables
| Benchmark | Encounters | Mistakes avoided ( ) | Corrections preserved | |||
| Base retry | Self-Direction | Gain | Base retry | Self-Direction | ||
| GAIA | 2 | +11.9 pp | ||||
| 3 | +12.9 pp | |||||
| Terminal-Bench 2.1 | 2 | +6.8 pp | ||||
| 3 | +2.3 pp | |||||
| Claw-Eval | 2 | +7.5 pp | ||||
Appendix figures & tables24 assets
Supplementary material from the paper’s appendix.
Appendix
| Benchmark | Task group | Tasks | Initial base | Base pass@ | Full loop |
|---|---|---|---|---|---|
| (Qwen3.6-27B) | (no lesson retention) | (lessons retained) | |||
| MiniWoB++ | social-media-all | 25 | ( ) | ( ) | ( ) |
| MiniWoB++ | click-collapsible-2 | 25 | ( ) | ( ) | ( ) |
| MiniWoB++ | email-inbox | 25 | ( ) | ( ) | ( ) |
| MiniWoB++ | email-inbox-nl-turk | 25 | ( ) | ( ) | ( ) |
| MiniWoB++ | Overall | 100 | ( ) | ( ) | ( ) |
| Generalization | Lessons learned from | Library | Evaluation tasks | Improvement |
|---|---|---|---|---|
| Tasks in a continual stream GAIA | 3 GAIA tasks | 3 adapters | GAIA deployment stream ( ) | +16.3 pp [-1pt] |
| Harder tasks GAIA | Easy Level 1 tasks | 28 adapters | Harder Level 2 tasks ( ) | +10.47 pp [-1pt] |
| Tasks across categories Claw-Eval | Operations tasks | 3 adapters | Unseen workflow tasks ( ) | +12.5 pp [-1pt] |
| Stage | Attempts | New wins | Stage success | Cumulative wins | Overall accuracy |
|---|---|---|---|---|---|
| Phase 1 | 89 | 23 | 25.8% | 23 | 25.8% |
| Phase 4: adapter | 65 | 7 | 10.8% | 30 | 33.7% |
| Phase 4: base fallback | 58 | 1 | 1.7% | 31 | 34.8% |
| Final | 89 | 31 | – | 31 | 34.8% |
| Stratification | Group | N | Mean Accuracy | Pass 3 | ||
|---|---|---|---|---|---|---|
| Initial base | Full loop | Initial base | Full loop | |||
| Overall | All tasks | 161 | 64.4% | 73.3% | 51.6% | 64.6% |
| Category | Workflow | 47 | 78.7% | 87.9% | 61.7% | 78.7% |
| Ops | 31 | 89.2% | 98.9% | 80.6% | 96.8% | |
| Finance | 14 | 28.6% | 40.5% | 14.3% | 28.6% | |
| Office QA | 10 | 33.3% | 43.3% | 20.0% | 20.0% | |
| Stratification | Group | N | Mean Accuracy | Pass 3 | ||
|---|---|---|---|---|---|---|
| Initial base | Full loop | Initial base | Full loop | |||
| Overall | All tasks | 89 | 51.7% | 65.5% | 34.8% | 57.3% |
| Difficulty | Easy | 4 | 100.0% | 100.0% | 100.0% | 100.0% |
| Medium | 55 | 62.4% | 78.2% | 43.6% | 70.9% | |
| Hard | 30 | 25.6% | 37.8% | 10.0% | 26.7% | |
| Category | Software Engineering | 26 | 38.5% | 47.4% | 26.9% | 42.3% |
| Benchmark Pair | Max. Similarity | Safe | Cross-Domain Retrievals | Capabilities Preserved |
|---|---|---|---|---|
| GAIA–TB 2.1 | 0.546 | 0.55 | 0 / 145 | |
| GAIA–Claw | 0.415 | 0.42 | 0 / 141 | |
| TB 2.1–Claw | 0.306 | 0.31 | 0 / 84 | |
| All three, one global | 0.546 | 0.55 | 0 / 370 |
| Stored content | Approximate tokens | Native context windows |
|---|---|---|
| Full trajectories for 101 failures | M | |
| Truncated failure representations | 188K | |
| 2,428 lesson instruction-response pairs | 362K | |
| Lessons with formatting and rationales | 410K | |
| Full trajectories and lessons | M |
| Hyperparameter | GAIA / Claw-Eval | Terminal-Bench 2.1 |
|---|---|---|
| Temperature | ||
| Top- | ||
| Maximum new tokens per turn | 16,384 | 16,384 |
| Maximum ReAct steps | 50 | 100 |
| Maximum tool calls | 100 | 100 |
| Stop generation after tool call | Yes | Yes |
| Component | Hyperparameter | Value |
| Corrective data | Maximum examples per failure | 24 |
| Corrective data | Minimum examples required | 8 |
| Corrective data | Maximum assistant-response length | 16,384 tokens |
| Corrective data | Trajectory steps retained for reflection | 24 |
| LoRA | Rank | 16 |
| LoRA | Scaling parameter | 16 |
| Reason | Operational definition | Target modules |
|---|---|---|
| step_budget | The agent reaches its maximum number of interaction steps before verified completion. | q_proj , v_proj |
| tool_call_budget | The agent exhausts its permitted tool calls before completing the task. | q_proj , v_proj |
| no_final_response | The execution ends without an extractable final response and was not terminated by a budget or exception. | q_proj , v_proj |
| wrong_answer | The agent produces a response but the verifier rejects the resulting answer or environment state. | down_proj |
| exception | An execution error prevents the agent from completing the task. | down_proj |
| Benchmark | Adapters | Training tokens | Synthesis | Optimization | End-to-end | GPU energy |
|---|---|---|---|---|---|---|
| per adapter | (min) | (s) | (min) | (Wh) | ||
| GAIA | 46 | 4,059 | 8.51 | 80.9 | 9.89 | 37.0 |
| Claw-Eval | 39 | 3,709 | 5.82 | 80.3 | 7.19 | 26.5 |
| Terminal-Bench 2.1 | 45 | 3,100 | 5.79 | 81.4 | 7.22 | 27.1 |
| Overall | 130 | 3,622 | 6.76 | 80.9 | 8.16 | 30.4 |
| Benchmark | Available tools |
|---|---|
| GAIA | web_search , web_fetch , python_exec , shell , file_read , file_open , and list_dir . These tools support web research, numerical computation, shell commands, directory inspection, and extraction from text, PDF, spreadsheet, HTML, and image files. |
| Claw-Eval | Email and contacts: gmail_list_messages , gmail_get_message , gmail_save_draft , gmail_send_message , contacts_search , contacts_get , and contacts_send_message . Calendar, tasks, and scheduling: calendar_list_events , calendar_get_event , calendar_create_event , calendar_get_user_events , calendar_delete_event , todo_list_tasks , todo_get_task , todo_update_task , todo_create_task , todo_delete_task , scheduler_list_jobs , scheduler_get_job , scheduler_job_history , scheduler_create_job , scheduler_update_job , and scheduler_delete_job . Business services: finance, CRM, inventory, reporting, helpdesk, and integration-management tools for listing, inspecting, updating, and creating benchmark entities. Knowledge and content: kb_search , kb_get_article , kb_update_article , notes_list , notes_get , notes_share , rss_list_feeds , rss_list_articles , rss_get_feed , rss_get_article , rss_publish , web_search , and web_fetch . Documents and media: documents_extract_text , ocr_extract_text , and caption_describe_image . The nine sandbox tasks additionally expose Bash , Read , Write , Edit , Glob , and Grep inside an isolated workspace. |
| Terminal-Bench 2.1 | terminal_shell , which executes Bash commands inside a fresh, task-specific Podman container. Commands share a persistent filesystem for the duration of an attempt and return their exit code, standard output, and standard error. The shell supports inspecting files and processes, editing or creating artifacts, installing dependencies, compiling software, configuring services, and running agent-authored validation checks. |
| Source adapter | Later target | Shared procedure | Observed recovery |
|---|---|---|---|
| ORCID publication aggregation (Level 3) | Wikipedia revision counting (Level 2) | Traverse a complete remote history, handle pagination, apply a date constraint, and verify completeness before counting. | Initial answer: 2610. Adapter answer: 2732 (correct). |
| BBC Earth video lookup (Level 1) | Exact quotation from another video (Level 1) | Identify the correct video and extract a localized fact using descriptions, timestamps, comments, or other supporting metadata. | The initial execution exhausted its step budget; the adapter returned the exact quotation. |
| Spreadsheet aggregation (Level 1) | Statistics over values extracted from an image (Level 2) | Extract structured values, inspect intermediate data, compute with a tool, verify the calculation, and format only after validation. | Initial answer: 2.404. Adapter answer: 17.056 (correct). |
| Caesar-cipher decoding (Level 2) | Text-grid reconstruction (Level 1) | Apply a text transformation, check linguistic coherence, and preserve exact capitalization, spacing, and output constraints. | The initial execution recovered the meaning but violated formatting; the adapter returned the exact required sentence. |
| Source operations lesson | Target workflow | Shared procedure | Grader score change |
|---|---|---|---|
| Scheduled-task management | Weekly meeting tracking | Collect status across multiple records, identify missing or incomplete actions, and produce a structured progress report. | |
| Month-end reconciliation | Task backtracking | Reconcile evidence across emails, task lists, and meeting notes; identify discrepancies and report status, blockers, and next actions. | |
| Scheduled-task management | Multi-project progress reporting | Aggregate task status across several projects, identify risks, and organize the results into separate actionable reports. |
Self-Improving Agents
Self-improving agents use experience and feedback to update their models, memories, skills, or workflows for better future task performance.
See all 169 papers