Reference
Everything the three Python packages export. For the narrative version, see Core concepts and the per-framework pages.Environment variables
Platform credentials
Read bySwarmDConfig.from_env() and by both wrappers’ create_runtime().
SWARMD_WEBHOOK_SECRET is read by swarmd-google-adk’s create_runtime() but
not by swarmd-langchain’s — see the
gap noted on the LangChain page.SWARMD_TIMEOUT and SWARMD_MAX_RETRIES are read by SwarmDConfig.from_env()
only — so they apply to SwarmDClient.from_env() and McpClient.from_env().
Neither wrapper’s create_runtime() passes them on: SwarmDRuntime.configure()
takes no timeout or retry arguments, so a wrapper-built runtime always gets the
30 / 3 defaults.Custom prefix
Running several agents in one process? Everyfrom_env takes a prefix:
LLM and server
Pointing at another environment
SWARMD_BASE_URL and SWARMD_TOKEN_URL move together — a base URL and a token
URL from different environments mint tokens the gateway rejects on audience.
Ask your platform team for the pair that matches the estate you’ve been given
credentials for.
swarmd-sdk
SwarmDClient
agent_id must be your own id when calling with an agent token. The
registry compares it against the JWT subject and returns 403 on a mismatch —
the endpoint is shared with tenant admins, who may query any agent.401 clears the cached token and retries once; 5xx
and network errors retry with exponential backoff up to max_retries; other
4xx fail immediately.
SwarmDConfig
SwarmDConfig.from_env(env_prefix="SWARMD") builds one from the environment
and raises ValueError naming any missing required variable. Trailing slashes
are stripped from both URLs. Importing the module calls load_dotenv(), so a
.env in the working directory is picked up automatically.
SwarmDRuntime
Holds credentials and the clients built from them; supports reconfiguration in
place.
The two token managers are proxies: they resolve to the current client’s
manager on every call, so a helper that captured one at startup keeps working
after a reconfigure.
create_admin_app
/admin.
Refresh-triggering event types (
X-Swarmd-Event-Type):
SUBSCRIPTION_CHANGED, AGENT_LIFECYCLE, TENANT_LIFECYCLE,
MCP_GRANTS_CHANGED.
AgentDirectory
on_change(added, removed) receives sets of UUIDs. A raising callback is
logged and does not abort the refresh.
McpClient
Same constructors and retry semantics as SwarmDClient, but mints
mcp:call-scoped tokens bound to {base_url}/relay.
McpServerInfo fields: mcp_server_id: UUID, name: str,
description: Optional[str], transport: Optional[str],
protocol_version: Optional[str].
mcp_tool_namespace(server) -> str returns mcp_{sanitised_name}_{uuid8};
characters outside ^[a-zA-Z0-9_-]+$ become _. No trailing separator — the
caller adds its framework’s own.
Correlation
verify_webhook
WebhookVerificationError on a missing header, malformed timestamp,
timestamp outside the symmetric ±max_age_seconds window, or signature
mismatch. Signature is
HMAC-SHA256(secret, f"{timestamp}.".encode() + body), compared with
hmac.compare_digest.
Models
AgentResponse — agent_id: UUID, name: str, description: str,
agent_card_url: str (relay-proxied), visibility: Optional[Visibility]
(PUBLIC · PRIVATE · INTERNAL). Accepts the wire’s camelCase aliases.
OAuth2Token — access_token, token_type, expires_in, scope,
issued_at, and is_expired(buffer_seconds=60).
Exceptions
swarmd-google-adk
PollingRemoteA2aAgent
RemoteA2aAgent. Polls tasks/get while the task state is
working, submitted, input_required or auth_required; stops at
completed, failed, canceled, rejected or unknown. With no factory,
builds an authenticated one from the active runtime.
tool_choice values
"auto" / None · "required" · "none" · a specific tool name. Forwarded
to litellm.acompletion on every turn.
swarmd-langchain
PollingA2aTool
BaseTool. Same terminal/non-terminal state sets as the ADK
wrapper.
LangChainA2aExecutor
LangChainA2aExecutor(agent) adapts a compiled graph to the A2A protocol.
set_agent(new_graph) swaps the graph in place — how serve()’s refresh
works.
Attributes serve() reads off the graph
create_llm_agent() sets these; set them yourself if you compile your own
graph and want auto-refresh to work.
Dependency ranges
The wrappers pin their framework dependencies deliberately. Widening a bound is how these packages break.swarmd-sdk itself needs httpx>=0.27, pydantic>=2.0,
python-dotenv>=1.0, starlette>=0.37 (for CorrelationIdMiddleware, which
import swarmd_sdk loads eagerly), and fastapi>=0.110 (imported lazily,
only by create_admin_app).
swarmd-google-adk additionally needs openai>=1.0 — helpers.py imports
AsyncOpenAI at module scope to build the LLM-gateway client.
All three packages require Python 3.9+.
Not yet available
swarmd-crewai exists on the roadmap but ships as a placeholder — it exports a
version string and nothing else. For CrewAI today, use
the core SDK directly.