Skip to content

Writing a plugin

Plugins are normal Python packages that declare an entry point in the provingground.plugins group. The entry point resolves to a function that receives the provingground.plugins.Registry:

# pyproject.toml
[project.entry-points."provingground.plugins"]
my_plugin = "my_pkg.pg_plugin:register"
# my_pkg/pg_plugin.py
from importlib import resources


def register(registry):
    registry.add_env("warehouse", WarehouseEnv)  # factory(params) -> Environment
    registry.add_adapter("ros-agent", RosAgent)  # factory(ref, name=None, **opts)
    registry.add_metric("energy_meter", EnergyMeter)  # factory() -> Metric
    registry.add_judge("my-judge", MyJudge)  # factory() -> Judge
    registry.add_suite(
        "warehouse-basic", resources.files("my_pkg").joinpath("warehouse-basic.yaml").read_bytes()
    )

pg plugins list shows everything registered and where it came from. A plugin that fails to load is reported (exit code 1) without breaking other plugins; registering a name that already exists is an error.

Extension points

Extension Base class Contract
Environment provingground.core.Environment reset(seed) -> obs; step(action) -> (obs, reward, done, info); optional apply_perturbation(name), close(). Set name and version (recorded in the manifest). Put success (bool) and violations (list of {rule, severity}) in info. Observations should be JSON-serialisable (required for http-agent, llm-tool-agent and the docker backend).
Agent adapter provingground.adapters.AgentAdapter act(obs), optional reset(seed), fingerprint() (sha256 of the artefact), usage() (per-step tokens). Leave adapter = "plugin" unless you implement one of the schema's adapter kinds.
Metric provingground.core.Metric update(record) per step and per episode_end; result() returns keys that are valid in a Scorecard results[] entry. Plugin metrics are opt-in with pg run --metric NAME.
Judge provingground.core.Judge judge(transcript) -> {"success": bool, "violations": [...]}. For LLM judges subclass provingground.judges.LLMJudge and implement ask(); output is schema-checked and can only tighten.
Suite YAML bytes Must validate against the suite schema.
Backend provingground.core.Backend / provingground.backends.remote.RemoteBackend run(agent, suite, **options) returns a valid Scorecard.

The Scorecard schema has additionalProperties: false: a metric cannot add new top-level keys to a result. Propose schema additions through an ADR (schema changes bump schema_version).

Testing a plugin

Use provingground.plugins.load_registry(entry_points=False), register your objects, and run provingground.runner.Runner(suite, agent, registry=reg).run(); validate the result with provingground.scorecard.validate.