Skip to main content
Single-turn environments are the simplest type of environment in Verifiers, designed for tasks where the model provides a single response to each prompt. They’re ideal for Q&A tasks, math problems, text transformations, and other one-shot challenges.

Overview

SingleTurnEnv is a specialized version of MultiTurnEnv with max_turns=1. Each rollout follows this simple pattern:
  1. Send the prompt to the model
  2. Receive a single response (the completion)
  3. Score the response using reward functions
No multi-turn interaction, no tools, no complex state management—just prompt, response, and reward.

Your First Environment

Here’s a minimal single-turn environment for math problems:

Real Example: Text Reversal

Let’s examine the reverse-text environment from the repository:
environments/reverse_text/reverse_text.py
Key features:
  • Uses XMLParser to extract structured output from <reversed_text> tags
  • Computes continuous reward based on longest common subsequence
  • Allows customization via system_prompt parameter

Advanced Patterns

Multiple Reward Functions

Combine multiple scoring criteria with custom weights:
The final reward is the weighted sum: reward = 1.0 * check_keywords + 0.1 * length_reward

Parsing Structured Output

Use parsers to extract specific fields from model responses:

Lazy Dataset Loading

For large datasets, defer loading until first access:
Benefits:
  • Avoid loading large datasets during environment initialization
  • Better performance when running multiple replicas
  • Parameterize dataset creation (splits, shuffling, filtering)

Metrics and Observability

Track additional metrics without affecting the reward:
All metrics appear in evaluation results:

Evaluation Datasets

Provide separate train and evaluation datasets:
When you run prime eval run, the evaluation dataset is used automatically.

Common Patterns

Math Verification

Use symbolic math checking with the built-in MathRubric:

LLM-as-Judge

Use another LLM to score responses:

Combining Multiple Rubrics

Use RubricGroup to combine different scoring approaches:
Final reward = math_rubric.reward + judge_rubric.reward

Testing Your Environment

After implementing your environment:

Next Steps