Agent archetypes
An archetype is a named agent setup: settings to create the agent with, and a NixOS module its container runs. The swarm UI's create form lists the archetypes the swarm knows. Picking one fills the form's permissions, resource caps, inference and AGENTS.md fields from it, and you can still change each field before you create the agent.
An agent created from an archetype has no agent-configs/<name> repo of its
own. The swarm's internal/meta flake builds it from the archetype's module,
so every agent of that archetype runs the same configuration. To change what it runs, change the
archetype. Picking "none" creates a custom agent, with its own config repo. The
swarm can also turn an archetype agent into a custom one later
(below).
The built-in archetypes
The hyperhive flake ships these:
| archetype | what it sets |
|---|---|
reviewer |
permissions messaging, inbox, execution: the default set without meta. With execution it can run hive-forge, git and other commands. |
android-dev |
installs android-tools (adb, fastboot), Gradle, a JDK, the Android SDK (build-tools 36.1.0, platform 35) and nix-ld, and sets ANDROID_HOME, ANDROID_SDK_ROOT and JAVA_HOME, so the aapt2 Gradle downloads runs; default permissions. |
reverse-engineer |
sets services.hyperhive.agent.rea.enable: installs REA, Ghidra 12.1 and procps, and allows all REA MCP tools; default permissions and the agent's normal memory cap. |
ruth |
the manager agent. Inference model sonnet; permissions: the default set plus manage_root_agent, logs and metrics. Its module is empty. The swarm UI's setup assistant creates ruth from it. |
triage |
labels and assigns every new issue and pull request, then routes it. Inference model haiku; default permissions. It has no forge subscription: its flows send it a todo for each new or reopened issue and each new pull request. |
Run one triage agent per swarm. Its flows send to members, so every triage
agent gets every new item, and two of them would both label and assign it.
- Flows already in place. If the operator's flow document already sends new
issues to an agent, as a custom flow on the notification router board does,
creating a
triageagent gives each new issue two todos. Switch one off on the board: the custom flow, or the archetype's flow (below). - Forge rights. A new agent's forge account is a read collaborator on its own
config repo and has read on
internal/docs, and nothing else. Labelling and assigning an issue or a pull request in a project repo takes write access to that repo, so the triage agent can't do either until the operator adds it as a write collaborator on each repo it should triage, in the forge's repo settings or withhive-forge repo-add-collaborator <agent>. Without that grant its label and assign calls fail.
An existing ruth, created before this archetype, keeps her own config repo and
model. Set sonnet in the swarm UI's inference settings for her if wanted.
Each built-in archetype also sets services.hyperhive.agent.icon, so its agents
show an icon in the swarm UI until their config sets another.
Where an archetype comes from
A flake declares archetypes in its hyperhiveArchetypes output:
hyperhiveArchetypes.reviewer = {
module = { };
meta = {
description = "Reviews what it is sent.";
permissions = [ "messaging" "inbox" "execution" ];
limits = { memory_max = "4G"; };
inference = { effort = "high"; };
prompt = "You review pull requests and never push.";
};
};
A long prompt can live in a file next to the flake. builtins.readFile gives a
plain string at evaluation, so meta stays plain data:
hyperhiveArchetypes.reviewer.meta.prompt = builtins.readFile ./prompts/reviewer.md;
metais plain data: no derivation, no path, no function. The swarm evaluatesmetaalone.- Every archetype needs a
description.permissions,limitsandinferenceare optional and take the shapesPOST /api/agentstakes.promptis optional text that prefillsAGENTS.md, below.iconis optional SVG text, at most 16 KiB, that the create form shows on the archetype's tile;builtins.readFile ./icon.svggives it. The swarm refuses aniconthat isn't SVG text or is over the limit, like any badmeta.flowsis an optional list of notification router flows, below. The swarm ignores other keys inmeta. moduleis a NixOS module for the agent's container. The meta flake imports it into each agent created from the archetype.
Today the swarm reads one flake: the hyperhive source the
builder's host runs, so only the built-ins appear. The meta
flake has one archetype source too, its own hyperhive input, and refuses
an archetype from any other source name.
The prompt
An archetype's meta.prompt is starting text for the new agent's AGENTS.md:
a reviewer that never pushes, a triage agent that keeps its notes in one
place. Picking the archetype in the create form fills the form's AGENTS.md box
with it, next to the permissions, caps and inference it fills. Edit the text
freely; the agent starts with what the box holds when you create it. An
archetype without prompt leaves the box alone.
- The pick replaces the box only while the box is empty or still holds the previous pick's prompt. Text you typed or edited stays.
- The limit is 64 KiB (65536 bytes), the limit of an initial
AGENTS.md. The swarm refuses a longerpromptthe way it refuses any badmeta: the archetype leaves the list, and its name and the reason go into the record'srefusedmap. A blankpromptcounts as none. - The text is a copy made at create. Editing the archetype's
promptlater changes what new agents start with, not theAGENTS.mdof agents that exist. - Each built-in archetype comes with a default prompt. It describes who the agent is and what it cares about, and names no repo, agent or swarm path. Where the files live: the implementation page.
Notification flows
An archetype's meta.flows lists notification router
flows that run for every
agent of the archetype, next to the built-in flows and the ones in the
operator's document. A todo node in them sends to members: every agent
created from the archetype.
hyperhiveArchetypes.triage.meta.flows = [
{
id = "new-issues";
name = "new issues get a greeting";
nodes = [
{ id = "src"; kind = "source"; events = [ "issues" ]; }
{ id = "opened"; kind = "match"; when = [ { field = "action"; equals = "opened"; } ]; }
{
id = "tell";
kind = "todo";
to = "members";
op = "upsert";
key = "forge:{{ repo }}#{{ number }}:greet";
text = "greet {{ repo }}#{{ number }}: {{ title }}";
}
];
edges = [
{ from = "src"; to = "opened"; }
{ from = "opened"; to = "tell"; }
];
}
];
- A flow here has the shape of a flow in the operator's document, with two
differences. Every
todomust send tomembers. A flow that names an agent or an event field's agents, or asks for a review, belongs in the operator's document, and the swarm refuses it as it refuses any badmeta: the archetype leaves the list and the reason goes intorefused. The operator's document in turn refusesmembers, since it has no archetype. - Flow ids are unique within the archetype.
- Use a todo key that starts with
forge:{{ repo }}#{{ number }}:, as the example does. The built-inclosedflow clears todos by that prefix when the issue or PR closes. - A change to the archetype's flows, or to who belongs to it, takes effect within about 10 seconds of the next forge event. An agent outside the swarm gets nothing.
- Custom agents have no archetype and get no archetype flows.
On the board
The notification router card on /swarm lists each archetype flow under
archetype flows, tagged with its archetype and with the agents it applies to
now, drawn as a graph with hit counts like the other flows. The flow follows
the archetype: an edit to the archetype reaches the card and every agent
within about 10 seconds, and the card has no edit button.
- Switch off for the archetype. The
onswitch on the card turns the flow off for every agent of the archetype, as for a built-in. It adds the keyarchetype:<archetype>/<flow id>to the router's list of switched-off flows. - Switch off for one agent. Each agent on the card has its own checkbox.
Clearing it adds
archetype:<archetype>/<flow id>@<agent>to the same list; the other agents keep the flow. - Edit a copy.
duplicateopens the new-flow editor on a copy of the flow as a custom flow. The copy sends to the agent the archetype has when it has just one, and to nobody until you name an agent when it has more. A custom flow can also request a review, which an archetype's flow can't. Switch the archetype's flow off to replace it with your copy. - customize next to an agent opens the new-flow editor on a copy of the flow for that agent alone: its recipient is the agent, and its name ends with the agent's name. Saving it adds the agent's switch-off to the list in the same write, so the agent gets its copy and not both, while the archetype's flow keeps updating for everyone else. Deleting the copy later leaves the agent's switch off; switch it on again to give the agent the archetype's flow.
- Destroying an agent removes its per-agent switch-offs from the list, so a new agent of the same name starts with every archetype flow on. If that cleanup fails, the controller logs the agent and leaves the keys; destroying the agent again retries it.
- A customized copy is a custom flow addressed to the agent's name. It survives the destroy like any custom flow, so delete it by hand if you reuse the name; otherwise the new agent gets the copy and the archetype's flow.
- A key for a flow or agent that no longer exists stays in the list and does nothing, so editing an archetype never breaks the stored flows. The key stays after its flow goes: a later flow with the same archetype and id comes up already switched off; switch it on from its card.
How the list stays current
The swarm controller asks the builder for the list when the queue connects and every 10 minutes after. A builder host redeploy can change it, and the next pass picks the change up. The controller leaves an archetype that fails its check off the list and logs it. When no builder answers, the controller keeps the stored list, and a swarm with no builder shows no archetype select.
The query, the stored record and the retry timing:
archetypes.md.
Creating an agent from an archetype
The create form sends the picked archetype as archetype on
POST /api/agents, { "source": "hyperhive", "name": "reviewer" }. The
controller refuses with 400 an archetype the stored list doesn't hold, then:
- stores the choice in the
agent-archetypeKV bucket, keyed by agent name, next to the agent's permissions, caps and inference; - queues the creation graph without
CreateRepo,AddRepoMemberandInitAgentConfigRepo. Identity, forge user, docs read, the mints and the wanted state stay, and the deploy waits on those alone.
Destroying the agent deletes its key.
Every hive may read any key of the bucket
($JS.API.DIRECT.GET.KV_agent-archetype.>) and write none; only the
controller writes it.
Deploy swarm-nats-auth before the hives: every provision reads the
agent's key, and a hive whose queue connection predates the grant gets a
refused read, so its Provision nodes fail until it reconnects.
swarm-controller renders internal/meta's flake.nix with the
hive-meta-flake crate, and reads each agent's archetype from the
agent-archetype bucket to do so. For an archetype agent the render:
- adds no
agent-<name>input and reads no config repo, and lists the agent asmkAgent { …; archetype = { source = "hyperhive"; name = "<name>"; }; }; - makes
mkAgentimporthyperhive.hyperhiveArchetypes.<name>.modulein place of the agent's own flake, and setHIVE_ARCHETYPEin the harness environment.
The swarm builds from internal/meta alone and the hive deploys that closure. The hive reads the agent's key when it
provisions the agent and on every rebuild, and keeps the last value read in
/var/lib/hyperhive/swarm-agent-archetypes.json. When the read fails, a rebuild keeps the stored value. For an
archetype agent the hive also:
- deploys the closure its record declares, as every agent does.
The agent's system prompt says it has no config repo and names its archetype.
The module comes from the hyperhive input that internal/meta pins, not
from the hive's own. When that pin predates the archetype, the agent's build
fails with this hive's hyperhive input has no archetype <name>; update that input. Update the hyperhive pin in internal/meta to fix it.
Turn into custom
An archetype agent can become a custom agent with its own
agent-configs/<name> repo, either from the agent's overview in the swarm UI
(the "turn into custom" button asks first) or with POST /api/agents/{name}/custom.
The agent keeps its state, permissions, caps, inference settings and accounts.
Its configuration stays the same, except that it no longer has HIVE_ARCHETYPE
in its environment. Keeping the config current is then up to the repo's owner.
Nothing here undoes it.
The controller refuses with 409 an agent that no hive or more than one hive
places, and one whose hive doesn't list the
no-config-checkout capability (see below). Otherwise it queues a job graph:
-
CreateRepo,CreateForgeUserandAddRepoMember: the repo and the agent's access to the repo, as for any custom agent. Each is a no-op for what exists. -
SeedArchetypeConfigcommits two files to the repo. It copies nothing from the archetype:flake.nixdeclares the archetype's source as an input, at the URLinternal/metaholds for that source today (a pinned rev, which is the input's only pin: the repo has no lock, and a source meta doesn't pin to a commit fails the node), and importsinputs.<source>.hyperhiveArchetypes.<name>.modulenext to./agent.nix;agent.nixis an empty module for the owner's edits.
The node leaves a repo whose
flake.nixalready is this file alone, whatever URL it pins. Any otherflake.nixfails the node. -
DropArchetypedeletes the agent'sagent-archetypekey, only after the seed and the member grant succeeded. A failure before it leaves the agent archetype-built and working, and you can send the same request again. -
UpdateMeta, then the build and the deploy, as for a merged config PR. If the build fails, the agent is custom and has no key. Sending the request again then queues only this step, as the earlier ones have run.
When the source is hyperhive, the meta flake sets
agent-<name>.inputs.hyperhive.follows = "hyperhive" for an agent whose
flake.nix or flake.lock declares a hyperhive input, so the lock holds one
hyperhive, and the module comes from the pin internal/meta holds. Any other
source keeps the pinned URL from its seeded flake.nix, and the meta lock
records that rev. The follows applies to every custom agent whose flake.nix
declares a hyperhive input, not only converted ones. A hyperhive node left
in a lock doesn't count.
Which hives may convert
A hive that keeps a checkout of a custom agent's config would create one for
the converted agent, under the container's running mount. A hive that lists
no-config-checkout under capabilities in the status it publishes (the
document GET /api/hives/status serves as snapshot) keeps none: it deploys a
custom agent's closure from the swarm alone, and the agent clones its own repo from
the forge. The controller reads the agent's hive's latest status and refuses
unless it's fresh and lists the capability; an older hive lists none. Deploy
the release to every hive that places archetype agents before converting theirs.