Run a baseline simulation
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.nametoproduction) when there are any, and otherwise your development runs, so the first simulation needs no production traffic. The baseline’snotessay when it was built from development runs. For more information, see 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.
- Tool definitions recorded: If your agent calls tools in production, send
gen_ai.tool.definitionson model spans or declare each tool in your agent map. For more information, see Describe your agents. - A claimed organization: An organization created with
init --no-browseris unclaimed. Before you prepare or start a baseline simulation, claim it withnpx @runtypelabs/connect claim. For more information, see Claim an unclaimed organization. If you authenticate with an API key, the key needs theSIMULATIONS:RUNscope.
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:
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.
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. 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):
Replace the following:
PRODUCT_ID: the product ID thatinitprinted. You can omit--product-idwhen.envor.env.localholds 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 fromget_status. When you omit--agent, Runtype picks the product’s agent with the most traces in the last 30 days and names it innotes.
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.
Check the following fields in the response:
state: where the baseline stands. The value isready_to_run,awaiting_approval,needs_scenarios,running, orfinished. In an unclaimed organization, the call fails with theclaim_requirederror instead.estimate: the pricing details, includingestimateId, ornullwhen scenarios are missing.pendingAction: theapprove_spendaction (with itsid) to resolve before a run that needs approval, ornullwhen no approval is needed.runId: the baseline run ID after a run has started, ornullbefore 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:truewhen Connect credit covers the run, so the run starts without spend approval. WhencoveredByFirstRunGrantisfalse, 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_simulationstarts it without approval and charges your organization within the first simulation’s spending limit, or returns HTTP402(PAYMENT_REQUIRED) when your organization can’t pay. For credit and approval rules, see 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:
Replace PRODUCT_ID and AGENT_NAME as in 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,
notessays 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’srunId, andnotessays so. Itsestimateis the one that run used, so it starts no new baseline run.nextis the product’s next step, asget_statusgives it. To test new scenarios, add them by hand and run them (see 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):
Replace PRODUCT_ID and AGENT_NAME as in 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, withrunId: null. Anotesentry 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_spendpending action, then start it withrun-simulation. Until then,get_statusnames 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,
notesnames 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:
-
Optional: If
stateisawaiting_approval, approve theapprove_spendpending action withresolve-pending-action(or theresolve_pending_actionMCP tool). Skip this step whencoveredByFirstRunGrantistrue.Approve the spendReplace the following:
ACTION_ID: thependingAction.idvalue from thestart-baseline-simulationresult.ESTIMATE_ID: theestimate.estimateIdvalue 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. -
Start the baseline run with
run-simulation(or therun_simulationMCP tool):Start the runReplace
ESTIMATE_IDwith theestimate.estimateIdvalue fromstart-baseline-simulation. The command returns the run’srunId.
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):
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 itsmaxSpendUsdlimit 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):
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 withdescribe_agents, or sendgen_ai.tool.definitionson model spans as shown in Send a first trace. Then runstart-baseline-simulationagain.needs_scenarios: Runtype returnedstate: "needs_scenarios"because it didn’t draw scenarios automatically. Readnotesfor the reason, then runstart-baseline-simulation --draw-scenariosto 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 checkget_status.ESTIMATE_EXPIREDorESTIMATE_STALE: the estimate is older than 24 hours or no longer matches the baseline. Runstart-baseline-simulationagain to get a current estimate.
For other refusal codes, see Troubleshooting.
Next steps
- Read a simulation report: interpret the baseline verdict, scores, confidence, and proposed changes
- Test a proposed change: run the baseline’s proposed changes side by side against the copy
- Connect MCP tools: view the full input and output schemas for every simulation tool
- Connect CLI: view every
runtype-connectcommand and option