---
title: "How to clone a web app as an RL environment for agents"
description: "Clone a web app as an agent environment by self-hosting an open-source app of the same kind in a container image, loading seeded synthetic data, replacing outside services with local fakes, fixing the clock, and reading rewards from its database. Then pin the image and check two runs match."
url: "https://www.agenticrlenvironments.com/guide/clone-a-web-app-as-an-rl-environment/"
site: "AgenticRLEnvironments.com"
author: "AgenticRLEnvironments editors"
published: "2026-11-26"
updated: "2026-11-26"
---

# How to clone a web app as an RL environment for agents

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

Clone a web app as an agent environment by self-hosting an open-source app of the same kind in a container image, loading seeded synthetic data, replacing outside services with local fakes, fixing the clock, and reading rewards from its database. Then pin the image and check two runs match.

To clone a web app as an RL environment, you build a copy you fully control: the same kind of software, realistic data that you generated, no calls to the outside world, and a way to read its state after the agent is done. The clone does not have to be pixel-identical to the real product; it has to present the same tasks and be checkable.

## What does a cloned web app environment contain?

A cloned web app environment contains five things: the app, its data, fakes for outside services, a controlled clock, and a reward reader.

Table: The parts of a cloned web app environment

| Part | What it is | Why it matters |
|---|---|---|
| App | Open-source software of the same category, in a container image | You can run, reset and inspect it |
| Data | Synthetic or sampled records, generated from a seed | Tasks need realistic content; the seed makes it repeatable |
| Fakes | Local versions of payment, email, maps or login providers | No real side effects, same answers every run |
| Clock | A fixed or offset time the app sees | Dates in tasks and data stay valid |
| Reward reader | A database query or API call after the episode | The reward checks what happened, not what was shown |

WebArena is the best-documented example of this approach. Its authors "leveraged open-source libraries relevant to each category to build our own versions" of each site, then "imported sampled data from their real-world counterparts", deployed the sites "in separate Docker images", and provide "scripts to reset the environment to a deterministic initial state" ([WebArena paper, arXiv 2307.13854](https://arxiv.org/html/2307.13854), read 2026-11-26). Its reward functions "programmatically examine the intermediate states", for example through a database query or the site's own API (same source).

## Step 1: How do I choose the app to clone?

Choose an open-source app whose workflows match the tasks you want the agent to learn, not the app whose look is closest.

1. List the tasks the agent must do: "refund an order", "move a ticket to done", "invite a user".
2. Pick an open-source application in the same category that supports those workflows through its interface and has an API or a database you can query.
3. Check its licence allows the use you plan, including redistribution of the image if you share the environment.
4. Build it into a container image from a pinned base, so the environment is one artefact.

## Step 2: How do I fill it with data?

Fill it with data generated from a seed, so every copy of the environment starts the same.

1. Write a loader that creates users, records and history through the app's API or database, using a seeded generator.
2. With the Faker library, call `Faker.seed(4321)` for the shared generator or `fake.seed_instance(4321)` for one instance. Its documentation warns that its datasets change over time, so results can differ across patch versions: pin Faker to an exact version ([Faker documentation](https://faker.readthedocs.io/en/master/), read 2026-11-26).
3. Add the edge cases the tasks need: a pending order among shipped ones, a duplicate customer, an expired coupon.
4. Bake the loaded state into the image, or keep it as a database dump next to the image, so loading is not repeated for every episode.

## Step 3: How do I replace outside services?

Replace every outside service with a local fake that the clone calls instead.

1. List every outbound call the app makes: payments, email, maps, single sign-on, analytics, update checks.
2. Point each one at a small local HTTP service that returns fixed, valid answers. Record what it received, because a grader may need it: "an email was sent to the customer" is checked in the fake mail service.
3. Block all other outbound traffic from the environment, so a forgotten call fails loudly instead of reaching the internet.
4. Turn off the app's telemetry and update checks in its configuration.

## Step 4: How do I control time?

Control time by giving the app a fixed starting date, because tasks such as "orders from last week" depend on it.

The libfaketime library "intercepts various system calls that programs use to retrieve the current date and time" and reports a faked time to one program without changing the system clock. It is loaded with `LD_PRELOAD` and set with `FAKETIME`; a value with `@`, such as `FAKETIME="@2020-12-24 20:30:00"`, starts the clock at that date and lets it run, while a value without `@` freezes it. Its documentation notes it does not work with statically linked binaries or setuid programs ([libfaketime repository](https://github.com/wolfcw/libfaketime), read 2026-11-26). Prefer a start date to a frozen clock: apps that measure elapsed time misbehave when the clock stops.

## Step 5: How do I read the reward from the clone?

Read the reward from the app's state after the episode, through its database or API.

1. For each task, write the query that shows success: the order's status, the ticket's column, the user's role.
2. Also query what must not have changed. AppWorld's state-based tests check for "collateral damage" as well as success ([AppWorld, arXiv 2407.18901](https://arxiv.org/abs/2407.18901), read 2026-11-26).
3. Run the grader against the hidden state, never against the agent's last message. See [writing a grader](https://www.agenticrlenvironments.com/guide/write-a-grader-for-an-agent-environment/).

## Step 6: How do I prove the clone is reproducible?

Prove it by starting two copies from the same image digest and seed, running the same scripted actions in both, and comparing the database afterwards.

1. Pin the image by digest, not by tag. Docker's documentation says pulling by digest lets you "specify exactly which version of an image to pull" and that this "pins" an image to a specific version in time ([docker image pull](https://docs.docker.com/reference/cli/docker/image/pull/), read 2026-11-26).
2. Start two copies, run a fixed script of actions, and dump the tables the graders read.
3. Diff the dumps. Any difference is non-determinism to remove before training: an unseeded generator, the real clock, an outside call, or a background job.

Resetting between episodes is the other half of the job; the simplest reliable method is to throw the copy away and start a new one from the image. Versioning the clone over time is covered in [versioning agent environments](https://www.agenticrlenvironments.com/guide/version-and-reproduce-agent-environments/).

## What we read for this article

- [WebArena (arXiv 2307.13854)](https://arxiv.org/html/2307.13854), read 2026-11-26
- [AppWorld (arXiv 2407.18901)](https://arxiv.org/abs/2407.18901), read 2026-11-26
- [Faker documentation](https://faker.readthedocs.io/en/master/), read 2026-11-26
- [libfaketime repository](https://github.com/wolfcw/libfaketime), read 2026-11-26
- [docker image pull: pull by digest](https://docs.docker.com/reference/cli/docker/image/pull/), read 2026-11-26

## FAQ

### Why not train agents on the live website?

A live site changes, cannot be reset, may forbid automated use, and makes every mistake real. A self-hosted clone can be reset to a known state, run many times in parallel, and inspected directly to compute a reward.

### Do I have to rebuild the app from scratch?

Usually not. Published environments start from open-source software of the same category and add data. WebArena's authors used open-source libraries for each kind of site and imported data sampled from real counterparts.

### How do I make a cloned app deterministic?

Seed every random generator that creates data, freeze or offset the clock the app sees, replace outside services with fakes that answer the same way each time, and pin the image by digest. Then check it by building twice from one seed and comparing the database.

### Where should the reward come from in a cloned web app?

From the app's state: a database query or an API call after the episode. Reading the page the agent saw is weaker, because a page can show success that did not happen.
