How ShopGym Builds Realistic Sandboxes for Shopping Agents

Peter Bubenik · Shopify ML · · Source
Image for ShopGym: Realistic, reproducible sandboxes for shopping agents (2026) - Shopify

Learning Outcomes

After studying this material, you should be able to:

  1. Explain why training and evaluating shopping agents is difficult in real-world environments
  2. Describe what ShopGym is and what problem it solves
  3. Distinguish between ShopArena and ShopGuru and explain each component's role
  4. Trace the step-by-step process of how a live storefront becomes a sandbox environment
  5. Understand how ShopGym validates quality through structural and behavioral evaluation
  6. Evaluate the tradeoffs between realism and reproducibility in agent testing environments

Step 1: Understanding the Core Problem

Why Is Testing Shopping Agents Hard?

Before learning the solution, you need to understand what makes this problem difficult.

Imagine you are building an AI agent that helps users shop online. You need to:

  • Train it repeatedly on the same scenarios
  • Compare different versions fairly
  • Debug when something goes wrong

But real online stores create three major obstacles:

ObstacleWhy It Matters
Constant changeProducts go out of stock, prices update, layouts redesign — your test from yesterday may not run today
Bot detectionStores block automated traffic, interrupting your agent mid-task
Limited hand-built storesYou can build a fake store manually, but it won't capture the full complexity of real shopping behavior

Key Insight: You need an environment that is both controllable (like a fake store) and realistic (like a real store). ShopGym is built to solve exactly this tension.


Step 2: What ShopGym Is — The Big Picture

The Core Idea

ShopGym takes a live storefront and converts it into a self-contained sandbox — a frozen, resettable copy that agents can interact with repeatedly under identical conditions.

Think of it like this:

Live Store (messy, changing, blocks bots)
        ↓
ShopGym processes it
        ↓
Sandbox Store (stable, resettable, agent-friendly)
        +
Shopping Tasks (grounded in that store's real products and policies)

Two Components Working Together

ShopGym has two distinct frameworks:

  • ShopArena → Builds the environment (the sandbox store)
  • ShopGuru → Builds the benchmark (the shopping tasks)

Analogy: ShopArena builds the exam room. ShopGuru writes the exam questions.


Step 3: How ShopArena Works — Building the Environment

ShopArena has two clearly separated phases. Understanding why they are separated is as important as knowing what each does.

Phase 1: Exploration (Reading the Real Store)

ShopArena sends agents to explore the live storefront's key surfaces:

  • Homepage
  • Sitemap
  • Search and cart endpoints
  • Product catalog
  • Policy pages (returns, shipping, etc.)

A planner agent divides this exploration into focused tasks. For each task, a fresh specification agent browses the store and writes an anonymized fragment.

These fragments collectively describe three things:

Fragment TypeWhat It Captures
Design specificationVisual style, layout, overall look and feel
Structured attributesFilters, navigation menus, pagination behavior
Catalog statisticsNumber of products, price ranges, category distribution

Critical detail — Anonymization: While writing fragments, agents deliberately omit:

  • Brand names
  • Product names
  • People's names
  • Absolute URLs

This means the output is a structural description, not a copy of the store. No separate redaction step is needed later.

Finally, a consolidation step merges all fragments into one unified shop specification.

Why separate exploration from generation? The specification acts as the only interface between the two phases. This means generation never touches the original store — making the process cleaner, more auditable, and privacy-respecting.


Phase 2: Generation (Building the Sandbox)

The generation phase reads only the specification — never the original store data.

Step-by-step generation sequence:

1. Generate fictional product catalog
   (collections, names, descriptions, images)
        ↓
2. Build site shell and homepage
        ↓
3. Build collection pages
        ↓
4. Build product pages
        ↓
5. Build cart functionality
        ↓
6. Build search and filtering
        ↓
7. Build policy pages
        ↓
8. Final integration pass

Each step follows the same execution-verification loop:

Fresh execution agent reads:
  → current code
  → relevant specification
  → catalog data
  → latest feedback report
        ↓
Agent edits code + runs lightweight checks
        ↓
Rule-based checks verify:
  → build success
  → required routes exist
  → output structure is correct
        ↓
Visual verification agent:
  → hosts the shop in a browser
  → inspects it visually
  → writes feedback for next iteration

Why start a fresh agent each iteration? Keeping the working context small prevents the agent from being overwhelmed by accumulated history. The code holds current state, the specification holds intent, and the report describes what to fix next.

Key benefit: If one feature fails, ShopArena repairs just that feature — it does not regenerate the entire shop.


Step 4: How ShopGuru Works — Building the Tasks

Once the sandbox store exists, ShopGuru creates shopping tasks grounded in that specific store's actual products, navigation, filters, and policies.

Two Types of Tasks

Simple/Focused Tasks (rule-based generation):

  • Find a specific product
  • Locate the return policy
  • Check if a product is in stock

Multi-step Journey Tasks (LLM-generated):

  • Open a collection → filter by color → sort by price → add matching product to cart

Quality Control Loop

Task generated
      ↓
Automated checks verify:
  → Products referenced exist in the shop
  → Collections referenced exist
  → Filter options referenced exist
      ↓
If checks fail → LLM receives feedback → revises task

Why does grounding matter? A task that references a product that doesn't exist in the sandbox is useless. This verification loop ensures every task is actually solvable.


Step 5: How ShopGym Was Validated

ShopGym tested quality in two ways across 224 tasks, 6 sandbox shops (3 synthetic, 3 real-data twins).

Validation Method 1: Structural Fidelity

Researchers mapped both real and synthetic shops as graphs:

  • Nodes = interface states (e.g., homepage, open menu, cart drawer)
  • Arrows = actions that move between states

Findings:

PropertyResult
Number of distinct statesSimilar between real and synthetic
Page complexityComparable
Connections between statesFewer in synthetic (expected — no external links or marketing pages)

Conclusion: Synthetic shops preserve the core navigational structure of real stores, with minor expected differences.


Validation Method 2: Behavioral Alignment

Two agent evaluation systems tested both live stores and their sandbox twins:

  • BrowserGym (uses accessibility tree observations)
  • Internal system (uses screenshots + accessibility tree)

Key findings:

  • Success rates on sandbox twins were similar to success rates on live stores
  • Multi-step tasks showed the strongest alignment — model rankings were preserved
  • Focused tasks showed larger gaps, especially in the internal system

What this means: The twins are not perfect replicas, but they preserve meaningful difficulty signals — especially for complex tasks. An agent that performs well on the sandbox tends to perform well on the live store.


Step 6: The Bigger Picture — Why This Matters

For Developers

  • Reproduce failures reliably
  • Compare agent versions under identical conditions
  • Measure whether improvements actually help

For Merchants

  • Agents can practice on sandboxes before touching live stores
  • Works across store types: clothing, electronics, cookware, home improvement, digital goods

The Core Tradeoff Resolved

ApproachReproducible?Realistic?
Live stores✗✓
Hand-built fake stores✓✗
ShopGym sandboxes✓✓ (approximately)

Summary: The Full ShopGym Workflow

LIVE STOREFRONT
      ↓
[ShopArena - Exploration Phase]
  Planner agent divides work
  Specification agents explore + write anonymized fragments
  Consolidation merges fragments into shop specification
      ↓
[ShopArena - Generation Phase]
  Reads specification only (never original store)
  Generates fictional catalog
  Builds store in fixed sequence with execution-verification loops
      ↓
SANDBOX STORE
      ↓
[ShopGuru - Task Generation]
  Rule-based generators → simple tasks
  LLM → multi-step journey tasks
  Automated checks verify task validity
      ↓
BENCHMARK TASKS
      ↓
[Evaluation]
  Structural graph comparison
  Agent behavioral testing on live vs. sandbox

Quick Self-Check Questions

  1. What three problems make testing shopping agents on live stores difficult?
  2. What is the difference between ShopArena and ShopGuru?
  3. Why does ShopArena separate exploration from generation?
  4. What does anonymization during exploration accomplish?
  5. Why does the generation phase start a fresh agent for each iteration?
  6. How does ShopGuru ensure tasks are actually solvable?
  7. What did the behavioral evaluation reveal about multi-step vs. focused tasks?
  8. In your own words, what tradeoff does ShopGym resolve?

More to study