Skip to main content

Gymnasium-compatible SDK for ThetaBench web agent training & evaluation

Project description

ThetaBench Python SDK

Gymnasium-compatible SDK for training and evaluating web agents on ThetaBench environments.

Installation

pip install thetabench

# With browser mode support (Playwright)
pip install 'thetabench[browser]'
playwright install chromium

Quick Start

REST Mode (Fast Training — 1-5ms/step)

import thetabench

env = thetabench.make("shopify-admin", task_id="prod-001")
obs, info = env.reset()

print(f"Task: {info['task_goal']}")
print(f"Max steps: {info['max_steps']}")

done = False
while not done:
    # Your agent decides what to do
    action = {"action": "update_product", "productId": "1", "fields": {"price": "34.99"}}
    obs, reward, terminated, truncated, info = env.step(action)
    done = terminated or truncated

result = env.finish()
print(f"Score: {result['score']:.0%} | Steps: {result['steps']} | Reward: {result['total_reward']:.2f}")
env.close()

Browser Mode (Realistic Evaluation)

import thetabench

env = thetabench.make("shopify-admin", task_id="prod-001", mode="browser")
obs, info = env.reset()

# obs includes screenshot, accessibility tree, and URL
print(f"URL: {obs['url']}")

action = {"type": "navigate", "url": "/admin/products/1"}
obs, reward, terminated, truncated, info = env.step(action)

action = {"type": "fill", "selector": "#price", "value": "34.99"}
obs, reward, terminated, truncated, info = env.step(action)

action = {"type": "click", "selector": "button:has-text('Save')"}
obs, reward, terminated, truncated, info = env.step(action)

result = env.finish()
env.close()

Curriculum Training

import thetabench

def my_agent(obs, info):
    # Your agent logic here
    return {"action": "navigate", "target": "/admin/products"}

runner = thetabench.CurriculumRunner(
    base_url="http://localhost:3000",
    mastery_threshold=0.8,
)

for stage_result in runner.run(my_agent):
    print(f"Stage {stage_result['stage']}: {stage_result['title']}")
    print(f"  Score: {stage_result['avg_score']:.0%}")
    print(f"  Mastery: {'Yes' if stage_result['mastery_achieved'] else 'No'}")

runner.close()

Browse Tasks

from thetabench import ThetaBenchClient

client = ThetaBenchClient("http://localhost:3000")

# List all tasks
tasks = client.list_tasks()
print(f"Total tasks: {tasks.total}")

# Filter by domain and difficulty
easy_product_tasks = client.list_tasks(domain="products", difficulty="easy")
for t in easy_product_tasks.tasks:
    print(f"  {t.id}: {t.title}")

# Get curriculum
curriculum = client.get_curriculum()
for stage in curriculum.stages:
    print(f"Stage {stage.stage}: {stage.title} ({len(stage.taskIds)} tasks)")

client.close()

API Reference

thetabench.make(site, task_id, mode, **kwargs)

Factory function for creating environments.

Param Type Default Description
site str "shopify-admin" Site identifier
task_id str "prod-001" Task to run
base_url str "http://localhost:3000" ThetaBench server URL
mode str "rest" "rest" or "browser"

ThetaBenchEnv (Gymnasium)

Method Returns Description
reset() (obs, info) Start new episode
step(action) (obs, reward, terminated, truncated, info) Execute action
evaluate() dict Mid-episode score check
finish(response?) dict End episode, get final score
close() None Cleanup

CurriculumRunner

Method Description
run(agent_fn) Generator yielding stage results
run_stage(stage, agent_fn) Run all tasks in one stage
run_task(task_id, agent_fn) Run a single task

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thetabench-0.1.1.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thetabench-0.1.1-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file thetabench-0.1.1.tar.gz.

File metadata

  • Download URL: thetabench-0.1.1.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for thetabench-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3f8ff4b95bcd6fa449027bd132b51de97a6b38ebedd1ee813b9a976fdca8446f
MD5 1582e8ff625894d5a3beffa1fbb1ffb4
BLAKE2b-256 492fd5414d5526a973c5ce4f4a251dd9e2e0325de30e7a1dbba136bd83e4f0fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for thetabench-0.1.1.tar.gz:

Publisher: release.yml on theta-rl-lab/thetabench

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thetabench-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: thetabench-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for thetabench-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dbe91a01912fbf8ad51082bcb9162d2a9598b619548c27184d57c46de185f537
MD5 c1bbc9500bc8e23af08de3163c8aac5d
BLAKE2b-256 d4800c4fe38d1d6f5c6456b7c1641b6d8792f84a53efda151f8dc670aafc5280

See more details on using hashes here.

Provenance

The following attestation bundles were made for thetabench-0.1.1-py3-none-any.whl:

Publisher: release.yml on theta-rl-lab/thetabench

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page