Implementing Agent Networks: GAINs and HCIN on Real Agents (Claude Code, Codex, OpenClaw, Hermes)
The multi-agent network architectures called GAINs and HCINs are already built into today's agent tools, so you can implement them without designing from scratch. Claude Code, OpenAI's Codex, OpenClaw, and Hermes each supply the key pieces: a coordinating lead agent, specialized worker agents, validation gates between steps, and separate context windows so each worker only sees what it needs. The main gap is deep recursion, since tools cap nesting at one or two levels — which the architecture itself recommends. Hermes uniquely ships persistent shared memory that accumulates across sessions.
Notes
Implementing Agent Networks: GAINs and HCIN on Real Agents
Source: Prompt Engineering Institute (feed), published 2026-06-26. Maps the GAIN (General Agent Interaction Network) and HCIN (Hierarchical Collective Intelligence Network) architectures onto shipping agent tools.
The tool-to-primitive mapping
- Coordinator (CCA/PAC) → Claude Code team lead; Codex orchestrator (or Agents-SDK project-manager agent); an OpenClaw worker organization.
- Specialized ephemeral agents → Claude Code subagents/teammates; Codex subagents with custom agent files; OpenClaw isolated specialist workers.
- Validation agents → Codex gated hand-offs; Claude Code plan-approval, task-completion hooks, adversarial "scientific-debate" teammates.
- Privileged/asymmetric information flow → per-worker context window + per-agent credentials.
- Shared memory (collective knowledge base) → Claude Code's shared task list + mailbox within a run; Hermes' persistent memory across runs.
Two implementation patterns
GAIN as subagents — parent = coordinator; decomposes task, spawns one specialist per subtask in its own context window, runs parallel, synthesizes results; children report only to parent. Best when specialists are independent and only results matter (parallel research/review, fan-out extraction). Cost-efficient because children summarize back rather than dumping context into the orchestrator.
GAIN/HCIN as coordinating team — lead coordinates teammates, each with own context, shared task list with dependency tracking, mailbox messaging, file-lock work claiming. The "spawn teammates to disprove each other's theories, like a scientific debate" pattern operationalizes the verification idea — independent critics surface errors a single agent would anchor on.
Key claims
- HCIN's load-bearing principle (privileged, need-to-know flow) ships as default: each worker gets its own context window loaded with its task + shared project context, not the coordinator's full history.
- OpenClaw, on isolation: "isolation by design… prevents context pollution and ensures each agent reasons clearly about its specific task." Extends principle to credentials — auth profiles strictly per-agent (least-privilege / ALARA applied to access, not just context).
- Verification at the seams (not end-of-line): Codex gated hand-offs (project-manager confirms upstream deliverable); Claude Code plan-approval (read-only plan mode until lead approves) + completion hooks that can reject and send feedback.
The honest gap: recursion
HCIN's deep fractal nesting is where architecture outruns the tools. Codex caps nesting depth at one by default (a child can spawn, its children can't) and warns raising it multiplies cost and latency; Claude Code disallows nested teams entirely. Practical result: 2–3 explicit levels, not arbitrary depth. The article reframes this as the research's own bounded-recursion discipline enforced as default — "design your hierarchy shallow on purpose."
Memory caveat
The collective knowledge base is the piece most tools leave to you; Hermes is the exception, with a learning loop remembering across sessions and turning repeated work into reusable skills.
Takeaway
No choice between architecture and tooling: GAINs/HCIN define what to build (coordinator, scoped specialists, verification at seams, bounded depth, knowledge base); the four tools provide the primitives, with lessons already wired in as defaults. Map concept→primitive, configure scopes/gates deliberately, keep hierarchy shallow, respect cost.