Ontology and Memory Systems (2/13) — Multi-Agent Ontology in Practice

OpenClaw 도구(Tools)와 훅(Hooks) 설계 — 최소 권한 원칙 적용기

Building a structure where multiple agents actually collaborate


Key Takeaways

  • Agent-to-agent communication requires two distinct paths: lightweight insight delivery and acknowledged task requests
  • Context isolation (1 agent = 1 role = minimum context) is the key to maintaining system quality at scale
  • Knowledge is managed across three layers: global CLAUDE.md → project CLAUDE.md → session memory

도구 프로파일과 그룹 제어

Background

Part 1 covered the concept and rationale of ontology — why defining relationships between agents matters, and what roles CLAUDE.md and memory serve.

Part 2 covers implementation. How agents exchange data, why context must be isolated, and how to layer memory.


Body

1. Message Hub — Designing Agent-to-Agent Communication

Once relationships are defined in the ontology, a channel for actual data exchange is needed.

Agent-to-agent communication splits into two types with fundamentally different characteristics.

① Insight delivery (fire-and-forget)

POST /api/webhooks
{"content": "...", "tags": ["analysis"], "source": "agent-name"}

A lightweight notification — "here's something I found." Send and done. No confirmation of receipt or processing.

Use cases: - An analysis agent forwards insights to a dashboard - A signal agent logs a state change

② Task request (ACK required)

POST /api/agent-messages
{
  "fromAgent": "home-server-manager",
  "toAgent": "write-score-director",
  "messageType": "task_request",
  "intent": "blog_material",
  "body": {"text": "Please write a blog post based on this material"}
}

This type requires an acknowledgment (ACK). It supports retry, thread tracking, and state management.

The receiving agent confirms and responds:

POST /api/agent-messages/{messageId}/ack
{"status": "acked", "response": {"text": "Received. Starting draft."}}

The reason for separating these two paths is clear. Requiring ACK on every message slows the system. Using fire-and-forget for everything drops critical tasks. Informational signals travel light; task handoffs travel with confirmation.

Practical example: The home server manager sends a blog material request to the write director via task_request. The write director ACKs and begins work. No human relay required — agents hand off work directly.


2. Context Isolation — Why Agents Must Be Separate

"Can't I just put every role into one powerful agent?"

This was tested. It does not work. Three reasons:

① Context contamination

When stock analysis context and Flutter UI code share the same conversation, the model conflates them. A prompt like "analyze the return value of this function" becomes ambiguous — stock data or code? This ambiguity emerges in practice.

② CLAUDE.md rule conflicts

Combining rules from multiple projects into a single CLAUDE.md creates contradictions. "Write concisely" (content) and "enumerate every edge case" (code) cannot coexist in the same instruction set.

③ Prompt length and performance degradation

Models tend to follow earlier instructions less faithfully as prompt length increases. Reducing irrelevant context is a performance optimization in itself.

Isolation principles: - 1 agent = 1 role = minimum context - When handing off a task to a sub-agent, do not pass the full session history - Pass only what the agent needs to know; isolate the rest

This principle is why quality holds even as the number of agents grows.


훅(Hooks) — 시스템 자동화의 축

3. Three-Layer Memory Architecture

Where and at what granularity to store knowledge matters. Three layers handle this.

Layer 1: Global CLAUDE.md — what every agent knows

~/.claude/CLAUDE.md  (symlinked across all agents)

Contents: - Full agent inventory and relationships (the ontology) - User judgment criteria and values - Inter-agent communication contracts - Cross-project rules

Every agent reads this at session start. Information here is shared across the entire system.

Layer 2: Project CLAUDE.md — what only this agent knows

{project-root}/CLAUDE.md

Contents: - Project purpose and structure - Project-specific rules and workflows - Skill triggers, agent role separation - Technology stack, API configuration

Project-specific knowledge is isolated so it does not contaminate other agents.

Layer 3: Session memory — what accumulates during conversations

{project}/.claude/projects/{id}/memory/

Contents: - User feedback ("don't do this," "that worked well") - Project state changes - Patterns learned mid-task

Persists across sessions. The agent for this project progressively calibrates to the user.

Flow between layers:

Repeated feedback in sessions
  → promoted to rule in project CLAUDE.md
    → if common across projects, promoted to global CLAUDE.md

Knowledge propagates upward. A principle validated in one agent eventually spreads to the full system.


4. Practical Tips for Ontology Management

Operational lessons collected over time.

① Keep a relationship table in CLAUDE.md

## Relationships
- OpenClaw → HomeServer: insights → dashboard display [data]
- QuietLeaf ↔ GrowNote: Flutter patterns shared [tech]
- MyLife → WriteScore: experience → content material [content]

Type tags ([data], [tech], [content]) make the relationship type readable at a glance.

② Checklist for adding a new agent

  • Add the role to the ontology
  • Define at least one relationship with an existing agent
  • If no relationship exists → reconsider whether the agent is necessary
  • Update global CLAUDE.md

③ Periodically validate relationships

Verify that relationships defined in the ontology are actually active. If the ontology says "A → B data transfer" but no transfer has ever occurred, that relationship must be removed or implemented.

④ Keep global CLAUDE.md concise

Ontology information, user preferences, communication contracts — that's it. Detailed implementation belongs in project CLAUDE.md. The shorter this file, the more reliably the model follows it, since it is read every session.


Design Considerations

  • A message hub is not required from day one. Human relay is sufficient early on — "take this agent's output and pass it to that one." Automate when the frequency justifies it.

  • The balance between isolation and sharing is critical. Over-isolation turns agents into islands; over-sharing contaminates context. Sharing belongs in global CLAUDE.md; isolation belongs in project CLAUDE.md. This boundary requires conscious management.

  • The ontology is a living document. Agents are added and removed, relationships change, roles evolve. It is not a one-time artifact — it requires continuous updates.

  • Replace agents incrementally. When replacing a stable agent, use parallel operation (Strangler Fig pattern) and a validation phase. If the new agent exhibits token runaway or unexpected behavior, the system must be able to revert to the original agent immediately.


Closing

One agent is a tool. Many agents without an ontology is chaos. Many agents with an ontology is a system.

The difference is not the number of agents — it is the design of relationships and the layering of knowledge. Share CLAUDE.md across agents, communicate through a message hub, isolate context, and layer memory — and the system maintains quality as it scales.

If you are adding agents one by one, now is the time to formalize the ontology.

댓글

이 블로그의 인기 게시물

Agent Memory Engine (2/10) — Building an AI Agent Memory System with SQLite Alone

"ML Foundations (9/9) — PyTorch vs TensorFlow, and the Road to Local LLMs"

"RAG Core Study (14/26) — Evaluation Sets with RAGAS & DeepEval"

"ML Foundations (8/9) — Deep Learning Architectures: CNN, RNN, Attention"

"ML Foundations (7/9) — Deep Learning Training: Optimizers, Regularization, Initialization"

OpenClaw to Hermes Migration (2/13) — What to Preserve, Partially Port, or Discard

AI Agents I Built (5/7) — Building an Automated Blogger API Publishing System