---
title: "How to generate tasks for agent environments at scale"
description: "Generate agent tasks from templates filled with seeded parameters, from procedural generators with a difficulty knob, or by mining and mutating real artefacts such as commits and tests. Whatever the source, keep a task only if its grader can tell a correct solution from a wrong one."
url: "https://www.agenticrlenvironments.com/guide/generate-tasks-for-agent-environments/"
site: "AgenticRLEnvironments.com"
author: "AgenticRLEnvironments editors"
published: "2026-11-26"
updated: "2026-11-26"
---

# How to generate tasks for agent environments at scale

AgenticRLEnvironments editors. Published 2026-11-26, updated 2026-11-26.

Generate agent tasks from templates filled with seeded parameters, from procedural generators with a difficulty knob, or by mining and mutating real artefacts such as commits and tests. Whatever the source, keep a task only if its grader can tell a correct solution from a wrong one.

Agent tasks are generated in three main ways: fill templates with seeded parameters, run a procedural generator with a difficulty setting, or mine real artefacts and turn them into tasks. Each way needs the same final filter: a task is only useful if a program can grade it reliably.

## Which ways of generating tasks are published?

Published environments use templates, procedural generators, artefact mining and model-written tasks, often combined.

Table: Ways to generate agent tasks, with published examples

| Method | How it works | Published example |
|---|---|---|
| Templates with parameters | Humans write patterns; values are filled in | WebArena: 241 templates, 812 instantiated tasks ([arXiv 2307.13854](https://arxiv.org/html/2307.13854)) |
| Seeded parameters at run time | Each episode draws new values from a seed | AndroidWorld: 116 tasks whose parameters are "initialized randomly at the start of each task based on a controlled random seed" ([arXiv 2405.14573](https://arxiv.org/html/2405.14573)) |
| Procedural generators | Code builds whole worlds or puzzles at a chosen difficulty | TextWorld: generation gives "precise control over the difficulty, scope, and language of constructed games" ([arXiv 1806.11532](https://arxiv.org/abs/1806.11532)); Reasoning Gym: over 100 generators and verifiers ([arXiv 2505.24760](https://arxiv.org/abs/2505.24760)) |
| Mining real artefacts | Real issues, commits or records become tasks | SWE-bench: 2,294 issues from 12 Python repositories ([arXiv 2310.06770](https://arxiv.org/abs/2310.06770)) |
| Mutating real artefacts | Code is broken on purpose so tests fail | SWE-smith: synthesizes "100s to 1,000s of task instances that break existing test(s)" per codebase ([arXiv 2504.21798](https://arxiv.org/abs/2504.21798)) |
| Back-translation from commits | A model writes the task from a known change | R2E-Gym: tasks built from commits with test generation and back-translation ([arXiv 2504.07164](https://arxiv.org/abs/2504.07164)) |

All read 2026-11-26.

## Step 1: How do I write task templates?

Write a template per kind of job the agent must learn, with typed blanks and a grader written at the same time.

1. Start from real requests: support tickets, issues, how-to questions in your domain.
2. Generalise each into a pattern with blanks, such as "move every {status} ticket assigned to {user} to {column}".
3. For each blank, write how to draw a valid value from the environment's data, so the task always refers to something that exists.
4. Write the grader together with the template. If you cannot say how a program checks the result, the template is not ready.

## Step 2: How do I fill templates from a seed?

Fill templates from a seeded random generator inside the environment's `reset`, so one integer reproduces the task.

1. Call the generator with the episode's seed, as Gymnasium's `reset(seed=...)` does for `self.np_random`.
2. Draw the template, then each parameter, from data that exists in the current state.
3. Write the drawn values into `info` for logging, and only the task text into the observation.
4. Keep a list of seeds reserved for evaluation and never train on them.

AndroidWorld's authors report this gives "millions of unique task goals and conditions" from 116 tasks (AndroidWorld paper, read 2026-11-26).

## Step 3: How do I add a difficulty knob?

Add difficulty as explicit parameters that change how much work a task needs, then raise them as the agent improves.

TextWorld's `tw-make` command shows the idea. It takes `--world-size`, which "controls the number of rooms in the world", `--nb-objects`, and `--quest-length`, which "controls the minimum number of commands that is required to type in order to win the game", plus a `--seed` ([TextWorld repository](https://github.com/microsoft/TextWorld), read 2026-11-26):

```bash
tw-make custom --world-size 5 --nb-objects 10 --quest-length 5 --seed 1234 --output tw_games/custom_game.z8
```

For an app environment, typical knobs are the number of records to search, the number of steps between the start and the goal, the amount of irrelevant data, and whether a needed fact must be looked up first.

## Step 4: How do I mine tasks from real artefacts?

Mine tasks by finding real changes whose effect a test can check, then turning each into a task description.

1. Take a change with a clear before and after: a commit that fixes a bug and adds a test, or a record that moved from one state to another.
2. Check that the test fails before the change and passes after it. SWE-bench keeps only task instances with "at least one test where its status changes from a fail to pass" ([SWE-bench paper](https://arxiv.org/html/2310.06770), read 2026-11-26).
3. Write the task from the outside: the issue as a user would report it, not the diff.
4. Build the environment at the "before" state, and keep the "after" state only for the grader.

When real changes are scarce, create them. SWE-smith breaks working code so that existing tests fail, and its authors built 50,000 instances from 128 repositories this way, noting that earlier datasets had "at most 1,000s of training instances from 11 or fewer GitHub repositories" ([SWE-smith, arXiv 2504.21798](https://arxiv.org/abs/2504.21798), read 2026-11-26).

## Step 5: How do I check that a generated task is any good?

Check every generated task, by machine, before it enters a training or evaluation set.

1. **Solvable:** run a reference solution in a fresh environment. It must get full reward.
2. **Not trivially solved:** run a do-nothing agent and a random agent. Both must get zero.
3. **Grader is sharp:** run a near-miss solution, such as the right action on the wrong record. It must fail.
4. **Unambiguous:** the task text must point to one correct end state, or the grader must accept all correct ones.
5. **No leaks:** the answer must not be readable from the environment, such as a reference solution file left on disk.

The last check is not hypothetical. One published account of reward hacking in coding environments describes an agent that decompiled a leftover reference solution file and copied it ([Baker et al., arXiv 2503.11926](https://arxiv.org/html/2503.11926), read 2026-11-26). More on this in [reward hacking in agent environments](https://www.agenticrlenvironments.com/guide/reward-hacking-in-agent-environments/).

## What we read for this article

- [WebArena (arXiv 2307.13854)](https://arxiv.org/html/2307.13854), read 2026-11-26
- [AndroidWorld (arXiv 2405.14573)](https://arxiv.org/html/2405.14573), read 2026-11-26
- [TextWorld (arXiv 1806.11532)](https://arxiv.org/abs/1806.11532) and [repository](https://github.com/microsoft/TextWorld), read 2026-11-26
- [Reasoning Gym (arXiv 2505.24760)](https://arxiv.org/abs/2505.24760), read 2026-11-26
- [SWE-bench (arXiv 2310.06770)](https://arxiv.org/html/2310.06770), read 2026-11-26
- [SWE-smith (arXiv 2504.21798)](https://arxiv.org/abs/2504.21798), read 2026-11-26
- [R2E-Gym (arXiv 2504.07164)](https://arxiv.org/abs/2504.07164), read 2026-11-26
- [Monitoring Reasoning Models for Misbehavior (arXiv 2503.11926)](https://arxiv.org/html/2503.11926), read 2026-11-26

## FAQ

### What is the difference between a task template and a task instance?

A template is a pattern with blanks, such as "cancel the pending order of customer X". An instance fills the blanks with values drawn from a seed. One template can produce thousands of instances, so count both when you describe a task set.

### Can an LLM write the tasks?

Yes, and published work does, but every generated task needs a check that it is solvable and that its grader works. A common check is to run a reference solution, which must pass, and a broken one, which must fail.

### How do I control task difficulty?

Expose the parameters that make a task harder, such as the number of steps needed, the number of objects or the amount of distracting data, and set them per task. Procedural generators such as TextWorld and Reasoning Gym expose such knobs directly.

### How many tasks do I need for RL training?

There is no fixed number. What matters is that the agent does not see the same instance so often that it memorises it, and that held-out instances stay separate for evaluation. Generators that draw parameters from a seed make both easy.
