mcpField
A
ai-agent-orchestrator

ai-agent-orchestrator

github.com/dengineproblemエージェントワークフロー69 回インストール
リポジトリ

ai-agent-orchestrator について

マルチエージェントシステムの設計と実装を支援するスキルです。エージェントワークフローを構築する開発者向けに、タスクルーティング、エージェント間通信、サーキットブレーカーや縮退運転などの回復性パターンを扱います。

主な機能

  1. 01階層型エージェントの役割
  2. 02ハブアンドスポークとパイプラインのパターン
  3. 03能力に基づくタスクルーティング
  4. 04エージェント間メッセージ設計
  5. 05サーキットブレーカーと縮退運転
  6. 06ログ・メトリクス・トレースの実践

活用シーン

  1. 01調査・分析エージェントの構成
  2. 02能力に応じたエージェントへのタスク振り分け
  3. 03エージェント障害時のフォールバック設計

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/dengineproblem/agents-monorepo --skill ai-agent-orchestrator

インストール後、Claude Code で/ai-agent-orchestratorを入力して読み込まれたか確認します。

詳細

AI Agent Orchestrator Expert

マルチエージェントシステムの設計と実装に関するエキスパートです。

基本原則

エージェントの階層構造
  • オーケストレーター:タスクを委任するメインコーディネーター
  • 専門エージェント:特定の分野(調査、分析、コード)を担当します
  • ユーティリティエージェント:補助機能(検証、フォーマット)を担当します
  • モニタリング:システムの健全性とエラー処理を監視します

アーキテクチャパターン

ハブアンドスポーク
class OrchestratorAgent:
    def __init__(self):
        self.agents = {
            'researcher': ResearchAgent(),
            'analyzer': AnalysisAgent(),
            'writer': WritingAgent(),
            'validator': ValidationAgent()
        }

    async def orchestrate_task(self, task):
        subtasks = self.decompose_task(task)

        results = []
        for subtask in subtasks:
            agent_type = self.route_task(subtask)
            result = await self.agents[agent_type].execute(subtask)
            results.append(result)

        return self.synthesize_results(results)
パイプラインパターン
class AgentPipeline:
    def __init__(self):
        self.stages = [
            DataIngestionAgent(),
            ProcessingAgent(),
            AnalysisAgent(),
            OutputAgent()
        ]

    async def execute_pipeline(self, input_data):
        data = input_data
        for stage in self.stages:
            try:
                data = await stage.process(data)
            except Exception as e:
                return await self.handle_pipeline_error(stage, e, data)
        return data

タスクのルーティング

class TaskRouter:
    def __init__(self):
        self.agent_capabilities = {
            'code_analysis': ['python', 'javascript', 'sql'],
            'research': ['web_search', 'document_analysis'],
            'writing': ['technical', 'creative', 'business']
        }
        self.agent_load = {}

    def route_task(self, task):
        required_skills = self.extract_skills(task)

        capable_agents = [
            agent_id for agent_id, skills in self.agent_capabilities.items()
            if self.has_required_skills(skills, required_skills)
        ]

        return self.select_least_loaded_agent(capable_agents)

エージェント間通信

@dataclass
class AgentMessage:
    sender_id: str
    receiver_id: str
    message_type: MessageType
    payload: Dict[str, Any]
    correlation_id: str
    timestamp: float
    priority: int = 5

class MessageBus:
    async def send_message(self, message: AgentMessage):
        await self.validate_message(message)
        await self.route_message(message)
        await self.log_message(message)

エラー処理

サーキットブレーカー
class AgentCircuitBreaker:
    def __init__(self, failure_threshold=5, timeout=60):
        self.failure_count = 0
        self.failure_threshold = failure_threshold
        self.state = 'CLOSED'

    async def call_agent(self, agent, task):
        if self.state == 'OPEN':
            if time.time() - self.last_failure_time > self.timeout:
                self.state = 'HALF_OPEN'
            else:
                raise CircuitBreakerOpenError()

        try:
            result = await agent.execute(task)
            if self.state == 'HALF_OPEN':
                self.reset()
            return result
        except Exception as e:
            self.record_failure()
            raise
グレースフルデグラデーション
class ResilientOrchestrator:
    def __init__(self):
        self.agent_priorities = {
            'primary': ['gpt-4', 'claude-3'],
            'fallback': ['gpt-3.5', 'local-model'],
            'emergency': ['rule-based-agent']
        }

    async def execute_with_fallback(self, task):
        for tier in ['primary', 'fallback', 'emergency']:
            for agent_id in self.agent_priorities[tier]:
                try:
                    if await self.is_agent_healthy(agent_id):
                        return await self.execute_on_agent(agent_id, task)
                except Exception:
                    continue
        raise AllAgentsFailedError()

ベストプラクティス

  • correlation ID を使用した包括的なロギングを実装します
  • エージェントのパフォーマンス指標を追跡します
  • 複雑なワークフローには分散トレーシングを使用します
  • エージェント間通信をすべて検証します
  • 可能な場合は、エージェントをステートレスに設計します
  • 疎結合を実現するためにメッセージキューを使用します

コメント