Nothing matches those filters.

Article

1
01:35

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.

Full text · 5,418 chars
We introduced GAINs and HCINs as the architecture of multi-agent AI. The obvious question now is: how do you actually build one? The striking answer is that the agent tools developers already use — Claude Code, OpenAI Codex, OpenClaw, and Hermes — have each, independently, implemented the GAIN/HCIN primitives. Their defaults even encode the same lessons the architecture points to. GAINs and HCIN are the map; these tools are the implementation surface. The mapping Stripped to primitives, the correspondence is close to one-to-one: - Coordinator (CCA / PAC) → Claude Code's team lead; Codex's orchestrator (or an Agents-SDK project-manager agent); an OpenClaw worker organization. - Specialized ephemeral agents → subagents and teammates (Claude Code); subagents with custom agent files (Codex); isolated specialist workers (OpenClaw). - Validation agents → Codex's gated hand-offs; Claude Code's plan-approval, task-completion hooks, and adversarial "scientific-debate" teammates. - Privileged / asymmetric information flow → each worker's own context window, plus per-agent credentials. - Shared memory (collective knowledge base) → Claude Code's shared task list + mailbox within a run; Hermes' persistent memory across runs. Two patterns A GAIN as subagents. The simplest network maps directly onto subagents: the parent agent is the coordinator — it decomposes the task, spawns one specialist per subtask in its own context window, runs them in parallel, and synthesizes the returned results. The children report only to the parent. Use this when specialists are independent and only their results matter (parallel research, parallel review, fan-out extraction). It's the cost-efficient GAIN, because each child's work is summarized back rather than dumped into the orchestrator. A GAIN/HCIN as a coordinating team. When specialists need to share and challenge each other, use a coordinating agent team (Claude Code's). A lead coordinates teammates that each have their own context, share a task list with dependency tracking, message each other through a mailbox, and claim work with file locking. The documented "spawn teammates to disprove each other's theories, like a scientific debate" pattern is the architecture's verification idea made operational — independent critics surface the wrong answer a single agent would anchor on. HCIN's best idea ships as the default HCIN's load-bearing principle — privileged, need-to-know information flow — is not something you bolt on. Every one of these tools gives each worker its own context window, loaded with its task and the shared project context but not the coordinator's full history. OpenClaw states the rationale in its own terms: isolation by design… prevents context pollution and ensures each agent reasons clearly about its specific task. OpenClaw extends the same principle to credentials — authentication profiles are strictly per-agent, so a worker holds only the access it needs and can't leak it to peers. That is least-privilege (the ALARA principle from the HCIN write-up) applied to access, not just context. You don't design privileged flow from scratch on these tools; you configure each agent's scope, and the tool enforces it. Verification at the seams A single end-of-line check isn't enough; you verify at the seams to stop a confident error from cascading into false consensus. The tools provide the seams: Codex's gated hand-offs (a project-manager agent confirms an upstream deliverable before advancing); Claude Code's plan approval (a teammate works in read-only plan mode until the lead approves) and completion hooks (a hook can reject a task completion and send feedback). Implementing a GAIN's validation agents is a matter of choosing which seams to gate, not building a verifier from nothing. The honest gap: recursion HCIN's deep recursive-fractal nesting — agents made of sub-networks made of sub-agents — is the one place the architecture runs ahead of the tools, and it's worth being honest about. The tools deliberately bound recursion: Codex caps nesting depth at one by default (a child can spawn, but its children can't) and warns that raising it multiplies cost and latency; Claude Code disallows nested teams entirely (only the lead manages the team). Today, you get two or three explicit levels, not arbitrary depth — and that refusal to nest freely is not a deficiency, it's the bounded-recursion discipline the research recommends, enforced as a default. Design your hierarchy shallow on purpose. Memory, realized The collective knowledge base — durable memory that accumulates across runs — is the piece most tools leave to you, with one exception: Hermes builds it in, with a learning loop that remembers across sessions and turns repeated work into reusable skills. When a network needs institutional memory rather than per-run coordination, that's the component to add. The takeaway You don't have to choose between the architecture and the tooling. GAINs and HCIN tell you what to build — a coordinator, scoped specialists, verification at the seams, bounded depth, a knowledge base — and Claude Code, Codex, OpenClaw, and Hermes give you the primitives to build it, with the hard-won lessons already wired in as their defaults. Map the concept to the primitive, configure the scopes and the gates deliberately, keep the hierarchy shallow, and respect the cost — and you have a real, reliable agent network.