CoolFace
Apppublic

devaatmik/shopify-store-audit

sourceHugging Faceupdated 5mo agoView on Hugging Face
2likes
App README

Shopify Store Audit & Remediation — OpenEnv Environment

Train AI agents to find and fix real e-commerce store issues through the Shopify Admin API.

Motivation

Store auditing is a $5K–$15K consulting service that Shopify merchants regularly pay for. Every store accumulates issues: missing product descriptions, broken pricing, SEO gaps, inventory discrepancies, empty collections, stuck orders. This environment uses real Shopify product data (45 products from actual CSV exports) and lets AI agents learn to diagnose and fix them through API operations that map 1:1 to Shopify Admin GraphQL mutations.

Why this matters for the agent community:

  • Real data — 45 products loaded from real Shopify CSV exports (apparel + jewelry catalogs)
  • 184 discoverable issues — auto-scanned from real data quality gaps + synthetic injections
  • Randomised episodes — different issues sampled each reset (seeded for reproducibility)
  • Shaped rewards — discovery, partial fix, efficiency bonus, regression & repetition penalties
  • Genuine difficulty progression — hint level scales from guided to fully autonomous exploration
  • 18 API commands mirroring real Shopify Admin GraphQL mutations

How It Works

The environment loads real Shopify product exports (apparel.csv, jewelery.csv) containing 45 products across apparel, bags, footwear, jewelry, outdoor gear, and home goods. An IssuePool scans the catalog and discovers real data quality issues (0/45 products have SEO titles, 0/45 have image alt text, 20/20 jewelry products have no SKUs, plus handle typos and formatting artifacts). Synthetic issues (corrupted prices, draft products, negative inventory) are generated on top.

On each reset(seed=N), the pool randomly samples 8/12/20 issues depending on the task. Different seed = different bugs. The agent must discover and fix them through API commands.

Difficulty Tiers

The three tasks aren't just "more items" — they differ in how much the agent is told:

TaskIssuesSteps`query_store_health` returnsAgent must...
Easy825Each issue + suggested command nameFill in the right params
Medium1235Issue descriptions onlyFigure out which command AND params
Hard2050Only category counts (e.g. "16 SEO issues")Explore, discover, diagnose, and fix

Reward Function

Multi-signal shaped reward that provides gradient throughout the episode:

SignalRewardWhen
Full fix+1/NIssue fully resolved (N = total issues)
Partial fix+0.03Mutation targets the right resource but wrong value
Discovery+0.02First query of a resource that has an issue
Efficiency bonus+0.01Fixing without querying that resource first
Query cost-0.005Exploration has a small cost
Failed mutation-0.01Wrong resource or field targeted
Repetition-0.02Exact same command+params sent again
Regression-0.15Broke something that was previously correct

This means a weak agent that explores but fails to fix still earns discovery rewards. A careless agent that breaks things gets punished. A perfect agent earns close to 1.0.

Action Space

Actions are JSON objects with a command and params:

json
{"command": "update_product_seo", "params": {"product_id": "ayers-chambray", "seo_title": "Ayres Chambray | Store"}}
CommandTypeDescription
query_productsQueryList/filter products (params: status, search, product_type, limit)
query_productQueryGet product detail (params: product_id)
query_collectionsQueryList all collections
query_collectionQueryGet collection detail (params: collection_id)
query_inventoryQueryGet inventory levels (params: product_id, location_id)
query_ordersQueryList orders (params: fulfillment_status)
query_store_healthQueryDiagnostic overview (detail varies by difficulty)
update_productMutationUpdate product fields (description, status, tags)
update_variantMutationUpdate variant (price, compareatprice, sku)
update_product_seoMutationSet SEO title/description
update_image_alt_textMutationSet image alt text
add_product_imageMutationAdd image to a product
update_collectionMutationUpdate collection fields/rules
add_product_to_collectionMutationAdd product to collection
remove_product_from_collectionMutationRemove product from collection
adjust_inventoryMutationSet inventory quantity at location
update_metafieldMutationSet metafield value
publish_productMutationSet product status to active
update_orderMutationUpdate order fulfillment status

Observation Space

FieldTypeDescription
messagestrHuman-readable result description
datadictStructured API response data
issues_remainingintUnfixed issues count
issues_fixedintIssues fixed so far
total_issuesintTotal issues in task
store_health_scorefloatStore health (0.0–1.0)
available_commandslist[str]Available commands
task_namestrCurrent task ID
doneboolWhether episode has ended
rewardfloatStep reward (shaped, multi-signal)

Baseline Scores

TaskModelScoreStepsBehavior
product_listing_qagpt-4o99%16/25Reads hints, fixes all 8 issues efficiently
seo_collection_optimizationgpt-4o99%28/35Investigates then fixes, figures out commands from descriptions
full_store_auditgpt-4o1%50/50Gets stuck — can't reason from category counts to specific fixes

The hard task genuinely challenges frontier models. An agent trained via RL on this environment would need to learn exploration strategies that gpt-4o doesn't exhibit out of the box.

Setup Instructions

Prerequisites

  • Python 3.10+
  • Docker
  • openenv-core (pip install openenv-core)

Local Development

bash
cd /path/to/project
pip install -e .

# Start server
uvicorn server.app:app --host 0.0.0.0 --port 8000

# Test
curl http://localhost:8000/health
curl http://localhost:8000/tasks
curl -X POST http://localhost:8000/reset -H "Content-Type: application/json" -d '{}'

Docker

bash
docker build -t shopify-store-audit .
docker run -p 8000:8000 shopify-store-audit

Run Inference

bash
export API_BASE_URL="https://api.openai.com/v1"
export MODEL_NAME="gpt-4o"
export HF_TOKEN="your-api-key"
export ENV_URL="http://localhost:8000"

python inference.py

Validate

bash
openenv validate

Shopify API Mapping

Every environment command maps to a real Shopify Admin GraphQL operation:

Environment CommandShopify GraphQL Equivalent
update_productproductUpdate mutation
update_variantproductVariantUpdate mutation
update_product_seoproductUpdate (seo fields)
update_image_alt_textproductImageUpdate mutation
add_product_imageproductCreateMedia mutation
update_collectioncollectionUpdate mutation
add_product_to_collectioncollectionAddProducts mutation
adjust_inventoryinventoryAdjustQuantities mutation
update_metafieldmetafieldsSet mutation
publish_productpublishablePublish mutation
update_orderorderUpdate mutation
query_productsproducts query
query_inventoryinventoryLevels query

Agents trained here learn patterns directly transferable to real Shopify store management via Shopify MCP or Shopify CLI.

Architecture

├── apparel.csv, jewelery.csv    # Real Shopify product exports (45 products)
├── models.py                    # Pydantic Action & Observation types
├── client.py                    # EnvClient for WebSocket connection
├── openenv.yaml                 # OpenEnv spec metadata
├── pyproject.toml               # Dependencies
├── Dockerfile                   # Container definition
├── inference.py                 # Baseline agent (runs all 3 tasks)
├── test_live.py                 # WebSocket integration test
└── server/
    ├── app.py                   # FastAPI + /tasks + /grade endpoints
    ├── shopify_store_audit_environment.py  # Environment (reset/step/state)
    ├── store.py                 # CSV loader, IssuePool, ShopifyStore CRUD
    ├── tasks.py                 # TaskConfig (num_issues, hint_level, categories)
    └── graders.py               # Per-task grading functions

Extensibility

The architecture supports connecting to a real Shopify store via the Admin GraphQL API. The ShopifyStore class can be subclassed with a LiveShopifyStore that makes real API calls instead of in-memory mutations. Environment variables SHOPIFY_STORE_URL and SHOPIFY_ACCESS_TOKEN would enable live mode. The action space and observation format remain identical — the agent doesn't know which mode it's in.

License

MIT