Modern AI agents are powerful, but they also have a habit of multiplying. A single forgotten callback, a background tool that never stops, or a Swarm handoff sequence that grows faster than expected — it only takes one small oversight for a fleet to expand beyond what you intended.
Most developers only notice the issue when logs or cloud bills reveal dozens (sometimes hundreds) of workers quietly running in the background.
MachineID.io prevents this with a predictable device identity layer: a simple register → validate handshake that enforces strict per-org device caps, without requiring any architectural changes.
To make adoption simple, we’re releasing clean, minimal, MIT-licensed templates for the most widely used agent frameworks:
- Python (universal starter)
- LangChain
- OpenAI Swarm
- CrewAI
- More coming soon!
Each template is dependency-free, production-tested, and ready to drop directly into real workflows.
Why Agent Identity Matters
AI frameworks make it extremely easy to spin up:
- background workers
- recursive sub-agents
- tool-driven chain expansions
- containerized or serverless tasks
- long-running callbacks
They do not, by default, enforce any limits on how many workers end up running.
That’s useful during experimentation, but risky in production, where a single uncontrolled pattern can silently spawn a large, expensive, and unintended fleet.
MachineID.io adds a lightweight identity check to every worker’s lifecycle:
- one org-level key
- a unique deviceId per agent
- a register step (idempotent)
- a validation step before performing work
- strict plan-based caps on active devices
If a worker exceeds the allowed limit — or appears unexpectedly — it exits before running.
Included Templates
All templates follow the same minimal, production-ready pattern:
- Assign a unique deviceId
- Register it with your org key
- Validate before running work
- Exit immediately if not allowed
This protects against silent or uncontrolled worker growth across all supported ecosystems.
Templates repository: https://github.com/machineid-io/templates
Python Starter Template
A lightweight drop-in for any Python agent or worker.
LangChain Template
Ensures chains, tools, and background tasks only execute when validated.
OpenAI Swarm Template
Prevents Swarm workers from multiplying faster than intended.
CrewAI Template
Stops recursive agent behavior from spawning unbounded sub-agents.
All templates are MIT licensed.
The Core Pattern
Below is the exact snippet pattern used in the repos today. Every call sends the org key in the x-org-key header (never in the body or URL), and uses a simple allowed check before running work:
import requests, os, sys
ORG_KEY = os.getenv("MACHINEID_ORG_KEY", "org_your_key_here")
DEVICE_ID = os.getenv("MACHINEID_DEVICE_ID", "local-test-agent")
# Register once (idempotent)
requests.post(
"https://machineid.io/api/v1/devices/register",
headers={
"x-org-key": ORG_KEY,
"Content-Type": "application/json",
},
json={
"deviceId": DEVICE_ID,
},
timeout=10,
)
# Validate before any real work
resp = requests.get(
"https://machineid.io/api/v1/devices/validate",
headers={"x-org-key": ORG_KEY},
params={"deviceId": DEVICE_ID},
timeout=10,
)
data = resp.json()
allowed = data.get("allowed", False)
if not allowed:
# Optionally inspect data.get("reason")
sys.exit(0)
# Your agent code starts here
If your plan’s device cap is exceeded — or if an unexpected worker appears — the process exits before calling any LLMs or consuming compute.
What These Templates Protect
This pattern provides guardrails across:
- LangChain pipelines that spawn autonomous tools
- Swarm handoff chains capable of exponential growth
- CrewAI configurations where sub-agents recursively spawn new agents
- Python scripts, cron jobs, containers, and serverless functions
If the system can run code, it can multiply. If it can multiply, it should validate.
Getting Started
- Generate a free org key (no login required) at https://machineid.io (Instant — no email or signup needed.)
- Visit the templates repository: https://github.com/machineid-io/templates
- Pick the framework you use
- Copy the register/validate snippet
- Run locally
- Deploy with confidence knowing your fleet is under control
Additional resources:
Docs: https://machineid.io/docs
Dashboard: https://machineid.io/dashboard
API: https://machineid.io/api
If you find the templates useful, consider starring the repository so others can discover the pattern: ⭐ https://github.com/machineid-io/templates
Top comments (0)