Using plain Python only? You probably want the built-incustomadapter fromcharm init --template python. See Custom Python Adapter. This guide is for registering a new adapter name via entry points.
How discovery works
Charm loads adapters from Pythonentry_points in the charm.adapters group. The name you register becomes a valid runtime.adapter.type in charm.yaml.
Official adapters (langchain, crewai, openclaw, custom, …) use the same mechanism in the charmos package. Third-party packages add more names without forking core.
1. Get the Boilerplate
[!TIP]
Fastest Path: You do not need to write this from scratch. Use the official charm-adapter-template repository on GitHub. Click Use this template, rename the folder, and jump straight to implementing your invoke method.
If you are doing it manually, start by scaffolding a plain project:
charm.yaml, src/main.py, and .charmignore. You will add a separate installable package (or a pyproject.toml in the same repo) for the adapter plugin.
2. Implement BaseAdapter
Your class must inherit from charm.adapters.base.BaseAdapter and implement invoke.
AdapterClass(agent_instance=..., config=...) after importing the user’s entry point from charm.yaml.
Return a dict with "status": "success" and "output" for standard Store rendering, or include structured keys like _charm_render_type (see Output Renderers).
3. Register via entry points
In your plugin package’spyproject.toml:
charm validate should accept runtime.adapter.type: ag2 after your package is installed.
4. Configure charm.yaml
5. Cloud execution requires a custom image
The cloud runner will automaticallyuv pip install your adapter if it is listed in the user’s requirements.txt. However, if your adapter depends on massive libraries (like PyTorch or large LLM frameworks), uv pip install might timeout during Cloud Run startup.
For heavy adapters, you should provide a custom image:
- Build a Docker image based on charm-base or an official runner image
RUN uv pip install charm-adapter-ag2(orpip install) inside the Dockerfile- Set
runtime.custom_imageto the pushed image URI
6. Submit to the Charm Store
To make your adapter discoverable by the global Charm community:- Fork the charm-community-plugin repository.
- Edit
adapters/registry.jsonto add your package name (charm-adapter-ag2). - Submit a Pull Request.
Local testing
Related
- Extensibility Overview
- Custom Runtimes
- Custom Python Adapter — built-in path, no entry points
- Write a Custom Adapter — contributing official adapters to the SDK repo
