OpenClaw
OpenClaw is an open-source Python library designed for agent orchestration, serving as a plugin for the CMDOP platform. It provides tools and a framework for building and deploying intelligent agents that can interact with the CMDOP ecosystem. Currently at version 2026.3.20, it follows a YYYY.MM.DD versioning scheme, indicating active and continuous development.
Common errors
-
TypeError: object NoneType can't be used in 'await' expression
cause You are calling an asynchronous OpenClaw method (like `agent.run()`) without `await` or outside an `async` context.fixEnsure `agent.run()` is awaited inside an `async def` function, and that function is executed with `asyncio.run()`. -
cmdop_sdk.exceptions.APIError: Authentication Failed: Invalid API Key
cause The `api_key` provided in your `OpenClawConfig` is incorrect, expired, or missing, preventing authentication with the CMDOP platform.fixDouble-check the value of your `OPENCLAW_API_KEY` environment variable or the `api_key` parameter in `OpenClawConfig`. Obtain a valid API key from your CMDOP account settings. -
ModuleNotFoundError: No module named 'openclaw'
cause The `openclaw` package is not installed in your current Python environment or the environment is not activated.fixActivate your virtual environment (if using one) and run `pip install openclaw`. If you have multiple Python installations, ensure you're using the correct `pip` associated with your project's Python interpreter.
Warnings
- breaking OpenClaw has a strict, exact version dependency on `cmdop-sdk`. Mismatching versions (e.g., installing `cmdop-sdk` manually with a different version) will lead to runtime errors, unexpected behavior, or even `ImportError`.
- gotcha Key agent methods, particularly `agent.run()`, are asynchronous coroutines. Failing to `await` these methods or run them within an `asyncio` event loop will result in `TypeError: 'coroutine' object is not awaited` or the agent simply not starting.
- gotcha Incorrect or missing `api_key` or `agent_id` in `OpenClawConfig` will prevent the agent from authenticating and connecting to the CMDOP platform, leading to connection failures or API errors.
Install
-
pip install openclaw
Imports
- Agent
from openclaw.agent import Agent
- OpenClawConfig
from openclaw.config import OpenClawConfig
- tool
from openclaw.tools import register_tool
from openclaw.tools import tool
Quickstart
import asyncio
import os
from openclaw.agent import Agent
from openclaw.config import OpenClawConfig
from openclaw.tools import tool
# Define a tool for the agent to use
@tool
def greet(name: str) -> str:
"""Greets the given name."""
return f"Hello, {name}!"
async def main():
# Configure OpenClaw agent
# Obtain your API key from the CMDOP platform
config = OpenClawConfig(
api_key=os.environ.get("OPENCLAW_API_KEY", "sk-DUMMY_API_KEY"),
agent_id="my-first-openclaw-agent"
)
# Initialize the agent with the configuration
agent = Agent(config)
print(f"OpenClaw Agent '{config.agent_id}' running...")
# The agent.run() method is asynchronous and connects to the CMDOP platform
await agent.run()
print("Agent stopped.")
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
print("Agent interrupted and stopping.")
except Exception as e:
print(f"An error occurred: {e}")