LLM Skills
~/catalog/software architecture//SKILL

Ai agent orchestration patterns

/SKILL

Patterns for building and orchestrating AI agents effectively.

// agent content

AI Agent Orchestration Patterns Patterns for building and orchestrating AI agents effectively. ## When to Use - Building multi-agent systems - Designing agent architectures - Implementing agent communication patterns - Debugging agent workflows - Optimizing agent performance and costs ## Core Architecture Patterns ### Single Agent with Tools Use when: Task is well-defined, tools are sufficient `` User Request → Agent → [Tool Selection] → Tool Execution → Response ` **Implementation**: `typescript const agent = { systemPrompt: "You are a helpful assistant with access to tools.", tools: [searchTool, calculatorTool, fileTool], maxIterations: 10, }; async function run(input: string) { let context = { messages: [{ role: 'user', content: input }] }; while (!context.done && context.iterations < agent.maxIterations) { const response = await llm.chat(context.messages, agent.tools); if (response.toolCalls) { for (const call of response.toolCalls) { const result = await executeTool(call); context.messages.push({ role: 'tool', content: result }); } } else { context.done = true; return response.content; } context.iterations++; } } ` ### Supervisor Pattern **Use when**: Complex tasks requiring delegation to specialists ` User Request → Supervisor Agent → [Routing Decision] ↓ ┌──────────────────────────────────────┐ ↓ ↓ ↓ ↓ Researcher Coder Writer Reviewer ↓ ↓ ↓ ↓ └──────────────────────────────────────┘ ↓ Supervisor Synthesis ↓ Response ` **Key decisions**: - Supervisor chooses which agent(s) to invoke - Can be parallel (all at once) or sequential (one at a time) - Supervisor synthesizes results ### Pipeline Pattern **Use when**: Task has clear sequential stages ` Input → Stage 1 → Stage 2 → Stage 3 → Output (Plan) (Execute) (Review) ` **Example - Code Generation Pipeline**: `typescript const pipeline = [ { name: 'planner', prompt: 'Create implementation plan' }, { name: 'coder', prompt: 'Implement the plan' }, { name: 'reviewer', prompt: 'Review for bugs and improvements' }, { name: 'tester', prompt: 'Write tests for the implementation' }, ]; async function runPipeline(input: string) { let context = input; for (const stage of pipeline) { context = await runAgent(stage.name, stage.prompt, context); } return context; } ` ### Parallel Execution Pattern **Use when**: Independent subtasks can be processed simultaneously `typescript async function parallelAgents(tasks: Task[]) { const results = await Promise.all( tasks.map(task => runAgent(task.agent, task.input)) ); return synthesize(results); } ` ### Reflection Pattern **Use when**: Quality is critical, self-improvement needed ` Initial Response → Critique Agent → Refined Response → [Iterate?] ` **Implementation**: `typescript async function reflectiveAgent(input: string, maxReflections = 3) { let response = await generateResponse(input); for (let i = 0; i < maxReflections; i++) { const critique = await critiqueResponse(response); if (critique.satisfactory) break; response = await improveResponse(response, critique.feedback); } return response; } ` ## Communication Patterns ### Message Passing Agents communicate through structured messages: `typescript interface AgentMessage { from: string; to: string; type: 'request' | 'response' | 'update'; content: unknown; metadata: { timestamp: number; traceId: string; }; } ` ### Shared State Agents share a common context: `typescript interface SharedContext { goal: string; currentState: unknown; history: Message[]; artifacts: Map<string, unknown>; } // Each agent reads/writes to shared context async function agentStep(agent: Agent, context: SharedContext) { const result = await agent.run(context); context.history.push({ agent: agent.name, result }); context.currentState = result.newState; } ` ### Event-Driven Agents react to events: `typescript const eventBus = new EventEmitter(); // Agent subscribes to relevant events eventBus.on('code:generated', async (code) => { const review = await reviewerAgent.review(code); eventBus.emit('code:reviewed', review); }); eventBus.on('code:reviewed', async (review) => { if (!review.approved) { eventBus.emit('code:needsRevision', review.feedback); } }); `` ## Cost Optimization ### Model Routing Use appropriate models for each task:

// original public source
strataga/claude-setup
/skills/ai-agent-orchestration-patterns/SKILL.md
License: License not specified. Review the repository before reusing it.
Independent project, not affiliated with Anthropic. This agent remains the property of its original author.
// install this agent
Paste this command in your terminal at the root of your project:
mkdir -p .claude/commands && curl -o ".claude/commands/SKILL.md" "https://raw.githubusercontent.com/strataga/claude-setup/master/skills/ai-agent-orchestration-patterns/SKILL.md"
Then in Claude Code, type /SKILL to activate it.
open_in_newOpen original source
// save
Save available after sign in.
loginSign in to save
// information
Creatorstrataga
Format.md
AccessFree
// similar

Agents Software architecture

View allarrow_forward