Build
Model registry
Train models on your fleet, keep each one as a version with what it is, how it scored and what it is for, and score with the version an alias names.
Your organization keeps the models its people and agents train. Each model is a name with numbered versions. A version is one file, the model as its framework saved it, and a card that says what the model is, its scores on held-out data, what it is useful for, the settings it was trained with and what it was trained on. Each version also records the sweep row it came from. An alias such as prod names one version, so whatever scores with churn@prod picks up a promotion without changing.
Train
A sweep trains a model by running your Python over every row at once (scope="all") and returning a row that holds the model's file as bytes, plus its scores:
from drkm.broom import Workload, connect, sources
def train(rows, ctx):
import io
import joblib
from sklearn.ensemble import HistGradientBoostingClassifier
X = [[r["tenure"], r["spend"]] for r in rows]
y = [r["churned"] for r in rows]
model = HistGradientBoostingClassifier(**ctx.params).fit(X[:800], y[:800])
kept = io.BytesIO()
joblib.dump(model, kept)
return {"model": kept.getvalue(), "accuracy": model.score(X[800:], y[800:])}
broom = connect("https://isotope.example")
job = broom.read(sources.rows(customers)).run(
Workload(train, requirements=["scikit-learn", "joblib"], params={"max_depth": 4}, memory_gb=2),
scope="all",
).run()
The sandbox has no network, so every package comes from requirements. When the sweep is submitted, the isotope resolves them into the wheels each platform in your fleet installs: each Python, Linux or macOS, and CPU its sandboxes run, such as a Mac, an ARM Spark or an x86 server. The isotope that runs a step fetches its own platform's wheels from the package index, checks each against the digest it was resolved as, and installs them once for every later run. A stage runs only on isotopes whose platform the requirements resolved for. scikit-learn, LightGBM, XGBoost and pandas all work; a site holds at most 4 GiB of installed packages.
Register and promote
Keep the trained file as the model's next version, with its card:
curl -X POST https://isotope.example/registry/models/churn \
-H "Authorization: Bearer drkm_ak_..." -H "Content-Type: application/json" \
-d '{"job_id": "<the sweep>", "column": "model", "filename": "model.joblib",
"card": {"description": "Gradient-boosted trees on tenure and monthly spend",
"intended_use": "Ranking accounts for retention outreach; not for pricing",
"metrics": {"accuracy": 0.87}, "params": {"max_depth": 4},
"framework": "scikit-learn (joblib)", "dataset": "Accounts, Q3"}}'
| Request | What it does |
|---|---|
GET /registry/models | Every model: its newest version and which version each alias names |
GET /registry/models/{name} | Every version of a model, newest first, with its card |
POST /registry/models/{name} | Keep a bytes column of your finished sweep's result row as the next version |
PUT /registry/models/{name}/aliases/{alias} | Point an alias at a version: {"version": 3} |
GET /registry/versions/{reference} | The version churn, churn@3 or churn@prod names |
GET /registry/versions/{reference}/file | That version's file |
Anyone in the organization can read the registry. Registering and promoting need the member role, and you can register only your own sweep's result.
Score
A workload declares the versions it scores with, by alias. When the sweep is submitted, each reference is pinned to the version it names at that moment, and that version's file is sent with the job. Inside the workload, ctx.trained gives each file's path:
def score(rows, ctx):
import joblib
model = joblib.load(ctx.trained["churn"])
risk = model.predict_proba([[r["tenure"], r["spend"]] for r in rows])[:, 1]
return [{**r, "risk": float(p)} for r, p in zip(rows, risk)]
scored = broom.read(sources.result(accounts)).run(
Workload(score, requirements=["scikit-learn", "joblib"], trained={"churn": "churn@prod"}),
scope="batch",
).run()
A sweep carries at most 48 MiB of model files, and a model's file is at most 23 MiB, what one sweep partition's 32 MiB output carries once base64.
From an agent
Agents get these tools over MCP. In drkm chat, search for training or models, then use get_schema to load the tools you need; their schemas are not added to every turn:
| Tool | What it does |
|---|---|
broom_run | Run Python over rows, inline or from an earlier sweep's result, to train or score |
broom_status | A job's state and progress, and why its latest failed attempts failed |
broom_rows | A finished sweep's result rows; a file shows as its size and digest |
broom_cancel | Stop a job |
models_register | Keep a trained row's file as the next version, with its card |
models_list, models_versions | What the organization keeps, with cards and aliases |
models_promote | Point an alias, prod by default, at a version |
An agent doing research loops through them: train a few candidates with broom_run, compare their scores, register the best with a card that says what it is for, and promote it.