Update derived agent-usage shares (latest month: 2026-06)
Browse files- build_local.py +43 -10
- card/README.md +84 -0
build_local.py
CHANGED
|
@@ -29,7 +29,20 @@ from huggingface_hub import snapshot_download
|
|
| 29 |
from huggingface_hub.constants import ENDPOINT
|
| 30 |
from huggingface_hub.utils import get_session
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
SRC = os.environ.get("AGENT_USAGE_SRC")
|
| 35 |
if not SRC:
|
|
@@ -131,28 +144,48 @@ PUSH_REPO = os.environ.get("AGENT_USAGE_PUSH_REPO")
|
|
| 131 |
if PUSH_REPO:
|
| 132 |
from huggingface_hub import CommitOperationAdd, HfApi
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
ops = []
|
| 135 |
for parquet in sorted(DATA.rglob("*.parquet")):
|
| 136 |
ops.append(CommitOperationAdd(str(parquet.relative_to(OUT)), str(parquet)))
|
| 137 |
for png in ("leaderboard.png", "trend.png"):
|
| 138 |
ops.append(CommitOperationAdd(f"assets/{png}", str(OUT / png)))
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
# Card template → README.md with the freshness stamp filled in.
|
| 143 |
card = (
|
| 144 |
-
|
| 145 |
-
.read_text()
|
| 146 |
.replace("{{LATEST_MONTH}}", latest)
|
| 147 |
.replace("{{GENERATED}}", str(date.today()))
|
| 148 |
)
|
| 149 |
ops.append(CommitOperationAdd("README.md", card.encode()))
|
| 150 |
|
| 151 |
-
api = HfApi()
|
| 152 |
-
# Created private: review the rendered card/viewer, then flip to public in
|
| 153 |
-
# settings (or api.update_repo_settings). exist_ok means later scheduled
|
| 154 |
-
# runs never touch visibility.
|
| 155 |
-
api.create_repo(PUSH_REPO, repo_type="dataset", private=True, exist_ok=True)
|
| 156 |
commit = api.create_commit(
|
| 157 |
repo_id=PUSH_REPO,
|
| 158 |
repo_type="dataset",
|
|
|
|
| 29 |
from huggingface_hub.constants import ENDPOINT
|
| 30 |
from huggingface_hub.utils import get_session
|
| 31 |
|
| 32 |
+
try:
|
| 33 |
+
import agent_usage as au
|
| 34 |
+
except ModuleNotFoundError:
|
| 35 |
+
# Scheduled Jobs run this script by URL, without the sibling module on disk:
|
| 36 |
+
# fetch agent_usage.py from the same dataset repo the job pushes to.
|
| 37 |
+
import sys
|
| 38 |
+
|
| 39 |
+
from huggingface_hub import hf_hub_download
|
| 40 |
+
|
| 41 |
+
_mod = hf_hub_download(
|
| 42 |
+
os.environ["AGENT_USAGE_PUSH_REPO"], "agent_usage.py", repo_type="dataset"
|
| 43 |
+
)
|
| 44 |
+
sys.path.insert(0, str(Path(_mod).parent))
|
| 45 |
+
import agent_usage as au
|
| 46 |
|
| 47 |
SRC = os.environ.get("AGENT_USAGE_SRC")
|
| 48 |
if not SRC:
|
|
|
|
| 144 |
if PUSH_REPO:
|
| 145 |
from huggingface_hub import CommitOperationAdd, HfApi
|
| 146 |
|
| 147 |
+
api = HfApi()
|
| 148 |
+
# Created private: review the rendered card/viewer, then flip to public in
|
| 149 |
+
# settings. exist_ok means later scheduled runs never touch visibility.
|
| 150 |
+
api.create_repo(PUSH_REPO, repo_type="dataset", private=True, exist_ok=True)
|
| 151 |
+
|
| 152 |
+
# Idempotent: the job can run more often than the source updates (a new
|
| 153 |
+
# source snapshot means a new monthly parquet). Nothing new -> no commit.
|
| 154 |
+
if api.file_exists(
|
| 155 |
+
PUSH_REPO, f"data/monthly/{latest}.parquet", repo_type="dataset"
|
| 156 |
+
) and not os.environ.get("AGENT_USAGE_FORCE"):
|
| 157 |
+
print(
|
| 158 |
+
f"\n✓ {PUSH_REPO} already has {latest} — nothing new, skipping push "
|
| 159 |
+
"(AGENT_USAGE_FORCE=1 overrides)"
|
| 160 |
+
)
|
| 161 |
+
raise SystemExit(0)
|
| 162 |
+
|
| 163 |
ops = []
|
| 164 |
for parquet in sorted(DATA.rglob("*.parquet")):
|
| 165 |
ops.append(CommitOperationAdd(str(parquet.relative_to(OUT)), str(parquet)))
|
| 166 |
for png in ("leaderboard.png", "trend.png"):
|
| 167 |
ops.append(CommitOperationAdd(f"assets/{png}", str(OUT / png)))
|
| 168 |
+
# The build must stay auditable and self-contained from the dataset repo
|
| 169 |
+
# itself: on a scheduled Job only this script exists locally, so the module
|
| 170 |
+
# comes from wherever it was imported and the card template from the repo.
|
| 171 |
+
ops.append(CommitOperationAdd("build_local.py", str(Path(__file__).resolve())))
|
| 172 |
+
ops.append(CommitOperationAdd("agent_usage.py", au.__file__))
|
| 173 |
+
|
| 174 |
+
card_tpl = HERE / "card" / "README.md"
|
| 175 |
+
if not card_tpl.exists():
|
| 176 |
+
from huggingface_hub import hf_hub_download
|
| 177 |
+
|
| 178 |
+
card_tpl = Path(hf_hub_download(PUSH_REPO, "card/README.md", repo_type="dataset"))
|
| 179 |
+
ops.append(CommitOperationAdd("card/README.md", str(card_tpl)))
|
| 180 |
|
| 181 |
# Card template → README.md with the freshness stamp filled in.
|
| 182 |
card = (
|
| 183 |
+
card_tpl.read_text()
|
|
|
|
| 184 |
.replace("{{LATEST_MONTH}}", latest)
|
| 185 |
.replace("{{GENERATED}}", str(date.today()))
|
| 186 |
)
|
| 187 |
ops.append(CommitOperationAdd("README.md", card.encode()))
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
commit = api.create_commit(
|
| 190 |
repo_id=PUSH_REPO,
|
| 191 |
repo_type="dataset",
|
card/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: Agent Usage on the Hugging Face Hub
|
| 3 |
+
tags:
|
| 4 |
+
- analytics
|
| 5 |
+
- agents
|
| 6 |
+
configs:
|
| 7 |
+
- config_name: monthly
|
| 8 |
+
default: true
|
| 9 |
+
data_files: data/monthly/*.parquet
|
| 10 |
+
- config_name: daily
|
| 11 |
+
data_files: data/daily/*.parquet
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Agent Usage on the Hugging Face Hub
|
| 15 |
+
|
| 16 |
+
**Coding agents are real users of the Hugging Face Hub.** Claude Code, Codex, Cursor, and a growing list of harnesses are searching for models, building and pushing datasets, training models on [Jobs](https://huggingface.co/docs/hub/jobs), spinning up Spaces — tens of millions of requests so far ([hf CLI for agents](https://huggingface.co/blog/hf-cli-for-agents)). Now there's public data on which ones.
|
| 17 |
+
|
| 18 |
+
Requests made through the `huggingface_hub` library (including the `hf` CLI) carry an [`agent/<name>` User-Agent token](https://huggingface.co/docs/hub/agents-overview) identifying the harness. This dataset publishes **each harness's share of that agent-attributed traffic**, month by month and day by day, updated by a scheduled [HF Job](https://huggingface.co/docs/hub/jobs).
|
| 19 |
+
|
| 20 |
+

|
| 21 |
+
|
| 22 |
+
_Named harnesses ranked by share of requests, data through **{{LATEST_MONTH}}** · updated {{GENERATED}}. The **Dataset Viewer** at the top of this page lets you browse, sort, and filter both tables — no code needed._
|
| 23 |
+
|
| 24 |
+
## What you can see
|
| 25 |
+
|
| 26 |
+
- **Who's calling the Hub** — the monthly leaderboard of named harnesses, and how it shifts as new tools launch and register.
|
| 27 |
+
- **Usage styles** — compare request share with user share. An agent with 30% of requests but 8% of users is a small crowd running heavy automated pipelines; the reverse means many users, each doing a little.
|
| 28 |
+
- **Day-by-day detail** — the `daily` config picks up what monthly numbers smooth over: launch spikes, growth curves, weekday-vs-weekend patterns.
|
| 29 |
+
|
| 30 |
+
## Get your harness on the board
|
| 31 |
+
|
| 32 |
+
If you build a harness, register it to make sure your agent isn't missed — unregistered tools are counted only as `unknown`.
|
| 33 |
+
|
| 34 |
+
Attribution is automatic: `huggingface_hub` detects registered harnesses from environment variables and reports them in the User-Agent. To register, follow [Register your agent harness](https://huggingface.co/docs/hub/agents-overview#register-your-agent-harness) — a Pull Request adding your tool to [`agent-harnesses.ts`](https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/src/agent-harnesses.ts). No release is needed on either side: installed clients refresh the registry within a day, and your harness appears from the next monthly snapshot.
|
| 35 |
+
|
| 36 |
+
Only traffic through the Python `huggingface_hub` library (including the `hf` CLI) is attributed; direct HTTP calls to the Hub API are not counted. To confirm detection works, run inside your harness:
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
python -c "from huggingface_hub.utils import build_hf_headers; print(build_hf_headers()['user-agent'])"
|
| 40 |
+
# should contain agent/<your-id>
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
## Columns
|
| 44 |
+
|
| 45 |
+
| column | description |
|
| 46 |
+
| --------------- | ------------------------------------------------------------------------------------------------------------ |
|
| 47 |
+
| `month` / `day` | period the share is computed over |
|
| 48 |
+
| `agent` | harness name from the `agent/<name>` token; `unknown` = token present but no registered name |
|
| 49 |
+
| `pct_requests` | harness's share of agent-attributed `huggingface_hub` requests in the period (0–100; sums to 100 per period) |
|
| 50 |
+
| `pct_users` | same, for distinct authenticated users — someone using two harnesses counts once for each |
|
| 51 |
+
|
| 52 |
+
## Loading programmatically
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from datasets import load_dataset
|
| 56 |
+
|
| 57 |
+
monthly = load_dataset("huggingface/agent-usage", "monthly", split="train")
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
```sql
|
| 61 |
+
-- DuckDB: full monthly history in one query
|
| 62 |
+
SELECT month, agent, pct_requests
|
| 63 |
+
FROM 'hf://datasets/huggingface/agent-usage/data/monthly/*.parquet'
|
| 64 |
+
WHERE agent != 'unknown'
|
| 65 |
+
ORDER BY month, pct_requests DESC;
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
import polars as pl
|
| 70 |
+
|
| 71 |
+
daily = pl.scan_parquet("hf://datasets/huggingface/agent-usage/data/daily/*.parquet")
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
New months append as new parquet files, so these queries always return the full history unchanged.
|
| 75 |
+
|
| 76 |
+
## Reading the data
|
| 77 |
+
|
| 78 |
+
- **This measures Hub usage, not overall agent popularity.** A widely used tool that rarely touches the Hugging Face Hub will rank low here.
|
| 79 |
+
- **Shares are zero-sum.** A falling share doesn't mean falling usage — total agent traffic is growing, so a harness can double its requests while its share shrinks.
|
| 80 |
+
- **Start month-over-month comparisons from May 2026.** The `agent/` token rolled out April 3 and harnesses added detection at different times, so April reflects the rollout, not relative usage.
|
| 81 |
+
- **Smooth daily shares** with a 7-day rolling mean — weekends and small denominators make single days noisy.
|
| 82 |
+
- **Attribution is self-declared** (a User-Agent token set by the client library) and covers Python-library traffic only.
|
| 83 |
+
|
| 84 |
+
_Built by [`build_local.py`](./build_local.py) (bundled in this repo) on a scheduled HF Job — only relative shares are published._
|