How to force the cloud agent environment to rebuild from scratch when using a Dockerfile

I’m experimenting with setting up the environment for Cloud agents using environment.json and a Dockerfile.

One of my attempts was successful (no errors during docker build and no errors in the install script) and a snapshot of the environment was saved.

Now when I start a new chat with an agent, the environment is always restored from that snapshot, despite the fact that I’ve already pushed some changes to the Dockerfile and to the install script (but not to the environment.json itself - maybe this is the problem?).

I tried waiting for ~8 hours, I tried to create a separate branch with the changes, nothing helped.

How do I force the environment to rebuild?

Update: I did try to make a noop change to my environment.json just to make sure I see the latest version in “Cloud Agents > Environments” settings. It still did not force the full rebuild from the latest Dockerfile and restored from the old snapshot again. That actually made things worse because now it used the latest install script, that depends on the latest Dockerfile, and the install script failed with errors.

Hey, this is a known limitation in the web flow. After the first successful build, a saved environment can keep restoring from an old snapshot even if the Dockerfile and install script in the repo were updated. There isn’t a force rebuild button in the UI yet.

What usually works as a workaround:

  1. Open https://cursor.com/dashboard/cloud-agents > Environments, delete the saved environment for this repo, then create it again. This forces a fresh build with the latest Dockerfile.
  2. Make sure all changes are committed and pushed to the branch the agent starts from. Cloud agents use the config from the commit they start on.
  3. If that doesn’t help, try starting the agent from a brand new branch that has never had an environment created before.

We’re tracking this bug, but I can’t share an ETA for a fix yet. Let me know if recreating the environment helped.