gaia-build-agent
Build a new GAIA agent with the SDK end-to-end: scaffold the package, write the Agent subclass, register @tool functions, compose reusable tool mixins, set the model + system prompt, and test it locally — then hand off to publishing. Use when creating a NEW agent (a Python class inheriting from the base Agent) for the GAIA repo or a user-authored package, not for tuning an existing agent's prompt (prompt-engineer), adding one tool to an existing class (python-developer), or shipping/releasing an already-built agent (use the agent-hub-release skill + docs/guides/hub-publishing.mdx). Pairs with the agent-hub-release skill: this one BUILDS, that one PUBLISHES.
- License 许可
- MIT
- 最近更新
- 2026-10-26
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- gaia-build-agent
- description
- Build a new GAIA agent with the SDK end-to-end: scaffold the package, write the Agent subclass, register @tool functions, compose reusable tool mixins, set the model + system prompt, and test it locally — then hand off to publishing. Use when creating a NEW agent (a Python class inheriting from the base Agent) for the GAIA repo or a user-authored package, not for tuning an existing agent's prompt (prompt-engineer), adding one tool to an existing class (python-developer), or shipping/releasing an already-built agent (use the agent-hub-release skill + docs/guides/hub-publishing.mdx). Pairs with the agent-hub-release skill: this one BUILDS, that one PUBLISHES.
03 SKILL.md 正文
Building a GAIA Agent
How to take an idea to a working, testable GAIA agent — a Python class that runs
locally on AI PCs. This skill covers build; publishing is its sibling
agent-hub-release skill and the author guide
docs/guides/hub-publishing.mdx. The
full prose walkthrough is docs/guides/custom-agent.mdx.
Read
CLAUDE.mdfirst — the "No Silent Fallbacks", code-reuse, testing, and eval rules all apply to a new agent.
The mental model
A GAIA agent is one Python class that inherits from the base Agent
(src/gaia/agents/base/agent.py) and exposes capabilities as @tool-decorated
methods. The base class owns the agent loop, tool registry, state, error recovery,
and (via mixins) MCP / OpenAI-API exposure — you write the prompt + the tools, not
the plumbing. There are no YAML agent manifests for in-core agents (removed in
v0.17.5); a publishable hub package adds a gaia-agent.yaml manifest on top (see
the publish skill).
Steps
-
Scaffold.
gaia agent init my-agentgenerates a starter package at./my-agent/. For a publishable hub package in this repo, add--layout hubso it lands athub/agents/<id>/python/:gaia agent init my-agent -o hub/agents/ --layout hubThen mirror an existing package (e.g.
analyst,browser) for structure. -
Write the
Agentsubclass. Inherit fromAgent(or a closer base like the chat/docqa agents). Leavemodel_idunset — that inherits the base default,Gemma-4-E4B-it-GGUF(DEFAULT_MODEL_NAME), which is right for nearly every agent. Every agent sharing one model is what keeps a single model resident, so switching agents never triggers an eviction + cold reload. Only setmodel_idwhen the agent genuinely needs a different model (e.g. the summarizer'sQwen3-4B-Instruct-2507-GGUF), and say why. Keep the constructor thin. -
Register tools with
@tool. Each@toolmethod is a capability the LLM can call; its docstring is the schema the model sees, so write it for the model (one line of intent + each arg). Return structured data or an actionable error — never swallow exceptions into a placeholder (No Silent Fallbacks). -
Reuse, don't reinvent — compose mixins. Before writing file/web/RAG/shell/SQL logic, check
KNOWN_TOOLSinsrc/gaia/agents/registry.py:rag,file_io,file_search,shell,browser,scratchpad,code_index,vlm,sd, … Compose them by name instead of duplicating. New shared logic → add a mixin and register it inKNOWN_TOOLS. -
System prompt. Implement
_get_system_prompt()— state the agent's job, when to use which tool, and the output contract. This is an LLM-affecting surface, so it's covered by the eval rule below. -
Make it discoverable. An in-core agent is added to
src/gaia/agents/registry.py(and agaia <cmd>subparser insrc/gaia/cli.pyif it's a CLI command). A hub package is auto-discovered from itsgaia-agent.yamlmanifest — noregistry.pyedit; just make sure the manifest'spython.entry_module/entry_classpoint at your class. -
Test it — actually run it. Unit tests with a mocked LLM for tool logic (
tests/), then run the real CLI a user would (gaia <cmd> ...orpython my_agent.py) — never only the Python module. Follow thegaia-testingskill for real-world evidence. -
Eval if it touches LLM behavior. If you wrote/changed a system prompt, tool docstrings, the tool schema, the model, or error classification, you MUST run
gaia eval agentagainst the relevant category and compare to the committed baseline before calling it done (CLAUDE.md eval rule). Unit tests don't catch LLM regressions.
Then publish
Once it runs and is documented (README/SPEC/SKILL per the doc-sync rule), ship it:
- Standard wheel → Hub + PyPI (PR route, no token): the
hub-publishing.mdxguide. - Frozen-binary + npm sidecar (like the email agent): the
agent-hub-releaseskill. - Taking an agent that already exists to a publishable, Agent-UI-usable state
(the parity kit, the generalize-before-documenting rule, the day-one gate): the
porting-agent-to-hubskill.
Reference
docs/guides/custom-agent.mdx— the full build walkthrough.src/gaia/agents/base/—Agent,MCPAgent,ApiAgent,@tool, console, errors.src/gaia/agents/registry.py— agent registry +KNOWN_TOOLS.- The
gaia-agent-builderagent (.claude/agents/) — a specialist for this work.
Output style
Follow CLAUDE.md → "How You Communicate".
04 同仓库更多 Skills
web-search
Search the web via the Brave Search API. Use when the user asks about current events or external facts.
triage-support-ticket
Triage an inbound support ticket end to end. Use when the user pastes a support ticket or asks to triage one.
tool-mismatch
Declares a tool its tools.py never registers. Used to prove validation fails loudly with no partial load.
report-archive
Archive a generated report to the user's reports folder and register it with the team's report index. Use when the user asks to file, archive, or publish a finished report.
local-capability
Writes files on the local workspace. Used to prove Phase 1 refuses local-capability permissions.
incident-review
Run an incident postmortem. Stands in for a Claude Code skill library imported read-only from .claude/skills/.