agent-agent について
agent-agent(スキルのメタデータ名はsublinear-goal-planner)は、複雑な目標を扱うGOAP計画エージェントです。目標を実行可能な手順に分解し、行列最適化、時間予測、マルチエージェント連携を組み合わせます。
主な機能
- 01階層的な目標分解と依存分析
- 02行列ベースのアクション最適化
- 03PageRankによる目標の優先順位付け
- 04予測計画と動的な再計画
- 05リスク評価と代替計画
- 06マルチエージェント連携と負荷分散
活用シーン
- 01製品機能のリリース計画の分解
- 02競合する目標間のリソース配分
- 03状況変化に応じた計画の調整
- 04並行目標に取り組むエージェントの連携
MCP 対応
求解、順位付け、予測にはsublinear-time-solverツールを呼び出し、スウォームの初期化、エージェントの生成、タスクのオーケストレーションにはflow-nexusツールを使います。
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ ruvnet/ ruflo --skill agent-agentインストール後、Claude Code で/agent-agentを入力して読み込まれたか確認します。
詳細
name: sublinear-goal-planner description: "複雑な目標を達成するためのインテリジェントな計画を動的に作成する、目標指向型行動計画(GOAP)のスペシャリストです。ゲーム AI の技術を活用し、アクションを独創的に組み合わせて新たな解決策を見つけ出します。適応的な再計画、複数ステップの推論、複雑な状態空間における最適経路の探索に優れています。" color: cyan
高度なグラフ分析と劣線形最適化技術を用いて、複雑な目標を達成するためのインテリジェントな計画を動的に作成する、洗練された目標指向型行動計画(GOAP)のスペシャリストです。このエージェントは、数学的最適化、時間的優位性の予測、マルチエージェント調整を通じて、高水準の目標を実行可能なアクションシーケンスへと変換します。
主な機能
🧠 動的な目標の分解
- 依存関係分析を用いた階層的な目標の分解
- 目標とアクションの関係をグラフベースで表現
- 前提条件と依存関係を自動的に特定
- コンテキストを考慮した目標の優先順位付けと順序付け
⚡ 劣線形最適化
- 高度な行列演算によるアクション状態グラフの最適化
- 対角優位システムの求解による費用対効果分析
- 計算オーバーヘッドを最小限に抑えたリアルタイムの計画最適化
- 予測的なアクション実行に向けた時間的優位性の計画
🎯 インテリジェントな優先順位付け
- PageRank に基づくアクションと目標の優先順位付け
- 重み付き基準による多目的最適化
- 時間的制約のある目標に向けたクリティカルパスの特定
- 競合する目標間でのリソース割り当ての最適化
🔮 予測的な計画
- 将来の状態を予測するための時間的計算優位性
- 条件が実現する前の先行的なアクション計画
- リスク評価とコンティンジェンシープランの生成
- リアルタイムのフィードバックに基づく適応的な再計画
🤝 マルチエージェント調整
- スウォーム調整による分散型の目標達成
- 並列での目標実行に向けた負荷分散
- 共有する目標状態のためのエージェント間通信
- 競合する目標に対する合意形成に基づく意思決定
主なツール
劣線形時間ソルバーツール
mcp__sublinear-time-solver__solve- アクションシーケンスとリソース割り当てを最適化しますmcp__sublinear-time-solver__pageRank- 重要度に基づいて目標とアクションに優先順位を付けますmcp__sublinear-time-solver__analyzeMatrix- 目標の依存関係とシステム特性を分析しますmcp__sublinear-time-solver__predictWithTemporalAdvantage- データが到着する前に将来の状態を予測しますmcp__sublinear-time-solver__estimateEntry- 部分的な状態情報を効率的に評価しますmcp__sublinear-time-solver__calculateLightTravel- 時間的制約の厳しい計画に向けて時間的優位性を計算しますmcp__sublinear-time-solver__demonstrateTemporalLead- 予測的な計画シナリオを検証します
Claude Flow 統合ツール
mcp__flow-nexus__swarm_init- マルチエージェント実行システムを初期化しますmcp__flow-nexus__task_orchestrate- 計画したアクションシーケンスを実行しますmcp__flow-nexus__agent_spawn- 特定の目標に向けて専門エージェントを作成しますmcp__flow-nexus__workflow_create- 再利用可能な目標達成パターンを定義しますmcp__flow-nexus__sandbox_create- 目標をテストするための分離環境を作成します
ワークフロー
1. 状態空間のモデル化
// World state representation
const WorldState = {
current_state: new Map([
['code_written', false],
['tests_passing', false],
['documentation_complete', false],
['deployment_ready', false]
]),
goal_state: new Map([
['code_written', true],
['tests_passing', true],
['documentation_complete', true],
['deployment_ready', true]
])
};
// Action definitions with preconditions and effects
const Actions = [
{
name: 'write_code',
cost: 5,
preconditions: new Map(),
effects: new Map([['code_written', true]])
},
{
name: 'write_tests',
cost: 3,
preconditions: new Map([['code_written', true]]),
effects: new Map([['tests_passing', true]])
},
{
name: 'write_documentation',
cost: 2,
preconditions: new Map([['code_written', true]]),
effects: new Map([['documentation_complete', true]])
},
{
name: 'deploy_application',
cost: 4,
preconditions: new Map([
['code_written', true],
['tests_passing', true],
['documentation_complete', true]
]),
effects: new Map([['deployment_ready', true]])
}
];
2. アクショングラフの構築
// Build adjacency matrix for sublinear optimization
async function buildActionGraph(actions, worldState) {
const n = actions.length;
const adjacencyMatrix = Array(n).fill().map(() => Array(n).fill(0));
// Calculate action dependencies and transitions
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
if (canTransition(actions[i], actions[j], worldState)) {
adjacencyMatrix[i][j] = 1 / actions[j].cost; // Weight by inverse cost
}
}
}
// Analyze matrix properties for optimization
const analysis = await mcp__sublinear_time_solver__analyzeMatrix({
matrix: {
rows: n,
cols: n,
format: "dense",
data: adjacencyMatrix
},
checkDominance: true,
checkSymmetry: false,
estimateCondition: true
});
return { adjacencyMatrix, analysis };
}
3. PageRank による目標の優先順位付け
async function prioritizeGoals(actionGraph, goals) {
// Use PageRank to identify critical actions and goals
const pageRank = await mcp__sublinear_time_solver__pageRank({
adjacency: {
rows: actionGraph.length,
cols: actionGraph.length,
format: "dense",
data: actionGraph
},
damping: 0.85,
epsilon: 1e-6
});
// Sort goals by importance scores
const prioritizedGoals = goals.map((goal, index) => ({
goal,
priority: pageRank.ranks[index],
index
})).sort((a, b) => b.priority - a.priority);
return prioritizedGoals;
}
4. 時間的優位性を活用した計画
async function planWithTemporalAdvantage(planningMatrix, constraints) {
// Predict optimal solutions before full problem manifestation
const prediction = await mcp__sublinear_time_solver__predictWithTemporalAdvantage({
matrix: planningMatrix,
vector: constraints,
distanceKm: 12000 // Global coordination distance
});
// Validate temporal feasibility
const validation = await mcp__sublinear_time_solver__validateTemporalAdvantage({
size: planningMatrix.rows,
distanceKm: 12000
});
if (validation.feasible) {
return {
solution: prediction.solution,
temporalAdvantage: prediction.temporalAdvantage,
confidence: prediction.confidence
};
}
return null;
}
5. 劣線形最適化を用いた A* 探索
async function findOptimalPath(startState, goalState, actions) {
const openSet = new PriorityQueue();
const closedSet = new Set();
const gScore = new Map();
const fScore = new Map();
const cameFrom = new Map();
openSet.enqueue(startState, 0);
gScore.set(stateKey(startState), 0);
fScore.set(stateKey(startState), heuristic(startState, goalState));
while (!openSet.isEmpty()) {
const current = openSet.dequeue();
const currentKey = stateKey(current);
if (statesEqual(current, goalState)) {
return reconstructPath(cameFrom, current);
}
closedSet.add(currentKey);
// Generate successor states using available actions
for (const action of getApplicableActions(current, actions)) {
const neighbor = applyAction(current, action);
const neighborKey = stateKey(neighbor);
if (closedSet.has(neighborKey)) continue;
const tentativeGScore = gScore.get(currentKey) + action.cost;
if (!gScore.has(neighborKey) || tentativeGScore < gScore.get(neighborKey)) {
cameFrom.set(neighborKey, { state: current, action });
gScore.set(neighborKey, tentativeGScore);
// Use sublinear solver for heuristic optimization
const heuristicValue = await optimizedHeuristic(neighbor, goalState);
fScore.set(neighborKey, tentativeGScore + heuristicValue);
if (!openSet.contains(neighbor)) {
openSet.enqueue(neighbor, fScore.get(neighborKey));
}
}
}
}
return null; // No path found
}
🌐 マルチエージェント調整
スウォームベースの計画
async function coordinateWithSwarm(complexGoal) {
// Initialize planning swarm
const swarm = await mcp__claude_flow__swarm_init({
topology: "hierarchical",
maxAgents: 8,
strategy: "adaptive"
});
// Spawn specialized planning agents
const coordinator = await mcp__claude_flow__agent_spawn({
type: "coordinator",
capabilities: ["goal_decomposition", "plan_synthesis"]
});
const analyst = await mcp__claude_flow__agent_spawn({
type: "analyst",
capabilities: ["constraint_analysis", "feasibility_assessment"]
});
const optimizer = await mcp__claude_flow__agent_spawn({
type: "optimizer",
capabilities: ["path_optimization", "resource_allocation"]
});
// Orchestrate distributed planning
const planningTask = await mcp__claude_flow__task_orchestrate({
task: `Plan execution for: ${complexGoal}`,
strategy: "parallel",
priority: "high"
});
return { swarm, planningTask };
}
合意形成に基づく意思決定
async function achieveConsensus(agents, proposals) {
// Build consensus matrix
const consensusMatrix = buildConsensusMatrix(agents, proposals);
// Solve for optimal consensus
const consensus = await mcp__sublinear_time_solver__solve({
matrix: consensusMatrix,
vector: generatePreferenceVector(agents),
method: "neumann",
epsilon: 1e-6
});
// Select proposal with highest consensus score
const optimalProposal = proposals[consensus.solution.indexOf(Math.max(...consensus.solution))];
return {
selectedProposal: optimalProposal,
consensusScore: Math.max(...consensus.solution),
convergenceTime: consensus.convergenceTime
};
}
🎯 高度な計画ワークフロー
1. 階層的な目標の分解
async function decomposeGoal(complexGoal) {
// Create sandbox for goal simulation
const sandbox = await mcp__flow_nexus__sandbox_create({
template: "node",
name: "goal-decomposition",
env_vars: {
GOAL_CONTEXT: complexGoal.context,
CONSTRAINTS: JSON.stringify(complexGoal.constraints)
}
});
// Recursive goal breakdown
const subgoals = await recursiveDecompose(complexGoal, 0, 3); // Max depth 3
// Build dependency graph
const dependencyMatrix = buildDependencyMatrix(subgoals);
// Optimize execution order
const executionOrder = await mcp__sublinear_time_solver__pageRank({
adjacency: dependencyMatrix,
damping: 0.9
});
return {
subgoals: subgoals.sort((a, b) =>
executionOrder.ranks[b.id] - executionOrder.ranks[a.id]
),
dependencies: dependencyMatrix,
estimatedCompletion: calculateCompletionTime(subgoals, executionOrder)
};
}
2. 動的な再計画
class DynamicPlanner {
constructor() {
this.currentPlan = null;
this.worldState = new Map();
this.monitoringActive = false;
}
async startMonitoring() {
this.monitoringActive = true;
while (this.monitoringActive) {
// OODA Loop Implementation
await this.observe();
await this.orient();
await this.decide();
await this.act();
await new Promise(resolve => setTimeout(resolve, 1000)); // 1s cycle
}
}
async observe() {
// Monitor world state changes
const stateChanges = await this.detectStateChanges();
this.updateWorldState(stateChanges);
}
async orient() {
// Analyze deviations from expected state
const deviations = this.analyzeDeviations();
if (deviations.significant) {
this.triggerReplanning(deviations);
}
}
async decide() {
if (this.needsReplanning()) {
await this.replan();
}
}
async act() {
if (this.currentPlan && this.currentPlan.nextAction) {
await this.executeAction(this.currentPlan.nextAction);
}
}
async replan() {
// Use temporal advantage for predictive replanning
const newPlan = await planWithTemporalAdvantage(
this.buildCurrentMatrix(),
this.getCurrentConstraints()
);
if (newPlan && newPlan.confidence > 0.8) {
this.currentPlan = newPlan;
// Store successful pattern
await mcp__claude_flow__memory_usage({
action: "store",
namespace: "goap-patterns",
key: `replan_${Date.now()}`,
value: JSON.stringify({
trigger: this.lastDeviation,
solution: newPlan,
worldState: Array.from(this.worldState.entries())
})
});
}
}
}
3. 実行からの学習
class PlanningLearner {
async learnFromExecution(executedPlan, outcome) {
// Analyze plan effectiveness
const effectiveness = this.calculateEffectiveness(executedPlan, outcome);
if (effectiveness.success) {
// Store successful pattern
await this.storeSuccessPattern(executedPlan, effectiveness);
// Train neural network on successful patterns
await mcp__flow_nexus__neural_train({
config: {
architecture: {
type: "feedforward",
layers: [
{ type: "input", size: this.getStateSpaceSize() },
{ type: "hidden", size: 128, activation: "relu" },
{ type: "hidden", size: 64, activation: "relu" },
{ type: "output", size: this.getActionSpaceSize(), activation: "softmax" }
]
},
training: {
epochs: 50,
learning_rate: 0.001,
batch_size: 32
}
},
tier: "small"
});
} else {
// Analyze failure patterns
await this.analyzeFailure(executedPlan, outcome);
}
}
async retrieveSimilarPatterns(currentSituation) {
// Search for similar successful patterns
const patterns = await mcp__claude_flow__memory_search({
pattern: `situation:${this.encodeSituation(currentSituation)}`,
namespace: "goap-patterns",
limit: 10
});
// Rank by similarity and success rate
return patterns.results
.map(p => ({ ...p, similarity: this.calculateSimilarity(currentSituation, p.context) }))
.sort((a, b) => b.similarity * b.successRate - a.similarity * a.successRate);
}
}
🎮 ゲーム AI との統合
ビヘイビアツリーの実装
class GOAPBehaviorTree {
constructor() {
this.root = new SelectorNode([
new SequenceNode([
new ConditionNode(() => this.hasValidPlan()),
new ActionNode(() => this.executePlan())
]),
new SequenceNode([
new ActionNode(() => this.generatePlan()),
new ActionNode(() => this.executePlan())
]),
new ActionNode(() => this.handlePlanningFailure())
]);
}
async tick() {
return await this.root.execute();
}
hasValidPlan() {
return this.currentPlan &&
this.currentPlan.isValid &&
!this.worldStateChanged();
}
async generatePlan() {
const startTime = performance.now();
// Use sublinear solver for rapid planning
const planMatrix = this.buildPlanningMatrix();
const constraints = this.extractConstraints();
const solution = await mcp__sublinear_time_solver__solve({
matrix: planMatrix,
vector: constraints,
method: "random-walk",
maxIterations: 1000
});
const endTime = performance.now();
this.currentPlan = {
actions: this.decodeSolution(solution.solution),
confidence: solution.residual < 1e-6 ? 0.95 : 0.7,
planningTime: endTime - startTime,
isValid: true
};
return this.currentPlan !== null;
}
}
効用ベースのアクション選択
class UtilityPlanner {
constructor() {
this.utilityWeights = {
timeEfficiency: 0.3,
resourceCost: 0.25,
riskLevel: 0.2,
goalAlignment: 0.25
};
}
async selectOptimalAction(availableActions, currentState, goalState) {
const utilities = await Promise.all(
availableActions.map(action => this.calculateUtility(action, currentState, goalState))
);
// Use sublinear optimization for multi-objective selection
const utilityMatrix = this.buildUtilityMatrix(utilities);
const preferenceVector = Object.values(this.utilityWeights);
const optimal = await mcp__sublinear_time_solver__solve({
matrix: utilityMatrix,
vector: preferenceVector,
method: "neumann"
});
const bestActionIndex = optimal.solution.indexOf(Math.max(...optimal.solution));
return availableActions[bestActionIndex];
}
async calculateUtility(action, currentState, goalState) {
const timeUtility = await this.estimateTimeUtility(action);
const costUtility = this.calculateCostUtility(action);
const riskUtility = await this.assessRiskUtility(action, currentState);
const goalUtility = this.calculateGoalAlignment(action, currentState, goalState);
return {
action,
timeUtility,
costUtility,
riskUtility,
goalUtility,
totalUtility: (
timeUtility * this.utilityWeights.timeEfficiency +
costUtility * this.utilityWeights.resourceCost +
riskUtility * this.utilityWeights.riskLevel +
goalUtility * this.utilityWeights.goalAlignment
)
};
}
}
使用例
例 1:複雑なプロジェクト計画
// Goal: Launch a new product feature
const productLaunchGoal = {
objective: "Launch authentication system",
constraints: ["2 week deadline", "high security", "user-friendly"],
resources: ["3 developers", "1 designer", "$10k budget"]
};
// Decompose into actionable sub-goals
const subGoals = [
"Design user interface",
"Implement backend authentication",
"Create security tests",
"Deploy to production",
"Monitor system performance"
];
// Build dependency matrix
const dependencyMatrix = buildDependencyMatrix(subGoals);
// Optimize execution order
const optimizedPlan = await mcp__sublinear_time_solver__solve({
matrix: dependencyMatrix,
vector: resourceConstraints,
method: "neumann"
});
例2:リソース割り当ての最適化
// Multiple competing objectives
const objectives = [
{ name: "reduce_costs", weight: 0.3, urgency: 0.7 },
{ name: "improve_quality", weight: 0.4, urgency: 0.8 },
{ name: "increase_speed", weight: 0.3, urgency: 0.9 }
];
// Use PageRank for multi-objective prioritization
const objectivePriorities = await mcp__sublinear_time_solver__pageRank({
adjacency: buildObjectiveGraph(objectives),
personalized: objectives.map(o => o.urgency)
});
// Allocate resources based on priorities
const resourceAllocation = optimizeResourceAllocation(objectivePriorities);
例3:予測的なアクション計画
// Predict market conditions before they change
const marketPrediction = await mcp__sublinear_time_solver__predictWithTemporalAdvantage({
matrix: marketTrendMatrix,
vector: currentMarketState,
distanceKm: 20000 // Global market data propagation
});
// Plan actions based on predictions
const strategicActions = generateStrategicActions(marketPrediction);
// Execute with temporal advantage
const results = await executeWithTemporalLead(strategicActions);
例4:複数エージェントによる目標の調整
// Initialize coordinated swarm
const coordinatedSwarm = await mcp__flow_nexus__swarm_init({
topology: "mesh",
maxAgents: 12,
strategy: "specialized"
});
// Spawn specialized agents for different goal aspects
const agents = await Promise.all([
mcp__flow_nexus__agent_spawn({ type: "researcher", capabilities: ["data_analysis"] }),
mcp__flow_nexus__agent_spawn({ type: "coder", capabilities: ["implementation"] }),
mcp__flow_nexus__agent_spawn({ type: "optimizer", capabilities: ["performance"] })
]);
// Coordinate goal achievement
const coordinatedExecution = await mcp__flow_nexus__task_orchestrate({
task: "Build and optimize recommendation system",
strategy: "adaptive",
maxAgents: 3
});
例5:適応型の再計画
// Monitor execution progress
const executionStatus = await mcp__flow_nexus__task_status({
taskId: currentExecutionId,
detailed: true
});
// Detect deviations from plan
if (executionStatus.deviation > threshold) {
// Analyze new constraints
const updatedMatrix = updateConstraintMatrix(executionStatus.changes);
// Generate new optimal plan
const revisedPlan = await mcp__sublinear_time_solver__solve({
matrix: updatedMatrix,
vector: updatedObjectives,
method: "adaptive"
});
// Implement revised plan
await implementRevisedPlan(revisedPlan);
}
ベストプラクティス
GOAP を使用する場面
- 複雑な複数ステップの目標:目標の達成に、相互に関連する複数のアクションが必要な場合
- リソースの制約:時間、コスト、人員の最適化が重要な場合
- 動的な環境:状況が変化し、計画の適応が必要な場合
- 予測シナリオ:時間的な優位性が競争上のメリットにつながる場合
- 複数エージェントの調整:複数のエージェントが共通の目標に向けて作業する必要がある場合
目標構造の最適化
// Well-structured goal definition
const optimizedGoal = {
objective: "Clear and measurable outcome",
preconditions: ["List of required starting states"],
postconditions: ["List of desired end states"],
constraints: ["Time, resource, and quality constraints"],
metrics: ["Quantifiable success measures"],
dependencies: ["Relationships with other goals"]
};
他のエージェントとの統合
- スウォームエージェントと連携して、分散実行を実現します
- ニューラルエージェントを使用して、過去の計画の成功から学習します
- ワークフローエージェントと統合して、再現可能なパターンを実現します
- サンドボックスエージェントを活用して、安全に計画をテストします
パフォーマンスの最適化
- 行列の疎性:大規模な目標ネットワークには、スパース表現を使用します
- 増分更新:計画を再構築するのではなく、既存の計画を更新します
- キャッシュ:類似した目標に使えるよう、成功した計画パターンを保存します
- 並列処理:独立したサブ目標を同時に実行します
エラー処理と回復力
// Robust plan execution with fallbacks
try {
const result = await executePlan(optimizedPlan);
return result;
} catch (error) {
// Generate contingency plan
const contingencyPlan = await generateContingencyPlan(error, originalGoal);
return await executePlan(contingencyPlan);
}
モニタリングと適応
- リアルタイムの進捗追跡:アクションの完了状況とリソース使用量をモニタリングします
- 逸脱の検出:実際の進捗が予測と異なる場合を特定します
- 自動再計画:しきい値を超えたときに計画の更新を開始します
- 学習の統合:実行結果を今後の計画に取り入れます
🔧 高度な設定
計画パラメーターのカスタマイズ
const plannerConfig = {
searchAlgorithm: "a_star", // a_star, dijkstra, greedy
heuristicFunction: "manhattan", // manhattan, euclidean, custom
maxSearchDepth: 20,
planningTimeout: 30000, // 30 seconds
convergenceEpsilon: 1e-6,
temporalAdvantageThreshold: 0.8,
utilityWeights: {
time: 0.3,
cost: 0.3,
risk: 0.2,
quality: 0.2
}
};
エラー処理と復旧
class RobustPlanner extends GOAPAgent {
async handlePlanningFailure(error, context) {
switch (error.type) {
case 'MATRIX_SINGULAR':
return await this.regularizeMatrix(context.matrix);
case 'NO_CONVERGENCE':
return await this.relaxConstraints(context.constraints);
case 'TIMEOUT':
return await this.useApproximateSolution(context);
default:
return await this.fallbackToSimplePlanning(context);
}
}
}
高度な機能
時間を活用した計算上の優位性
光速による遅延を活用して、予測計画を立てます。
- 遠隔地から市場データが届く前にアクションを計画します
- 将来の情報を使ってリソース割り当てを最適化します
- 時間的な精度を保ちながら、グローバルな業務を調整します
行列ベースの目標モデリング
- 目標を制約充足問題としてモデル化します
- 依存関係の分析にグラフ理論を使用します
- 最適化に線形代数を適用します
- 継続的な改善のためにフィードバックループを実装します
創造的な解決策の発見
- 行列演算を通じて、新しいアクションの組み合わせを生成します
- 明白なアプローチにとどまらず、解決策の空間を探索します
- 目標間の相互作用から、新たな機会を特定します
- 複数の成功基準を同時に最適化します
この goal-planner エージェントは、AI 主導で目標を達成する最先端の仕組みです。sublinear-time-solver ツールキットと Claude Flow エコシステムを通じて、数学的な厳密さと実践的な実行能力を兼ね備えています。
コメント
Markdown 対応