Overview
GAIA’s agent registry lets you extend the Agent UI with your own custom agents. Each agent lives in its own directory under~/.gaia/agents/ as a Python module. Once placed there, the agent appears automatically in the agent selector dropdown of the Gaia Agent UI.
Custom agents can have their own:
- Personality and instructions (system prompt)
- Tools (RAG, file search, shell, image generation, vision, plus your own
@toolfunctions) - Preferred models (override the server default)
- Conversation starters (suggestion chips in the UI)
- MCP servers (any Model Context Protocol server)
- Connectors (Google, GitHub, and more) — give your agent permission to read your real email, calendar, repos, etc.
This guide builds a local custom agent in
~/.gaia/agents/ for your own Agent UI.
When it’s ready to share — so anyone can install it from the Agent Hub —
jump to Publish and share your agent.Quick Start: Gaia Builder Agent
The fastest way to create an agent is to use the built-in Gaia Builder Agent.1
Open the Agent UI
Start the GAIA Agent UI:
gaia chat --ui2
Click the + button
In the chat input footer, click the + icon (to the left of the agent picker).
On the welcome screen, click Build a Custom Agent Template.
3
Follow the prompts
The Builder (an alpha feature) greets you, asks what to name the agent and what it should do, and asks whether you want MCP support — then scaffolds a starter agent with a personality and conversation starters tailored to your description.
4
Use your new agent
Your agent is immediately available in the agent selector dropdown — no restart needed.
~/.gaia/agents/<your-agent-name>/agent.py — a tailored persona and conversation starters (plus MCP wiring if you asked for it). It’s a starting point you extend, not a turnkey agent: it won’t fetch data or perform complex tasks on its own until you add tools. Open the file to refine the instructions and add capabilities (see Python Agent below).
Python Agent
For full control — custom tools, built-in tool mixins, MCP servers, or complex logic — write a Python module.Directory structure
Minimal Python agent
_register_tools() (it’s abstract on the base Agent); the other two
have sensible defaults you can override:
Adding built-in tools
GAIA ships with ready-to-use tool mixins. To enable most of them, inherit the mixin and call itsregister_*_tools() method from _register_tools(). The sd and vlm mixins are the exception — call init_sd() / init_vlm() (which set up the client and register the tools in one step):
Overriding the default model (optional)
If your agent needs a specific model, setmodel_id in __init__():
agent.yaml next to agent.py with a models: list — the registry reads that list as an ordered preference. The sidecar only honours the models: key; any other top-level key is ignored.
Using GAIA connectors
If your agent needs to act on your behalf — read your inbox, list your calendar events, query GitHub, post to Slack, etc. — wire it up to a GAIA connector rather than asking users to paste API tokens into your code. A connector lets users:- Authenticate once in Settings → Connections (OAuth flow for Google-style providers, paste-an-API-key for MCP servers).
- Grant scopes per agent so each agent only sees the data it actually needs. The Agent UI surfaces this when a user first picks your agent.
- Trust that secrets stay in the OS keyring, never in plaintext files or env vars baked into your code.
REQUIRED_CONNECTORS on the
class, and call get_credential_sync(connector_id, agent_id, required_scopes=[...])
from inside a tool to get a usable token. The
connectors-demo agent
is a working reference for both oauth_pkce (Google) and mcp_server
(GitHub) connectors.
Read the connectors guide
Walks through what connectors are, how the OAuth + MCP flows differ,
per-agent grants, and a step-by-step setup for Google and GitHub.
Export and import agents
Custom agents can be packaged into a single.zip bundle and shared between machines, teammates, or environments. GAIA supports export and import from both the Agent UI and the CLI. Exports include every ~/.gaia/agents/* directory with an agent.py — the installer-seeded bundled example included; imported copies land as user-owned agents the seeder never touches.
From the Agent UI
Open Settings → Custom Agents.- Export All — packages every custom agent under
~/.gaia/agents/into a single.zipfile and downloads it. Disabled when you have no custom agents. - Import — opens a file picker for a
.zipbundle and shows a confirmation dialog listing the agent IDs that will be installed. Imported agents register into the live registry; in most cases no restart is required.
From the CLI
What’s in the bundle
Each.zip contains a bundle.json manifest at the root and one directory per agent:
Security
Importing runs third-party code. A bundle’s
agent.py files execute inside your GAIA process. Both the CLI (gaia agent import without --yes) and the UI surface the agent IDs and require explicit confirmation before installing. Only import bundles from sources you trust.POST /api/agents/export and POST /api/agents/import) are localhost-only, CSRF-guarded with the X-Gaia-UI header, and disabled while a tunnel is active.
Examples
Example Agent — simple personality
Example Agent — simple personality
Research Agent — RAG + file search
Research Agent — RAG + file search
RAGToolsMixin and FileSearchToolsMixin read state off the host agent —
self.rag, self.indexed_files, self.max_chunks, self.current_session,
self.session_manager — that nothing sets by default, so the agent must wire
it up itself (see the RAG tools mixin contract
for what each attribute is for). Pass documents pointing at wherever your
documents actually live; the example never widens access beyond that.Code Review Agent — shell + file I/O
Code Review Agent — shell + file I/O
FileIOToolsMixin reads self.path_validator off the host agent, which
nothing sets by default, so the agent wires it up itself. Pass documents
pointing at wherever the code to review actually lives — an unset
PathValidator only allows the current directory, never widen it to a
filesystem root or the home directory.Why a custom RAG agent can’t see the Document Library
A custom agent’sdocuments list only ever contains what the caller passes
in — not the Agent UI’s Document Library. If you index a folder of PDFs
through the Library panel, then run a custom agent like ResearchAgent
above with no documents argument, query_documents will honestly report
"No documents are currently indexed" even though the Library shows them.
That’s expected, not a bug — here’s why.
The Agent UI passes each conversation only the documents explicitly attached
to it (internally, the rag_documents list), never the whole Library. This
is deliberate: earlier versions exposed every library document to every
agent, which meant one session’s documents could leak into an unrelated
session’s answers. If a session has no documents attached, rag_documents
comes through empty — not the library — so you have to index what you want
your custom agent to see.
There’s also no persistent, shared vector index an agent can just attach to.
The Document Library is file metadata plus files on disk; it caches
extracted text per file so re-indexing skips redundant parsing, but the
FAISS index itself is built in memory, per agent instance, from whatever
paths that instance was constructed with — nothing is written to or read
from disk as a vector index, and nothing carries over between agents.
The flow that works: call index_document or index_directory (both from
RAGToolsMixin) once your agent is constructed, then query. That’s the same
index-then-query sequence the built-in agents use — there’s no shortcut that
skips indexing.
Troubleshooting
My agent doesn't appear in the selector
My agent doesn't appear in the selector
- Ensure the directory is under
~/.gaia/agents/<id>/and containsagent.py. - The directory name does not need to match the
AGENT_IDclass attribute, but it helps. - Check the server logs for warnings like
Failed to load agent from .... - If you created the agent manually (not via the Builder), restart the GAIA server — discovery runs at boot. Agents created via the Builder Agent are loaded immediately without a restart.
Agent fails to load
Agent fails to load
Check the server logs for load errors. Ensure
AGENT_ID, AGENT_NAME, and AGENT_DESCRIPTION are set as class attributes, and that the required _register_tools() method is implemented (_get_system_prompt() and _create_console() are optional overrides).Imported agent doesn't appear or shows errors
Imported agent doesn't appear or shows errors
- The import response (UI status banner or CLI output) lists per-agent errors under
errors[]— check those first. - Confirm each agent directory in the bundle contains an
agent.pyat its root. Bundles missingagent.pyare rejected. - If
requires_restart: trueis reported, restart the GAIA server to pick up the new agent. - Bundles produced on a different GAIA version may reference imports that don’t exist locally — check the server logs for
ImportError.
MCP server not connecting
MCP server not connecting
- Ensure
npxor the MCP server command is installed and accessible in$PATH. - Check the server logs for
MCPconnection errors. - Test the MCP server standalone before adding it to your agent.
Agent uses wrong model
Agent uses wrong model
If your preferred model isn’t loaded on the Lemonade server, GAIA falls back to the server default. Run
gaia init to download additional models.Publish and share your agent
The agent you built lives in~/.gaia/agents/ — yours, on your machine. To let
anyone install it from the Agent Hub (and PyPI/npm), package it as a hub
agent and publish it through the curated PR route:
1
Package it
gaia agent init <id> -o hub/agents/ --layout hub scaffolds a publishable
package under hub/agents/<id>/python/ — a gaia-agent.yaml manifest, your
agent code, a README, and pyproject.toml. Move your agent.py logic in and
fill the manifest.2
Validate it
gaia agent test --lint checks the manifest and that the agent loads. Add tests
and a README — both are required for review.3
Open a PR
Commit the package under
hub/agents/<id>/python/ and open a PR to
amd/gaia. The PR route needs no token —
maintainers review, and the automated pipeline publishes it to the Hub + PyPI on
merge. (A direct-publish token route exists too, for maintainers.)Publishing guide → Hub + PyPI
The complete walkthrough: package layout, manifest, the no-token PR route vs
direct token publish, requirements, and verification.
Claude Code skills
In the GAIA repo, the
gaia-build-agent skill builds and the
agent-hub-release skill cuts a frozen-binary + npm sidecar release (like the
email agent). Invoke them with the Skill tool.Next Steps
Agent System SDK
Deep dive into the base Agent class, tool registry, and state machine
MCP Integration
Connect any MCP server to extend your agent with external tools
GAIA Connectors
Give your agent permission to read Gmail, GitHub, Slack, and more — without baking API keys into code
RAG SDK
Add document Q&A to your agent with the RAG SDK
Agent UI Guide
Learn about the GAIA Agent UI and how agents are surfaced there
Custom Installer
Ship your agent pre-loaded in a branded, signed GAIA installer