Skip to main content
This reference is auto-generated from SDK docstrings. Run python scripts/generate_api_docs.py to regenerate.

Constructor

Create a Reflect client for a project.

Class methods

bootstrap


Instance methods

health

Return the API health status. No authentication required.

query_memories_async

Async version of query_memories.

augment_with_memories_async

Async version of augment_with_memories.

query_memories

Retrieve memories by semantic similarity and Q-value ranking. Returns: List of MemoryResponse objects, ranked by blended score.

get_skill

Return the project skill, or None if no skill has been created yet.

get_skill_async

Async variant of get_skill.

create_skill


augment_with_memories

Query memories and format them into the task text for prompt augmentation. Returns: AugmentedTask with augmented_task (task + memory blocks) and memories.

trace

Context manager that retrieves memories and auto-submits the trace. On entry, memories are queried and made available via ctx.augmented_task and ctx.memories. Call ctx.set_output(...) inside the block to record your agent’s result. On exit, the trace is submitted with the correct retrieved_memory_ids automatically.

trace_async

Async version of trace.

create_trace

Record your agent’s run without blocking your application. Call this after your agent finishes a task to send the full conversation to Reflect for storage. The call returns immediately with a TraceCreateResponse — the trace is ingested in the background, so your agent can move on to the next request without waiting. If you already know whether the response was correct (e.g. you compared it to an expected answer), pass review_result to include an inline review. Reflect will then generate a reflection and store it as a new memory in the background, so future runs of your agent can learn from this outcome. If you don’t know the result yet, omit review_result and review later via review_trace or the web dashboard. Returns: A TraceCreateResponse with the trace id and its ingest_status (typically "queued"). Example — log your agent’s run for later review
Example — log and review in one call (auto-graded)
"success" and "failure" are aliases for the API’s "pass" and "fail". The SDK maps them automatically.

create_trace_async

Async variant of create_trace. Same parameters and return type. Uses asyncio.sleep between polls where applicable.

create_memory

Store an agent-authored reflection as a memory in one call. Unlike create_trace, you supply the reflection yourself — Reflect stores it directly with the pass/fail result and skips background LLM reflection generation. Pass retrieved_memory_ids so the memories you used get Q-learning credit. Returns: A TraceCreateResponse (ingest_status is typically "completed" — authored reflections are stored synchronously).

create_memory_async

Async variant of create_memory. Same parameters and return type. Uses asyncio.sleep between polls where applicable.

wait_for_trace


wait_for_trace_async

Async variant of wait_for_trace. Same parameters and return type. Uses asyncio.sleep between polls where applicable.

create_trace_and_wait

Record your agent’s run and wait until the memory is created. Use this when your next step depends on the trace (and its memory) being fully processed — for example:
  • Evaluation loops where you run multiple tasks in sequence and need each memory to exist before the next task starts, so your agent can learn from earlier mistakes within the same run.
  • Tests where you want to assert on the created memory or the final review status.
  • Scripts and pipelines where you need confirmation that the reflection was stored before moving on.
This method submits the trace, then polls until it’s done:
  • Without review_result: waits until the trace is stored.
  • With review_result: waits until the review is processed, the reflection is generated, and the memory is saved. The returned TraceResponse will have review_status == "reviewed" and a populated created_memory_id.
If your application serves real-time traffic and you don’t want to block, use create_trace instead — it returns immediately while processing happens in the background. Returns: The fully processed TraceResponse with the attached ReviewResponse and created_memory_id (when reviewed). Raises: RuntimeError — If processing fails — e.g. the LLM errored while generating the reflection. Check trace.last_ingest_error for details. TimeoutError — If processing doesn’t finish within wait_timeout seconds. Example — evaluation loop that learns across tasks
Example — interactive CLI with human review
"success" and "failure" are aliases for the API’s "pass" and "fail". The SDK maps them automatically.

create_trace_and_wait_async

Async variant of create_trace_and_wait. Same parameters and return type. Uses asyncio.sleep between polls where applicable.

list_traces

List traces for the project. Returns: List of TraceResponse objects.

get_trace

Fetch a single trace by ID.

get_trace_async

Async variant of get_trace. Same parameters and return type. Uses asyncio.sleep between polls where applicable.

review_trace

Submit a deferred review for a trace. Returns: The updated TraceResponse with the review attached.

delete_traces


list_api_keys


create_api_key


revoke_api_key


delete_project