Source Code:
src/gaia/agents/registry.pyComponent: AgentRegistry
Module:
gaia.agents.registry
Import: from gaia.agents.registry import AgentRegistry, AgentRegistration, KNOWN_TOOLSOverview
AgentRegistry is the central catalog of agents available to the Agent UI. It
is populated at server startup by AgentRegistry.discover(), which:
- Registers built-in agents declared in code (today:
chat,builder, optionally others). - Scans
~/.gaia/agents/for custom agents. Each subdirectory must contain anagent.pydefining a subclass ofAgent. The registry imports the module viaimportlib, finds theAgentsubclass withAGENT_IDandAGENT_NAMEclass attributes, and registers it.
AgentRegistration objects that the UI router
(src/gaia/ui/routers/agents.py) lists and that _chat_helpers.py uses to
instantiate agents per chat session.
The OpenAI-compatible API server (
src/gaia/api/) still uses a separate,
hard-coded AGENT_MODELS dict in src/gaia/api/agent_registry.py; it does
not go through AgentRegistry. See API Server for
how to wire new agents into the OpenAI surface.Core types
KNOWN_TOOLS
Map of tool-mixin keys to a lazily-imported (module, class) pair. Consumed
by builder/template.py
when scaffolding a new agent.py so users can opt into a mixin by name.
AgentRegistration
Dataclass the registry stores per agent:
Public API
AgentRegistry is typically instantiated once per process and shared via
src/gaia/ui/dependencies.py:
| Method | Purpose |
|---|---|
discover() | Scan built-ins and ~/.gaia/agents/. Idempotent; logs results. |
get(id) | Return the registration for id or None. |
list() | Enumerate registered agents as a list of AgentRegistration. |
register_from_dir(path) | Hot-load a single ~/.gaia/agents/<id>/ directory. Used by BuilderAgent so newly-scaffolded agents are immediately available. |
**kwargs) — the caller
filters to valid AgentConfig fields per agent (see chat_factory in the
source for the common pattern using dataclasses.fields(...)).
Custom-agent directory layout
gaia chat --ui → + → Build a Custom Agent), which writes a
ready-to-edit agent.py. See the Custom Agents guide
for the full minimal example, the tool-mixin table, and the YAML-manifest
migration recipe.
Related
- Agent UI Server — how the UI backend uses the registry to resolve chat sessions.
- API Server — the separate OpenAI-style
model registry used by
gaia api start. - Custom Agents guide — Python agent recipes and
the manifest →
agent.pymigration.