> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Run a baseline simulation

> Prepare, price, start, and follow a baseline simulation of a connected agent.

A baseline simulation tests a simulation copy of your connected agent on scenarios drawn from its production conversations. Runtype builds the copy from your agent's traces (production traces when there are any, otherwise development runs) and never calls your live tools. The copy answers each tool call from a recorded call, or generates an answer from the tool's definition. A tool with no captured definition answers only from recorded calls.

If your agent map declares a Slack, Telegram, SMS, or iMessage surface, Runtype simulates the copy behind that channel without sending messages or requiring credentials. Runtype formats and splits each reply as that channel sends it. If an agent names more than one of those channels, Runtype simulates one, and the channel stays fixed after the baseline runs.

Every step works through your coding agent with the Runtype Connect MCP tools or from the command line with `npx @runtypelabs/connect`. Both accept the same arguments and return the same result.

## Before you begin

Before you prepare a baseline simulation, make sure that you have the following:

* **Traces of the agent**: Runtype builds the copy from the observed profile extracted from the agent's traces over the last 14 days. It uses production traces (those that set `deployment.environment.name` to `production`) when there are any, and otherwise your development runs, so the first simulation needs no production traffic. The baseline's `notes` say when it was built from development runs. For more information, see [Read the observed profile](/analyze/read-the-observed-profile).
* **Conversation content captured**: Your traces must include the system prompt, messages, and tool calls. Your agent's logging and personally identifiable information (PII) redaction settings must allow content capture. For more information, see [Control what content is sent](/connect/control-what-content-is-sent).
* **Tool definitions recorded**: If your agent calls tools in production, send `gen_ai.tool.definitions` on model spans or declare each tool in your agent map. For more information, see [Describe your agents](/analyze/describe-your-agents).
* **A claimed organization**: An organization created with `init --no-browser` is unclaimed. Before you prepare or start a baseline simulation, claim it with `npx @runtypelabs/connect claim`. For more information, see [Claim an unclaimed organization](/connect/connect-a-repository#claim-an-unclaimed-organization). If you authenticate with an API key, the key needs the `SIMULATIONS:RUN` scope.

## Prepare and price the baseline

Preparing a baseline builds the copy, creates its simulation, and prices one run. Runtype draws scenarios from up to 50 production conversations from the last 30 days, favoring conversations where signals flagged a problem.

### Prepare with your coding agent

To prepare a plan for an existing product and review it before starting, copy the command from the product's **Simulations** page:

**`Prepare a simulation plan`**

```bash title="Prepare a simulation plan"
npx @runtypelabs/connect simulate --product PRODUCT_ID --brief="Find where new users get stuck"
```

Replace `PRODUCT_ID` with the product's ID. `simulate` signs you in or reuses your session, reads that product's saved context, and offers to open your coding agent. Your agent prepares a draft plan and estimate for you to review in the dashboard. Start the run there when you're ready.

`simulate` requires an explicit run request for this product's baseline and proposed changes, including runs covered by Connect credit. Starting a run yourself keeps that requirement in place for later runs. Runs already queued or running continue.

To require explicit starts when using `start-baseline-simulation` directly, pass `--prepare-only` (or `prepareOnly: true` to the MCP tool). That setting also stays in place after an explicit run. Omitting it or passing `false` doesn't restore automatic starts.

### Prepare the baseline directly

Unless you've required explicit starts with `simulate` or `prepareOnly`, Runtype can prepare and start a baseline run on its own when Connect credit covers it. This automatic start runs after an agent reaches 20 production conversations and business context is saved for the product. Draft business context is enough: the `confirm_business_context` pending action can stay open in `get_status` until you review the first report. In that case, `start-baseline-simulation` returns `state` as `running` or `finished` with `runId` already set. For how to confirm business context, see [Confirm the business context](/analyze/describe-your-agents#confirm-the-business-context).

The product's first simulation starts in the `start-baseline-simulation` call, with no estimate and no approval. It runs each scenario once and stops at a \$2.00 spending limit. When the run ends, its report states what it cost. If it can't be paid for, the call fails with `PAYMENT_REQUIRED` and says what to add. For credit rules, see [Connect credit](/reference/limits-and-pricing#connect-credit). Later runs are priced first, as described below.

To prepare the baseline for one agent, run `start-baseline-simulation` (or call the `start_baseline_simulation` MCP tool):

**`Prepare the baseline`**

```bash title="Prepare the baseline"
npx @runtypelabs/connect start-baseline-simulation --product-id PRODUCT_ID --agent AGENT_NAME --json
```

Replace the following:

* `PRODUCT_ID`: the product ID that `init` printed. You can omit `--product-id` when `.env` or `.env.local` holds an ingest key for this API, or when your organization has one product.
* `AGENT_NAME`: the name that the agent reports in its traces, or the agent ID from `get_status`. When you omit `--agent`, Runtype picks the product's agent with the most traces in the last 30 days and names it in `notes`.

Running `start-baseline-simulation` again without `--draw-scenarios` or `--run-changed-scenarios` is safe. It returns the same estimate while that estimate is current, and after a run it keeps that run. To run the baseline on scenarios you changed after a run, see [Run scenarios you add by hand](#run-scenarios-you-add-by-hand).

Check the following fields in the response:

* `state`: where the baseline stands. The value is `ready_to_run`, `awaiting_approval`, `needs_scenarios`, `running`, or `finished`. In an unclaimed organization, the call fails with the `claim_required` error instead.
* `estimate`: the pricing details, including `estimateId`, or `null` when scenarios are missing.
* `pendingAction`: the `approve_spend` action (with its `id`) to resolve before a run that needs approval, or `null` when no approval is needed.
* `runId`: the baseline run ID after a run has started, or `null` before it starts.
* `notes`: plain-text notices about anything skipped or missing, such as tools without captured definitions or why scenarios weren't drawn.

### Read the estimate

The `estimate` object in the `start-baseline-simulation` response prices one baseline run without spending money. Review the following fields before you approve or start the run:

* `expectedUsd`: the expected total cost in US dollars across the planned conversations (`episodes`).
* `maxSpendUsd`: the spending limit where the run stops. If the run reaches this limit, it stops and keeps the scenarios that finished.
* `episodes`: the number of planned conversations across the drawn scenarios, at two trials per scenario by default.
* `coveredByFirstRunGrant`: `true` when Connect credit covers the run, so the run starts without spend approval. When `coveredByFirstRunGrant` is `false`, including on runs served by your organization's own provider keys, approve the estimate before you start the run. The product's first simulation is the exception: `start_baseline_simulation` starts it without approval and charges your organization within the first simulation's spending limit, or returns HTTP `402` (`PAYMENT_REQUIRED`) when your organization can't pay. For credit and approval rules, see [Connect credit](/reference/limits-and-pricing#connect-credit).
* `expiresAt`: the timestamp when the estimate expires. Each estimate stays valid for 24 hours and starts one run.

### Draw scenarios on demand

Pass `--draw-scenarios` (or `drawScenarios: true` in the MCP tool) to draw scenarios from production conversations right away.

To draw scenarios on demand, run `start-baseline-simulation` with `--draw-scenarios`:

**`Draw scenarios on demand`**

```bash title="Draw scenarios on demand"
npx @runtypelabs/connect start-baseline-simulation --product-id PRODUCT_ID --agent AGENT_NAME --draw-scenarios --json
```

Replace `PRODUCT_ID` and `AGENT_NAME` as in [Prepare and price the baseline](#prepare-and-price-the-baseline).

Using `--draw-scenarios` has the following behavior:

* Drawing on request is charged to your organization without an approval step after Connect credit runs out, or after 10 credit-paid drawings in the last 24 hours, so your coding agent asks you first. A product's first simulation draws its scenarios the same way without a request.
* On a baseline that already has scenarios, drawing again replaces the drawn scenarios (including your edits to them) and keeps the scenarios you wrote by hand.
* The earlier run and its proposals stay readable by run ID, but they no longer appear when you read the report by product. Until a new run starts, `notes` says so.
* If production conversations haven't changed since the last drawing, Runtype makes no changes and charges nothing. If the baseline already ran on those scenarios, the result keeps `state: "finished"` and that run's `runId`, and `notes` says so. Its `estimate` is the one that run used, so it starts no new baseline run. `next` is the product's next step, as `get_status` gives it. To test new scenarios, add them by hand and run them (see [Run scenarios you add by hand](#run-scenarios-you-add-by-hand)), or send more production conversations and draw again.
* You can't draw scenarios while a run of the baseline is active.

### Run scenarios you add by hand

After a baseline run that graded conversations, you can add scenarios to the baseline's simulation by hand, or edit or remove its scenarios, and then run the baseline on the new set. Add scenarios in the dashboard or with the `add_simulation_scenarios` MCP tool.

A plain `start-baseline-simulation` call keeps the last run. When the enabled scenarios differ from the ones that run played, a `notes` entry says how many were added, edited, or removed. To run the baseline on the new set, pass `--run-changed-scenarios true` (or `runChangedScenarios: true` in the MCP tool):

**`Run changed scenarios`**

```bash title="Run changed scenarios"
npx @runtypelabs/connect start-baseline-simulation --product-id PRODUCT_ID --agent AGENT_NAME --run-changed-scenarios true --json
```

Replace `PRODUCT_ID` and `AGENT_NAME` as in [Prepare and price the baseline](#prepare-and-price-the-baseline).

When the scenarios changed, `--run-changed-scenarios` has the following behavior:

* It prices a new baseline run on the current scenarios and returns its `estimate`, with `runId: null`. A `notes` entry says how many scenarios were added, edited, or removed since that run.
* The new run needs the same approval as any later baseline run: unless Connect credit covers it, approve its `approve_spend` pending action, then start it with `run-simulation`. Until then, `get_status` names that approval as the next step.
* The earlier run's proposals and change brief are no longer available from the baseline, and the run no longer appears when you read the report by product. The run and its proposals stay readable by run ID. Until a new run starts, `notes` names that run.
* Scenarios you wrote by hand are kept. Nothing is drawn, and nothing is charged until the new run starts.

A scenario counts as changed only when what a run plays differs: an added or removed scenario, a changed weight, or a changed task or simulated user. Changing only a task's product, category, or tags isn't a change. If nothing changed, the call returns the last run and `notes` says so. While a run of the baseline or of its proposals is queued or running, the call keeps that run.

## Approve spend and start the run

This section applies to runs after the product's first simulation. When Connect credit covers the run, skip approval and start the run. Otherwise, review the estimate and approve it first. Nothing is spent on the run until you approve it.

To approve an estimate and start the baseline run, follow these steps:

1. Optional: If `state` is `awaiting_approval`, approve the `approve_spend` pending action with `resolve-pending-action` (or the `resolve_pending_action` MCP tool). Skip this step when `coveredByFirstRunGrant` is `true`.

   **`Approve the spend`**

   ```bash title="Approve the spend"
   npx @runtypelabs/connect resolve-pending-action --action-id ACTION_ID --resolution approve --estimate-id ESTIMATE_ID --json
   ```

   Replace the following:

   * `ACTION_ID`: the `pendingAction.id` value from the `start-baseline-simulation` result.
   * `ESTIMATE_ID`: the `estimate.estimateId` value from the same result. Approval applies only to that estimate.

   To decline without running, pass `--resolution dismiss`. Your coding agent asks you first and never approves spend on your behalf.

2. Start the baseline run with `run-simulation` (or the `run_simulation` MCP tool):

   **`Start the run`**

   ```bash title="Start the run"
   npx @runtypelabs/connect run-simulation --estimate-id ESTIMATE_ID --json
   ```

   Replace `ESTIMATE_ID` with the `estimate.estimateId` value from `start-baseline-simulation`. The command returns the run's `runId`.

Running `run-simulation` again with the same estimate returns the same run with `replayed: true` and a `note`, and charges nothing more.

If another run holds your organization's run slot, `run-simulation` refuses the start with `SIMULATION_TOO_MANY_RUNNING`. Start again with the same `estimateId` after that run finishes.

## Follow and list runs

To check progress or view past runs for a product, run `list-runs` (or call the `list_runs` MCP tool):

**`List simulation runs`**

```bash title="List simulation runs"
npx @runtypelabs/connect list-runs --product-id PRODUCT_ID
```

Replace `PRODUCT_ID` with your product ID, or omit `--product-id` when `.env` holds the product's ingest key or your organization has one product.

The command returns up to 20 runs, newest first, with each run's status, progress, spend, and graded episode count. In the dashboard, the product page's **Simulations** section also shows each baseline's state, why a baseline isn't moving, and your Connect credit balance.

Active runs have the status `queued` or `running`. Finished runs have one of the following statuses:

* `completed`: every planned episode finished.
* `budget_exhausted`: the run reached its `maxSpendUsd` limit and kept the scenarios that finished.
* `failed`: the run stopped with an error.
* `cancelled`: the run stopped before completion.

When a run finishes as `completed` or `budget_exhausted` with at least one graded episode, the baseline report is ready. Read the report with `get-report` (or the `get_report` MCP tool). Proposals appear a few minutes later, after the `followUp` step finishes. When no Connect credit is left after a credit-covered run, the report's `notes` state that the copy check and proposals didn't run.

If a finished run graded zero episodes, or ended as `failed` or `cancelled`, it has no baseline result. Inspect why in the report, fix the cause, and run `start-baseline-simulation` again to price a new run.

### Cancel a run

To cancel a `queued` or `running` simulation run and stop further spend, run `cancel-run` (or ask your coding agent to call `cancel_run`):

**`Cancel an active simulation run`**

```bash title="Cancel an active simulation run"
npx @runtypelabs/connect cancel-run --run-id RUN_ID --yes --json
```

Replace `RUN_ID` with the `runId` returned by `run-simulation` or `list-runs`. Outside an interactive terminal, pass `--yes`.

Canceling stops further spend and keeps the finished conversations on a partial report. A canceled run gets no copy check or proposals. You can run `start-baseline-simulation` again to price a new run.

## Troubleshoot baseline errors

If preparing or starting a baseline fails, check the following common causes:

* `TOOL_DEFINITIONS_MISSING`: production traces show calls to tools that neither traces nor your agent map define. Declare the tools with `describe_agents`, or send `gen_ai.tool.definitions` on model spans as shown in [Send a first trace](/connect/send-a-first-trace). Then run `start-baseline-simulation` again.
* `needs_scenarios`: Runtype returned `state: "needs_scenarios"` because it didn't draw scenarios automatically. Read `notes` for the reason, then run `start-baseline-simulation --draw-scenarios` to draw scenarios now.
* `BASELINE_WAITING_FOR_RECORDINGS`: the previous baseline run graded zero episodes because every conversation stopped on a tool that answers only from recordings. Send new production traces that call those tools so the observed profile refreshes (at most once an hour). Then check `get_status`.
* `ESTIMATE_EXPIRED` or `ESTIMATE_STALE`: the estimate is older than 24 hours or no longer matches the baseline. Run `start-baseline-simulation` again to get a current estimate.

For other refusal codes, see [Troubleshooting](/reference/troubleshooting).

## Next steps

* [Read a simulation report](/simulate/read-a-simulation-report): interpret the baseline verdict, scores, confidence, and proposed changes
* [Test a proposed change](/simulate/test-a-proposed-change): run the baseline's proposed changes side by side against the copy
* [Connect MCP tools](/reference/connect-mcp-tools): view the full input and output schemas for every simulation tool
* [Connect CLI](/reference/connect-cli): view every `runtype-connect` command and option