Skip to main content
Quick setup? Copy the scenarios prompt into your coding agent to add simulation tests automatically.
Scenarios in code run with the open-source Scenario SDK, inside your own test suite and CI. To run scenarios from the platform against your agent’s HTTP endpoint instead, with no test code, see Connect your agent. This guide will walk you through the basic setup required to run your first simulation and see the results in LangWatch. For more in-depth information and advanced use cases, please refer to the official scenario library documentation.

1. Installation

First, you need to install the scenario library in your project. Choose your language below.

2. Configure Environment Variables

We recommend creating a .env file in the root of your project to manage your environment variables.
.env
You can find your LANGWATCH_API_KEY in your LangWatch project settings.

3. Create a Basic Scenario

Here’s how to create and run a simple scenario to test an agent. First, you need to create an agent adapter that implements your agent logic. For detailed information about agent integration patterns, see the agent integration guide.
Once you run this code, you will see a new scenario run appear under Agent Testing > Results in your LangWatch project.

4. Grouping Your Sets and Batches

While optional, we strongly recommend setting stable identifiers for your scenarios, sets, and batches for better organization and tracking in LangWatch.
  • id: A unique and stable identifier for your scenario. If not provided, it’s often generated from the name, which can be brittle if you rename the test.
  • setId: Groups related scenarios into a set. The set appears under Agent Testing > Results.
  • batchId: Groups all scenarios that were run together in a single execution (e.g., a single CI job). You can use a CI environment variable like process.env.GITHUB_RUN_ID for this.

5. Let the Judge Read Your Traces

When your adapter calls an agent that runs as a separate service, the judge cannot see what happens inside it. Turn on trace fetching and the judge also reads the traces your agent reports to LangWatch, one per conversation turn, before its verdict:
Spread input.propagation_headers (Python) or input.propagationHeaders (TypeScript) onto your adapter’s outgoing HTTP request, so the remote service joins each turn’s trace. Linking your traces covers the mechanism, the wait behavior, and how to write trace-aware criteria.
Last modified on August 22, 2026