Skip to main content
Quick setup? Copy the scenarios prompt into your coding agent to add scenario tests automatically.
The Scenario SDK is open source and runs inside your own test runner 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 scenario and see the results in LangWatch. For advanced use cases, see the scenario library documentation.

1. Installation

Install the scenario library in your project:

2. Configure Environment Variables

Create a .env file in the root of your project:
.env
You can find your LANGWATCH_API_KEY in your LangWatch project settings.

3. Create a Basic Scenario

Create an agent adapter that calls your agent, then run a scenario against it. For the integration patterns, see the agent integration guide.
Run the test. The scenario run appears under Agent Testing > Results in your LangWatch project.

4. Grouping Your Scenarios into Test Suites and Batches

Set stable identifiers for your scenarios, test suites and batches, so LangWatch groups the runs the same way every time:
  • id: A unique and stable identifier for your scenario. Without it, the id comes from the name, and renaming the test starts a new history.
  • setId: The test suite of the scenario. It appears under From Code on the Scenarios tab, and its runs go under a run plan of the same name on the Results tab.
  • batchId: Groups every scenario run together in one execution, for example one CI job. A CI variable such as process.env.GITHUB_RUN_ID is a good value.
A From Code test suite on the Scenarios tab, with the scenarios of the setId and their last run

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 30, 2026