Skip to main content
The Reflect SDK is a Python client that lets your AI agents learn from past outcomes. It connects to the Reflect API to query memories, record traces, and submit reviews — creating a feedback loop that improves responses over time.

Works across workflows

Agent agnostic

Use Reflect with any agent that can call the API. It is not tied to a single model, framework, or agent runtime.

Harness agnostic

Plug Reflect into your existing setup, whether you run custom scripts, evaluators, agent loops, or lightweight MCP-based tooling.

Task agnostic

Store and retrieve memories for debugging, implementation, documentation, testing, refactoring, and other kinds of work.

Cross-functional memory reuse

Memories created in one workflow can help with another. A reflection from a coding task can still be useful later in testing, docs, or review work when the task is relevant.
You can also wire Reflect into tools like Cursor or Codex through a simple MCP server, as long as the agent can query memories and record outcomes.

How retrieval works

Reflect ranks memories by learned utility (q_value) from real outcomes.
  • Q-value (utility) captures whether using a memory previously helped or hurt.
  • Higher Q-value memories are prioritized in retrieval.
  • Lower Q-value memories are deprioritized over time.
Reflect behaves like a utility database (a Q-database): memory retrieval is driven by expected usefulness in the current situation. That utility is learned from full trajectories plus review outcomes (pass / fail) in context, then fed back into future retrieval.

The learning loop

1

Query memories

Before executing a task, retrieve relevant reflections from past runs. Memories are ranked by learned utility (Q-value).
2

Augment your prompt

Append retrieved memories to the task text. The SDK formats successful and failed reflections into sections your LLM can use as context.
3

Execute the task

Your agent generates a response using the memory-augmented prompt.
4

Record a trace

Store the full trajectory — task, steps, final response, and which memories were used.
5

Submit a review / LLM as Judge {Evaluation}

Mark the outcome as pass or fail. The API generates a new reflection memory and adjusts Q-values of the memories that were retrieved.
Future queries automatically favor reflections that led to success.

Requirements

  • Python 3.12+
  • A Reflect API instance (local or deployed)
  • A project and API key from the Reflect console or the bootstrap endpoint

Next steps

Installation

Install the SDK with pip.

Quickstart

Create a client, query memories, and record a trace.

Memories

Query and augment tasks with past reflections.

Reference

Full ReflectClient method reference.