hive-concepts
目標達成型エージェント開発の基礎として、構造やノードの種類、ツール発見、ワークフローといった主要な概念を理解し、エージェント開発を円滑に進める、またはエージェントの基本を把握するSkill。
📜 元の英語説明(参考)
Core concepts for goal-driven agents - architecture, node types (event_loop, function), tool discovery, and workflow overview. Use when starting agent development or need to understand agent fundamentals.
🇯🇵 日本人クリエイター向け解説
目標達成型エージェント開発の基礎として、構造やノードの種類、ツール発見、ワークフローといった主要な概念を理解し、エージェント開発を円滑に進める、またはエージェントの基本を把握するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o hive-concepts.zip https://jpskill.com/download/9606.zip && unzip -o hive-concepts.zip && rm hive-concepts.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/9606.zip -OutFile "$d\hive-concepts.zip"; Expand-Archive "$d\hive-concepts.zip" -DestinationPath $d -Force; ri "$d\hive-concepts.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
hive-concepts.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
hive-conceptsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
エージェントの構築 - コアコンセプト
Python パッケージとして、目標駆動型エージェントを構築するための基礎知識。
アーキテクチャ: Python サービス (JSON 設定ではない)
エージェントは Python パッケージとして構築されます。
exports/my_agent/
├── __init__.py # パッケージのエクスポート
├── __main__.py # CLI (run, info, validate, shell)
├── agent.py # グラフの構築 (goal, edges, agent class)
├── nodes/__init__.py # ノードの定義 (NodeSpec)
├── config.py # ランタイム設定
└── README.md # ドキュメント
重要な原則: エージェントは構築中に可視化され、編集可能である
- コンポーネントが承認されると、ファイルがすぐに作成されます
- ユーザーはエディターでファイルの成長を監視できます
- セッション状態はありません - ファイルへの直接書き込みのみ
- 「エクスポート」ステップはありません - エージェントは構築が完了すると準備完了です
コアコンセプト
Goal
成功基準と制約 (agent.py に書き込まれます)
goal = Goal(
id="research-goal",
name="Technical Research Agent",
description="技術的なトピックを徹底的に調査する",
success_criteria=[
SuccessCriterion(
id="completeness",
description="トピックのすべての側面を網羅する",
metric="coverage_score",
target=">=0.9",
weight=0.4,
),
# 合計 3〜5 個の成功基準
],
constraints=[
Constraint(
id="accuracy",
description="すべての情報は検証済みである必要がある",
constraint_type="hard",
category="quality",
),
# 合計 1〜5 個の制約
],
)
Node
作業単位 (nodes/init.py に書き込まれます)
ノードの種類:
event_loop— ツール実行と判定ベースの評価を備えた、複数ターンのストリーミングループ。ツールを使用しても、使用しなくても動作します。function— 決定論的な Python 操作。LLM は関与しません。
search_node = NodeSpec(
id="search-web",
name="ウェブ検索",
description="情報を検索して結果を抽出する",
node_type="event_loop",
input_keys=["query"],
output_keys=["search_results"],
system_prompt="ウェブで {query} を検索します。web_search ツールを使用して結果を見つけ、set_output を呼び出して保存します。",
tools=["web_search"],
)
イベントループノードの NodeSpec フィールド:
| フィールド | デフォルト | 説明 |
|---|---|---|
client_facing |
False |
True の場合、出力をユーザーにストリーミングし、ターン間で入力をブロックします |
nullable_output_keys |
[] |
設定されない可能性のある出力キー (相互に排他的な出力の場合) |
max_node_visits |
1 |
このノードが 1 回の実行で実行される最大回数。フィードバックループのターゲットの場合は >1 に設定します |
Edge
ノード間の接続 (agent.py に書き込まれます)
エッジの条件:
on_success— ノードが成功した場合に続行します (最も一般的)on_failure— エラーを処理しますalways— 常に続行しますconditional— ノードの出力を評価する式に基づきます
エッジの優先度:
優先度は、複数のエッジが同じノードから離れる場合に評価順序を制御します。優先度の高いエッジが最初に評価されます。フィードバックエッジ (以前のノードにループバックするエッジ) には負の優先度を使用します。
# 順方向エッジ (最初に評価されます)
EdgeSpec(
id="review-to-campaign",
source="review",
target="campaign-builder",
condition=EdgeCondition.CONDITIONAL,
condition_expr="output.get('approved_contacts') is not None",
priority=1,
)
# フィードバックエッジ (順方向エッジの後に評価されます)
EdgeSpec(
id="review-feedback",
source="review",
target="extractor",
condition=EdgeCondition.CONDITIONAL,
condition_expr="output.get('redo_extraction') is not None",
priority=-1,
)
クライアント対応ノード
ユーザーとの複数ターンの会話の場合、ノードで client_facing=True を設定します。ノードは次のようになります。
- LLM 出力をエンドユーザーに直接ストリーミングします
- 会話のターン間でユーザー入力をブロックします
inject_event()を介して新しい入力が挿入されると再開します
intake_node = NodeSpec(
id="intake",
name="インテーク",
description="ユーザーから要件を収集する",
node_type="event_loop",
client_facing=True,
input_keys=[],
output_keys=["repo_url", "project_url"],
system_prompt="あなたはインテークエージェントです。ユーザーにリポジトリ URL とプロジェクト URL を尋ねてください。",
)
レガシーノート: 古い
pause_nodes/entry_pointsパターンも機能しますが、新しいエージェントではclient_facing=Trueが推奨されます。
STEP 1 / STEP 2 プロンプトパターン: クライアント対応ノードの場合、システムプロンプトを次の 2 つの明示的なフェーズで構成します。
system_prompt="""\
**STEP 1 — ユーザーに応答します (テキストのみ、ツール呼び出しはなし):**
[情報を提示したり、質問したりします。]
**STEP 2 — ユーザーが応答した後、set_output を呼び出します:**
[構造化された出力で set_output を呼び出します]
"""
これにより、ユーザーが応答する機会を得る前に、LLM が set_output を時期尚早に呼び出すのを防ぎます。
ノード設計: より少なく、より豊富なノード
多くの薄い単一目的のノードよりも、より多くの作業を行うノードを少なくすることを推奨します。
- 悪い例: 8 つの薄いノード (クエリの解析 → 検索 → フェッチ → 評価 → 合成 → 書き込み → チェック → 保存)
- 良い例: 4 つの豊富なノード (インテーク → 調査 → レビュー → レポート)
理由: 各ノード境界では、出力のシリアル化とコンテキストの受け渡しが必要です。ノードが少ないほど、LLM はノード内の作業の完全なコンテキストを保持します。検索、フェッチ、分析を行う調査ノードは、すべてのソースマテリアルを会話履歴に保持します。
クロスエッジ入力用の nullable_output_keys
ノードが特定のエッジでのみ到着する入力 (たとえば、feedback はレビュー → 調査フィードバックループからのみ来て、インテーク → 調査からは来ない) を受信する場合、それらのキーを nullable_output_keys としてマークします。
research_node = NodeSpec(
id="research",
input_keys=["research_brief", "feedback"],
nullable_output_keys=["feedback"], # 最初の訪問時には存在しません
max_node_visits=3,
...
)
イベントループアーキテクチャの概念
EventLoopNode の仕組み
イベントループノードは、複数ターンのループを実行します。
- LLM はシステムプロンプト + 会話履歴を受け取ります
(原文はここで切り詰められています)
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Building Agents - Core Concepts
Foundational knowledge for building goal-driven agents as Python packages.
Architecture: Python Services (Not JSON Configs)
Agents are built as Python packages:
exports/my_agent/
├── __init__.py # Package exports
├── __main__.py # CLI (run, info, validate, shell)
├── agent.py # Graph construction (goal, edges, agent class)
├── nodes/__init__.py # Node definitions (NodeSpec)
├── config.py # Runtime config
└── README.md # Documentation
Key Principle: Agent is visible and editable during build
- Files created immediately as components are approved
- User can watch files grow in their editor
- No session state - just direct file writes
- No "export" step - agent is ready when build completes
Core Concepts
Goal
Success criteria and constraints (written to agent.py)
goal = Goal(
id="research-goal",
name="Technical Research Agent",
description="Research technical topics thoroughly",
success_criteria=[
SuccessCriterion(
id="completeness",
description="Cover all aspects of topic",
metric="coverage_score",
target=">=0.9",
weight=0.4,
),
# 3-5 success criteria total
],
constraints=[
Constraint(
id="accuracy",
description="All information must be verified",
constraint_type="hard",
category="quality",
),
# 1-5 constraints total
],
)
Node
Unit of work (written to nodes/init.py)
Node Types:
event_loop— Multi-turn streaming loop with tool execution and judge-based evaluation. Works with or without tools.function— Deterministic Python operations. No LLM involved.
search_node = NodeSpec(
id="search-web",
name="Search Web",
description="Search for information and extract results",
node_type="event_loop",
input_keys=["query"],
output_keys=["search_results"],
system_prompt="Search the web for: {query}. Use the web_search tool to find results, then call set_output to store them.",
tools=["web_search"],
)
NodeSpec Fields for Event Loop Nodes:
| Field | Default | Description |
|---|---|---|
client_facing |
False |
If True, streams output to user and blocks for input between turns |
nullable_output_keys |
[] |
Output keys that may remain unset (for mutually exclusive outputs) |
max_node_visits |
1 |
Max times this node executes per run. Set >1 for feedback loop targets |
Edge
Connection between nodes (written to agent.py)
Edge Conditions:
on_success— Proceed if node succeeds (most common)on_failure— Handle errorsalways— Always proceedconditional— Based on expression evaluating node output
Edge Priority:
Priority controls evaluation order when multiple edges leave the same node. Higher priority edges are evaluated first. Use negative priority for feedback edges (edges that loop back to earlier nodes).
# Forward edge (evaluated first)
EdgeSpec(
id="review-to-campaign",
source="review",
target="campaign-builder",
condition=EdgeCondition.CONDITIONAL,
condition_expr="output.get('approved_contacts') is not None",
priority=1,
)
# Feedback edge (evaluated after forward edges)
EdgeSpec(
id="review-feedback",
source="review",
target="extractor",
condition=EdgeCondition.CONDITIONAL,
condition_expr="output.get('redo_extraction') is not None",
priority=-1,
)
Client-Facing Nodes
For multi-turn conversations with the user, set client_facing=True on a node. The node will:
- Stream its LLM output directly to the end user
- Block for user input between conversational turns
- Resume when new input is injected via
inject_event()
intake_node = NodeSpec(
id="intake",
name="Intake",
description="Gather requirements from the user",
node_type="event_loop",
client_facing=True,
input_keys=[],
output_keys=["repo_url", "project_url"],
system_prompt="You are the intake agent. Ask the user for the repo URL and project URL.",
)
Legacy Note: The old
pause_nodes/entry_pointspattern still works butclient_facing=Trueis preferred for new agents.
STEP 1 / STEP 2 Prompt Pattern: For client-facing nodes, structure the system prompt with two explicit phases:
system_prompt="""\
**STEP 1 — Respond to the user (text only, NO tool calls):**
[Present information, ask questions, etc.]
**STEP 2 — After the user responds, call set_output:**
[Call set_output with the structured outputs]
"""
This prevents the LLM from calling set_output prematurely before the user has had a chance to respond.
Node Design: Fewer, Richer Nodes
Prefer fewer nodes that do more work over many thin single-purpose nodes:
- Bad: 8 thin nodes (parse query → search → fetch → evaluate → synthesize → write → check → save)
- Good: 4 rich nodes (intake → research → review → report)
Why: Each node boundary requires serializing outputs and passing context. Fewer nodes means the LLM retains full context of its work within the node. A research node that searches, fetches, and analyzes keeps all the source material in its conversation history.
nullable_output_keys for Cross-Edge Inputs
When a node receives inputs that only arrive on certain edges (e.g., feedback only comes from a review → research feedback loop, not from intake → research), mark those keys as nullable_output_keys:
research_node = NodeSpec(
id="research",
input_keys=["research_brief", "feedback"],
nullable_output_keys=["feedback"], # Not present on first visit
max_node_visits=3,
...
)
Event Loop Architecture Concepts
How EventLoopNode Works
An event loop node runs a multi-turn loop:
- LLM receives system prompt + conversation history
- LLM responds (text and/or tool calls)
- Tool calls are executed, results added to conversation
- Judge evaluates: ACCEPT (exit loop), RETRY (loop again), or ESCALATE
- Repeat until judge ACCEPTs or max_iterations reached
EventLoopNode Runtime
EventLoopNodes are auto-created by GraphExecutor at runtime. You do NOT need to manually register them. Both GraphExecutor (direct) and AgentRuntime / create_agent_runtime() handle event_loop nodes automatically.
# Direct execution — executor auto-creates EventLoopNodes
from framework.graph.executor import GraphExecutor
from framework.runtime.core import Runtime
runtime = Runtime(storage_path)
executor = GraphExecutor(
runtime=runtime,
llm=llm,
tools=tools,
tool_executor=tool_executor,
storage_path=storage_path,
)
result = await executor.execute(graph=graph, goal=goal, input_data=input_data)
# TUI execution — AgentRuntime also works
from framework.runtime.agent_runtime import create_agent_runtime
runtime = create_agent_runtime(
graph=graph, goal=goal, storage_path=storage_path,
entry_points=[...], llm=llm, tools=tools, tool_executor=tool_executor,
)
set_output
Nodes produce structured outputs by calling set_output(key, value) — a synthetic tool injected by the framework. When the LLM calls set_output, the value is stored in the output accumulator and made available to downstream nodes via shared memory.
set_output is NOT a real tool — it is excluded from real_tool_results. For client-facing nodes, this means a turn where the LLM only calls set_output (no other tools) is treated as a conversational boundary and will block for user input.
JudgeProtocol
The judge is the SOLE mechanism for acceptance decisions. Do not add ad-hoc framework gating, output rollback, or premature rejection logic. If the LLM calls set_output too early, fix it with better prompts or a custom judge — not framework-level guards.
The judge controls when a node's loop exits:
- Implicit judge (default, no judge configured): ACCEPTs when the LLM finishes with no tool calls and all required output keys are set
- SchemaJudge: Validates outputs against a Pydantic model
- Custom judges: Implement
evaluate(context) -> JudgeVerdict
LoopConfig
Controls loop behavior:
max_iterations(default 50) — prevents infinite loopsmax_tool_calls_per_turn(default 10) — limits tool calls per LLM responsetool_call_overflow_margin(default 0.5) — wiggle room before discarding extra tool calls (50% means hard cutoff at 150% of limit)stall_detection_threshold(default 3) — detects repeated identical responsesmax_history_tokens(default 32000) — triggers conversation compaction
Data Tools (Spillover Management)
When tool results exceed the context window, the framework automatically saves them to a spillover directory and truncates with a hint. Nodes that produce or consume large data should include the data tools:
save_data(filename, data)— Write data to a file in the data directoryload_data(filename, offset=0, limit=50)— Read data with line-based paginationlist_data_files()— List available data filesserve_file_to_user(filename, label="")— Get a clickable file:// URI for the user
Note: data_dir is a framework-injected context parameter — the LLM never sees or passes it. GraphExecutor.execute() sets it per-execution via contextvars, so data tools and spillover always share the same session-scoped directory.
These are real MCP tools (not synthetic). Add them to nodes that handle large tool results:
research_node = NodeSpec(
...
tools=["web_search", "web_scrape", "load_data", "save_data", "list_data_files"],
)
Fan-Out / Fan-In
Multiple ON_SUCCESS edges from the same source create parallel execution. All branches run concurrently via asyncio.gather(). Parallel event_loop nodes must have disjoint output_keys.
max_node_visits
Controls how many times a node can execute in one graph run. Default is 1. Set higher for nodes that are targets of feedback edges (review-reject loops). Set 0 for unlimited (guarded by max_steps).
Tool Discovery & Validation
CRITICAL: Before adding a node with tools, you MUST verify the tools exist.
Tools are provided by MCP servers. Never assume a tool exists - always discover dynamically.
Step 1: Register MCP Server (if not already done)
mcp__agent-builder__add_mcp_server(
name="tools",
transport="stdio",
command="python",
args='["mcp_server.py", "--stdio"]',
cwd="../tools"
)
Step 2: Discover Available Tools
# List all tools from all registered servers
mcp__agent-builder__list_mcp_tools()
# Or list tools from a specific server
mcp__agent-builder__list_mcp_tools(server_name="tools")
Step 3: Validate Before Adding Nodes
Before writing a node with tools=[...]:
- Call
list_mcp_tools()to get available tools - Check each tool in your node exists in the response
- If a tool doesn't exist:
- DO NOT proceed with the node
- Inform the user: "The tool 'X' is not available. Available tools are: ..."
- Ask if they want to use an alternative or proceed without the tool
Tool Validation Anti-Patterns
- Never assume a tool exists - always call
list_mcp_tools()first - Never write a node with unverified tools - validate before writing
- Never silently drop tools - if a tool doesn't exist, inform the user
- Never guess tool names - use exact names from discovery response
Workflow Overview: Incremental File Construction
1. CREATE PACKAGE → mkdir + write skeletons
2. DEFINE GOAL → Write to agent.py + config.py
3. FOR EACH NODE:
- Propose design (event_loop for LLM work, function for deterministic)
- User approves
- Write to nodes/__init__.py IMMEDIATELY
- (Optional) Validate with test_node
4. CONNECT EDGES → Update agent.py
- Use priority for feedback edges (negative priority)
- (Optional) Validate with validate_graph
5. FINALIZE → Write agent class to agent.py
6. DONE - Agent ready at exports/my_agent/
Files written immediately. MCP tools optional for validation/testing bookkeeping.
When to Use This Skill
Use hive-concepts when:
- Starting a new agent project and need to understand fundamentals
- Need to understand agent architecture before building
- Want to validate tool availability before proceeding
- Learning about node types, edges, and graph execution
Next Steps:
- Ready to build? → Use
hive-createskill - Need patterns and examples? → Use
hive-patternsskill
MCP Tools for Validation
After writing files, optionally use MCP tools for validation:
test_node - Validate node configuration with mock inputs
mcp__agent-builder__test_node(
node_id="search-web",
test_input='{"query": "test query"}',
mock_llm_response='{"results": "mock output"}'
)
validate_graph - Check graph structure
mcp__agent-builder__validate_graph()
# Returns: unreachable nodes, missing connections, event_loop validation, etc.
configure_loop - Set event loop parameters
mcp__agent-builder__configure_loop(
max_iterations=50,
max_tool_calls_per_turn=10,
stall_detection_threshold=3,
max_history_tokens=32000
)
Key Point: Files are written FIRST. MCP tools are for validation only.
Related Skills
- hive-create - Step-by-step building process
- hive-patterns - Best practices: judges, feedback edges, fan-out, context management
- hive - Complete workflow orchestrator
- hive-test - Test and validate completed agents