Skip to contentSkip to page list

Docs

Use Parameters and Test Suites Well

Use run parameters for values that change between runs of the same world, keep fixtures with their scenario, and group scenarios into test suites by what they protect.

On this page

Where we are in the story: Anna's scenario has its criteria and its fixtures, and setup and teardown build and remove her world. Now we want more than one run of it: against two models, in two regions, and next to the other refund cases.

A parameter changes a value, not the world

A run parameter is a value the run supplies, read by the scenario text as {{ params.NAME }} and by the agent under test. Use one for a value that can change while the world stays the same: the model, the region, the language of the conversation. One scenario then covers each value, and every result records which value it ran with.

Do not use a parameter to switch worlds. A has_orders=false flag that makes setup skip Anna's order turns one scenario into two with one set of criteria, and the criteria cannot be right for both. Write Anna with no orders as its own scenario, with its own fixtures.

Fixtures are parameters keyed by entity type

Fixtures are run parameters too: one parameter per entity type, such as customers and orders, holding the scenario's entities as its default value. A Scenario Connector reads them in input["params"], and setup and teardown hooks read them in run.fixtures (langwatch SDK release after 2.5.0 / 2.0.1). LangWatch checks every $ref when the run starts and refuses a broken one with scenario_parameter_fixture_invalid.

Set fixtures in the scenario editor with + Fixture, which offers the types the project's connectors declare, or with the scenario REST API: see how fixtures are set.

Group scenarios into suites by what they protect

A test suite is a named group of scenarios you run together. Group by the behaviour a release must not break: a Refunds suite holds Anna with a delivered order, Anna with an order in transit, and a customer who asks for someone else's order. Run the suite before a release, and its pass rate is the refund behaviour's health.

In code, the same grouping is the setId (set_id in Python), so every run of a test joins one history. Give each scenario a stable id too, so renaming a test does not start a new history.

Also check: Run parameters, Test suites, Compare agents.

Next: Running and CI, to run the suite often enough to trust it.

Documentation