An agent that learns from its own failed attempts

Building agentsBuilder whose agent runs on Claude Code headless (claude -p)

Our data-fixing agent runs claude -p on each broken CSV a customer uploads. It kept trying the default parser on files split by semicolons, failing, and only then trying the right one. We wanted it to learn that once, not on every file.

How do I make my claude -p agent stop repeating an approach that already failed?

Tell your agent in its prompt to record failed approaches with ArcRoom's remember_failure and the reason, and to save approaches that worked with complete_task. Before each job, find_task returns similar past attempts, failures included. If a saved lesson turns out wrong, report it with arcroom wrong <memo> <reason>. The agent must call remember_failure; ArcRoom doesn't judge failure itself.

Also asked as: My data agent makes the same mistake on every file before finding the fix. How do I stop it? · How do I build an agent that learns from its past failures? · Can a headless Claude Code agent remember what didn't work last time?

The work

The agent's prompt says to record a failed approach with remember_failure and the reason.

ArcRoom keeps
  • Reused answer
  • Saved answer
  • Failed approach
  • Saved decision
  • Wrong-memory report
The next agent gets

find_task → similar (3):

Step by step

  1. The agent's prompt says to record a failed approach with remember_failure and the reason.
  2. Before each job, find_task returns similar past attempts, failures included.
  3. Approaches that worked are saved with complete_task, so the next file starts with them.
  4. If a saved lesson turns out wrong, arcroom wrong <memo> <reason> reports it.

What the agent sees

find_task → similar (3):
✗ failed: read_csv default on ';' files → 1 column (Oct 12)
✓ worked: sniff the delimiter, then read_csv(sep=…) (Oct 14)

Compared with today's tools

Letta

Build the agent on Letta and let it write lessons into its own memory blocks after each run.

Setup
2–5 days
Ongoing
Review what the agent wrote to memory, ~30 min a week

ArcRoom

Every agent reads the team playbook before it works and writes to it when it finishes. Nothing to update by hand.

Setup
2 min (npx arcroom init)
Ongoing
None

Letta suits an agent built on Letta and lets it rewrite its own memory; those lessons stay inside that Letta agent, not in Claude Code, Codex or a teammate's agent.

Where it stops

The agent must call remember_failure; ArcRoom doesn't judge failure itself. Lessons are matched by similarity, so unusual files may not match.

Try it in your project

Works with the agents your team already uses, and any agent over MCP or the HTTP API.

More in building agents