Skip to main content
Use Reflect with a native ToolLoopAgent. Wrap its constructor with PandaProbe tracing, then pass that constructor to Reflect so agent execution and memory use share the same boundary.

Installation

TypeScript only; use Node.js 22+ and AI SDK 6 or 7. Install Reflect together with the framework and model provider used below.

Credentials

For a self-hosted platform, also set PANDAPROBE_ENDPOINT to your API base URL. Reflect uses the same client configuration as tracing.

Enable Reflect

This example creates a policy assistant. Add your own domain tools where indicated; Reflect supplies reflect_bash automatically.
TypeScript

How the integration behaves

wrapVercelAgent records agent, model-step, and actual tool execution as CHAIN → AGENT → LLM → TOOL. Model middleware enriches those same model spans; middleware by itself records only model-level activity. See Vercel tracing.

Conversations and replay

Reflect constructs a native agent per invocation and preserves your prepareCall / prepareStep hooks. It composes current memory and restricts reflection to its tool and step budget. Reflection continues completed response messages; fresh validation starts without prior history. For ordinary multi-turn tasks, pass native conversation messages or use your own history store. A Reflect session ID groups evidence but is not a Vercel conversation store.

Streaming

For an interactive UI, consume the entire stream inside an explicit boundary. The native invokeOptions: { stream: true } convenience consumes supported streams and returns the completed result. Complete or cancel streams explicitly; abandoning a consumer is not a completion signal. run() returns the task’s native result after evaluation and any triggered reflection. A healthy answer may produce no proposal. The workspace persists accepted guidance and pending proposals across restarts.

Validate learned rules

Add independent replay or controlled trials before proposed changes can become shared accepted guidance. Reset your business environment and conversation for each validation arm. See Rules and memory for the working filesystem and session notes.