Repository navigation
Add grid_device.py update command to switch a worker's model in place - #33
Conversation
Previously the only way to change a device's approved model was remove + add,
which reissued its worker token and required carrying a fresh bundle to the
device. Add a coordinator endpoint (POST /api/admin/workers/{id}/model) and a
matching `grid_device.py update <name> --model <tag>` command that change only
the model, keeping the worker's identity, token and trust/credit history intact.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 404faefc6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| response = client.post(f"{base}/api/admin/workers/{worker_id}/model", | ||
| headers={"Authorization": f"Bearer {admin_key}"}, json={"model": args.model}) |
There was a problem hiding this comment.
Quiesce the old worker before retagging it
When this runs while the device is still polling with its old CAG_MODEL—the documented sequence edits and restarts it only after this command returns—the coordinator immediately offers it jobs for the new model. worker.client.infer() rejects those jobs because its configured model is still old, and repeated failures can exhaust the three attempts and fail queued jobs. Keep the worker stopped until its local config matches the new model and this update has completed.
Useful? React with 👍 / 👎.
What does this PR change?
Adds a way to change a device's operator-approved model without reissuing its worker token.
Previously the only way to switch a device's model was
remove+add, which creates a brandnew worker identity/token and means a fresh bundle has to be carried to the device again
(USB/scp/Taildrop — never chat, per
AGENTS.md). That's heavy-handed for what is often just "thisdevice can handle a bigger/smaller model now."
POST /api/admin/workers/{id}/model(admin-only). Validates the newmodel against
CAG_ALLOWED_MODELS, 404s on an unknown worker, 409s on a revoked one, otherwiseupdates the worker's
modelcolumn in place. Token, trust_level and credit history areuntouched.
grid_device.py update <name> --model <tag>. Looks up the device'sworker_idfrom the local registry, calls the new endpoint, and updates the localregistry.jsonentry to match.docs/ADD_DEVICE.md: documents the new command and clarifies that the device's ownCAG_MODELinworker.envstill has to be edited by hand and the worker restarted — thisendpoint only changes the coordinator-side allowlist entry, there is no secret to redistribute.
CHANGELOG.mdentry under[Unreleased].No change to the trusted/community split, and workers still never execute remote commands.
Checklist
pytest -qpasses locally (238 passed, 3 skipped — pre-existing Windows-only skips)ruff check --select E9,F63,F7,F82 .reports no new errorstests/test_worker_admin.py,tests/test_grid_device.py)CHANGELOG.mdupdated for user-visible changesHow was it tested?
All green locally; new tests cover the happy path (model switch changes which queued jobs the
worker can claim), identity/trust/credits staying untouched, rejecting an unapproved model, and
404/409/403 on an unknown/revoked/non-admin request.
🤖 Generated with Claude Code