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, base_url=None, **kwargs)

Factory function for creating environments.

Param Type Default Description
site str "shopify-admin" Site identifier — one of shopify-admin, linear, jira, slack, zendesk, plain, inspector
task_id str "prod-001" Task to run
base_url str | None None ThetaBench server URL. If None, resolved from site via DEFAULT_SITE_PORTS (each site is a separate Next.js app on its own localhost port). Pass an explicit URL for Vercel deployments.
mode str "rest" "rest" or "browser"
**kwargs Forwarded to ThetaBenchEnv — supports seed, config_overrides, headless, viewport, render_mode
# Local dev — auto-resolved to http://localhost:3001
env = thetabench.make("linear", task_id="lin-thr-001")

# Production deploy — explicit URL
env = thetabench.make(
    "shopify-admin",
    task_id="prod-001",
    base_url="https://theta-shopify-admin.vercel.app",
)

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.2.tar.gz (31.8 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.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: thetabench-0.1.2.tar.gz
  • Upload date:
  • Size: 31.8 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.2.tar.gz
Algorithm Hash digest
SHA256 f9536c1f79aeb0f0e734b2a90100c00f386f348fae504ac66ae7c675b30f2426
MD5 93f7339b937bef0cc95ebe0c1b406a50
BLAKE2b-256 1901d98814e26ff0e113991bdbefc8770c8253dace4bcc4c746fa7b6274a773d

See more details on using hashes here.

Provenance

The following attestation bundles were made for thetabench-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: thetabench-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d9f2b3ecb5d1bf144af113647419514e46263dae1eb88f1a280b0a185f9462dd
MD5 feba921dd5d85d079178d1740350425d
BLAKE2b-256 468a5f9a70f16cc4c752d8317935354ea24a554c42e35e83bcf3ce93a2d8402f

See more details on using hashes here.

Provenance

The following attestation bundles were made for thetabench-0.1.2-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