Template Guidelines
Evals and Scenarios
Explains how to define eval scenarios and batches on the _eval context to test an agent's high-level behavior.
Stubber has a standard mechanism for evaluating (eval) agents built in the framework. Every template has an _eval context, which provides what you need to run evaluation chats with your agent.
You define scenarios on the _eval context. Each scenario tests a specific behavior of the agent, and a template can have one or many.
The flow components library has examples of scenarios and scenario batches. Add annotations to the _eval flow if it has none, so the scenario and batch configuration is easy to find and edit (the library items show how).
Defining scenarios
Scenarios are defined in the eval.scenarios object in the _eval context's template data. The object has one key per scenario, in snake_case.
Each scenario has this structure (shown with its key):
Key terms
statement: what the scenario asserts.prompt: the prompt for the scenario agent, which plays the user. Don't reveal details about the flow; keep it simple, as a real user wouldn't know them.summary_prompt: an optional prompt used to summarize the chat log.rubrics: rubrics the summary and chat log are scored against once the scenario has finished. A fast model evaluates each one against itsthreshold.checks: deterministic true/false checks on the target stub's data.scenario_number: an easy way to identify the scenario in the eval.limits: limits on how far the scenario can run.roles: custom role labels. Theassistantrole is the scenario agent, and theuserrole is the template being tested.fixtures: test data.stub_datais added to the target stub (stub.data) automatically when the scenario runs.
Adding and editing scenarios
Check the _eval context for existing scenarios and configuration, then add or edit scenarios to cover the cases you want to test.
Writing scenario prompts
The scenario prompt is what the scenario agent receives before it chats to the flow being evaluated.
- Keep the prompt simple and direct.
- If the scenario agent must do a few steps in order, tell it what to do first and when to wait for a reply before continuing. Otherwise it may ask for everything up front, which defeats the purpose of the eval.
- Don't reveal how the flow works. The scenario agent should behave like a real user.
- Give the scenario agent the details it may need, such as a name or account details, and tell it to provide them only when the agent asks.
One-off scenarios
You can also run a one-off scenario to check that a specific piece of functionality works, by passing the scenario definition object directly instead of saving it in eval.scenarios.
Batches
Batches of scenarios are defined in the eval.batches object in the _eval context's template data. This example defines a batch called full:
A batch lists one or more scenarios, each with a run count.
Results
Once a scenario or batch run starts, the eval is updated as it is started, ended and evaluated. Wait for the final evaluated result of a scenario or batch before deciding what to change in your agent.
Flowpilot can create, edit and run scenarios and batches for you.