Skip to main content

Reference

Everything the three Python packages export. For the narrative version, see Core concepts and the per-framework pages.

Environment variables

Platform credentials

Read by SwarmDConfig.from_env() and by both wrappers’ create_runtime().
BASE_URL and TOKEN_URL are optional for swarmd-sdk and effectively required for the wrappers. SwarmDClient.from_env() falls back to the production defaults; create_runtime() only configures the runtime when all four of AGENT_ID, CLIENT_SECRET, BASE_URL and TOKEN_URL are present, and otherwise leaves it in standalone mode with no discovery.
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? Every from_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.
Request behaviour: 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

Returns a FastAPI app to mount at /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

Raises 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.
Pass the raw request body bytes. Re-serialising a parsed dict changes key order and whitespace, and the signature will never match.

Models

AgentResponseagent_id: UUID, name: str, description: str, agent_card_url: str (relay-proxied), visibility: Optional[Visibility] (PUBLIC · PRIVATE · INTERNAL). Accepts the wire’s camelCase aliases. OAuth2Tokenaccess_token, token_type, expires_in, scope, issued_at, and is_expired(buffer_seconds=60).

Exceptions


swarmd-google-adk

PollingRemoteA2aAgent

Drop-in for ADK’s 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

A LangChain 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.0helpers.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.