Your agent shouldn’t make the same mistake twice.

Retrace gives agents a memory of what worked, what failed, and what to try differently next time. A small layer between your agent and its next attempt.

$ pip install retrace

python ≥ 3.10MITruns locally

fig. 1 — one run, observed
01 / The problem

LLMs can reason.
They can’t remember what they learned.

An agent can spend twenty steps discovering why something failed, then make the exact same mistake tomorrow.

Most agent loops throw that experience away.

Retrace doesn’t.

Without Retrace, every run fails the same way and loses its context. With Retrace, the first failure is reflected on and stored as memory_042; the second run retrieves it, adapts, and succeeds.
without retracea
run_001
failure
∅ context lost
run_002
same failure
run_003
same failure
run_004

3 runs · 3 failures · 0 lessons kept

with retraceb
run_001
failure
reflect
⊡ memory_042
run_002
retrieve memory_042
adapt
success ✓

2 runs · 1 failure · 1 lesson kept

02 / How it works

One loop.
Nine stages.
Three of them are new.

Retrace sits beside your agent, not inside it. It watches a run end, decides whether anything worth keeping happened, and hands the result to the next run that needs it.

Request enters your runtime: agent, execution, outcome. The outcome and trace flow into Retrace: evaluation, reflection, memory with screening, retrieval. Relevant memories flow back out to the next attempt.
  1. [1]Your code owns the loop. Retrace observes a run; it never drives your agent.
  2. [2]Was the outcome acceptable? Heuristic, model-graded, or a verdict you supply.
  3. [3]The trace and verdict are condensed into a short, reusable lesson.
  4. [4]Only lessons that pass screening are kept. Memory is scoped per agent, task, or tenant.
  5. [5]On the next similar task, the most relevant lessons are returned as context.
  6. [6]You decide whether, when, and how many times to try again.
01 /
REFLECT

Turn execution outcomes into reusable lessons.

memory.reflect(task, result)
02 /
REMEMBER

Store useful experience in scoped, persistent memory.

memory.remember(lesson, scope="…")
03 /
RETRIEVE

Inject relevant experience when the agent meets a similar situation again.

memory.retrieve(task, k=3)
03 / Observed behavior

Attempt
fourteen.
Attempt fifteen.

A real session. The first run fails on a constraint the agent was never told to check. The reflection names the cause, writes a one-line lesson, and stores it. The next run on a similar task retrieves it before acting.

output abridged · ids shortened

Terminal session showing a failed booking attempt, Retrace evaluating the cause and storing a lesson, then a later attempt retrieving that memory and succeeding.
retrace · session
> agent.run("book a flight to London")
attempt#14
statusfailed
> retrace.evaluate(run)
causeselected itinerary exceeded budget constraint
lessonbefore checkout, compare final fare against
user.max_flight_budget
memorystored ⊡ mem_8F21Ascope travel-agent
> agent.run("book a flight to Paris")
retrieving memories…
mem_8F21Arelevance 0.94
adaptconstraint check addedfare ≤ user.max_flight_budget
attempt#15
statussuccess ✓
>
04 / Architecture

A small layer in your stack.
A long memory for your agent.

Your application calls the Retrace SDK. Retrace contains an evaluator, reflection, memory screening, retrieval, and scoped memory, backed by a persistent store on disk.
[ local / self-hosted ]
Runs on your machine or inside your infrastructure. There is no hosted service in the loop.
[ scoped memory ]
Lessons live in a scope you define: an agent, a family of tasks, a tenant.
[ isolation ]
Scopes do not bleed into each other. One tenant's lessons are never retrieved for another.
[ persistent store ]
SQLite on disk by default. Swap in your own store through a small adapter interface.
[ sdk / api ]
A Python SDK and a plain HTTP API. Use whichever your agent already speaks.
[ caller-controlled retry ]
Retrace returns context. Your code decides whether, and how, to try again.
05 / Position

Intelligence without memory
is just repetition.

The useful part of an agent’s experience shouldn’t disappear when the context window closes.

Failures contain information.
Corrections contain information.
Successful strategies contain information.

Retrace turns that experience into infrastructure.

06 / Install
$ pip install retrace
agent.py12 lines · python
from retrace import Retrace

memory = Retrace(scope="flight-booking")

for attempt in range(3):
    # past lessons, ranked by relevance
    lessons = memory.retrieve(task)
    result  = agent.run(task, context=lessons)

    # evaluate → reflect → store if useful
    memory.reflect(task, result)
    if result.ok: break

The loop is yours. Retrace only adds the two calls.

07 / Early access install

Private beta.
Two keys.
Seven steps.

Retrace ships as a private Python SDK and connects to a hosted API. Early users get two credentials, and it’s worth being clear about which one does what before you start.

Ten minutes from an empty folder to a running demo.

credentials
01 / Install only.
CLOUDSMITH TOKEN

Unlocks the private package index so pip can download the SDK. It never touches the Retrace API.

<ENTITLEMENT_TOKEN>
02 / Runtime only.
RETRACE API KEY

Starts with rt_live_. Authenticates the SDK and CLI to the hosted Retrace API. It is not used by pip.

<YOUR_RETRACE_API_KEY>
  1. [1]

    Request early access

    Tell us a little about the agent you’re building. Request access →

  2. [2]

    Receive two credentials

    We’ll send a Cloudsmith install token and a Retrace API key. They do different jobs: one installs the SDK, the other talks to the API. Keep both out of version control.

  3. [3]

    Create a virtual environment

    Python 3.10 or newer. Any venv tool works; this is the plain one.

    $ python -m venv .venv && source .venv/bin/activate

    Windows: .venv\Scripts\activate

  4. [4]

    Install the private SDK

    Replace <ENTITLEMENT_TOKEN> with your Cloudsmith token. The extra index keeps public dependencies coming from PyPI.

    $ pip install retrace-agent --index-url https://dl.cloudsmith.io/<ENTITLEMENT_TOKEN>/zenvex/retrace/python/simple/ --extra-index-url https://pypi.org/simple
  5. [5]

    Log in to the hosted API

    Paste <YOUR_RETRACE_API_KEY> when prompted. The key is stored locally for the SDK and CLI to use.

    $ retrace login --base-url https://retrace-nsbhhri2ta-el.a.run.app
  6. [6]

    Verify the connection

    Checks your Python version, the installed SDK, and that your key is accepted by the API.

    $ retrace doctor --base-url https://retrace-nsbhhri2ta-el.a.run.app
  7. [7]

    Run the demo

    One agent, one task, a few attempts. Watch it fail, reflect, remember, and retry.

    $ retrace demo --base-url https://retrace-nsbhhri2ta-el.a.run.app

Hosted API: https://retrace-nsbhhri2ta-el.a.run.app
If retrace doctor reports a 401, you pasted the Cloudsmith token where the rt_live_ key should go. Run retrace login again.