Initial commit
This commit is contained in:
56
skills/ai-sdk-agents/SKILL.md
Normal file
56
skills/ai-sdk-agents/SKILL.md
Normal file
@@ -0,0 +1,56 @@
|
||||
---
|
||||
name: orchestrating-multi-agent-systems
|
||||
description: |
|
||||
This skill enables Claude to orchestrate multi-agent systems using the AI SDK v5. It allows Claude to set up agent handoffs, intelligent routing, and coordinated workflows across different AI providers like OpenAI, Anthropic, and Google. Use this skill when the user asks to create multi-agent systems, needs help with agent coordination, task routing, or wants to build complex workflows involving specialized agents. It is triggered by phrases like "multi-agent system", "agent orchestration", "agent handoff", "intelligent routing", or "coordinate agents".
|
||||
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
|
||||
version: 1.0.0
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This skill empowers Claude to create and manage sophisticated multi-agent systems. It leverages the AI SDK v5 to facilitate agent collaboration, task delegation, and intelligent routing, enabling the creation of complex AI-powered workflows.
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Project Initialization**: The skill sets up a basic multi-agent project structure, including agent files and orchestration configurations.
|
||||
2. **Agent Creation**: It facilitates the creation of specialized agents with custom system prompts, tool definitions, and handoff rules.
|
||||
3. **Orchestration Configuration**: It configures the agent orchestration workflow, defining how agents interact and pass tasks to each other.
|
||||
|
||||
## When to Use This Skill
|
||||
|
||||
This skill activates when you need to:
|
||||
- Create a new multi-agent system from scratch.
|
||||
- Orchestrate existing agents to perform a complex task.
|
||||
- Define handoff rules between agents.
|
||||
- Route tasks intelligently to the most appropriate agent.
|
||||
- Coordinate a workflow involving multiple LLMs.
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Building a Code Generation Pipeline
|
||||
|
||||
User request: "Set up a multi-agent system for code generation with an architect, coder, tester, reviewer, and documenter."
|
||||
|
||||
The skill will:
|
||||
1. Initialize a multi-agent project with the specified agents.
|
||||
2. Create individual agent files (architect.ts, coder.ts, etc.) with relevant system prompts and tool access.
|
||||
3. Configure an orchestration workflow to pass tasks between the agents in the order: Architect -> Coder -> Tester -> Reviewer -> Documenter.
|
||||
|
||||
### Example 2: Intelligent Routing for Customer Support
|
||||
|
||||
User request: "Create a multi-agent system for customer support that routes inquiries to the appropriate agent based on the topic."
|
||||
|
||||
The skill will:
|
||||
1. Initialize a multi-agent project with a coordinator agent and specialized support agents (e.g., billing, technical support, sales).
|
||||
2. Configure the coordinator agent with routing rules based on topic classification.
|
||||
3. Implement handoff mechanisms for agents to transfer inquiries if needed.
|
||||
|
||||
## Best Practices
|
||||
|
||||
- **Agent Specialization**: Design agents with specific expertise and limited scope for better performance.
|
||||
- **Clear Handoff Rules**: Define clear and unambiguous handoff rules to avoid confusion and circular dependencies.
|
||||
- **Comprehensive Testing**: Thoroughly test the multi-agent system to ensure proper coordination and task completion.
|
||||
|
||||
## Integration
|
||||
|
||||
This skill integrates seamlessly with other Claude Code plugins, allowing you to combine multi-agent orchestration with other functionalities like code generation, data analysis, and external API integrations. It leverages the AI SDK v5 for robust and flexible agent management.
|
||||
7
skills/ai-sdk-agents/assets/README.md
Normal file
7
skills/ai-sdk-agents/assets/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Assets
|
||||
|
||||
Bundled resources for ai-sdk-agents skill
|
||||
|
||||
- [ ] agent_template.ts: Template for creating new agents with pre-defined structure and interfaces.
|
||||
- [ ] example_coordinator.ts: Example implementation of a coordinator agent with routing logic.
|
||||
- [ ] example_workflow.json: Example workflow definition for a multi-agent system.
|
||||
110
skills/ai-sdk-agents/assets/agent_template.ts
Normal file
110
skills/ai-sdk-agents/assets/agent_template.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Agent Template
|
||||
*
|
||||
* This file provides a template for creating new agents within the ai-sdk-agents plugin.
|
||||
* Use this as a starting point to define the behavior and capabilities of your agent.
|
||||
*
|
||||
* Instructions:
|
||||
* 1. Replace the placeholder values with your agent's specific details.
|
||||
* 2. Implement the `execute` method to define the agent's core logic.
|
||||
* 3. Define the agent's tools and capabilities using the `AgentCapabilities` interface.
|
||||
* 4. Ensure your agent properly handles errors and exceptions.
|
||||
* 5. Consider adding logging and monitoring for improved observability.
|
||||
*/
|
||||
|
||||
import { Agent, AgentCapabilities, AgentContext } from '@ai-sdk/core'; // Replace with actual import path if needed
|
||||
|
||||
// Define the specific capabilities of this agent. Adjust as needed.
|
||||
interface MyAgentCapabilities extends AgentCapabilities {
|
||||
[key: string]: any; // Allows for flexible capability definitions. Consider more specific types.
|
||||
// Example:
|
||||
// summarizeText: (text: string) => Promise<string>;
|
||||
// translateText: (text: string, targetLanguage: string) => Promise<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* MyAgent Class
|
||||
*
|
||||
* A template for creating new AI agents.
|
||||
*/
|
||||
export class MyAgent implements Agent<MyAgentCapabilities> {
|
||||
// Agent Name (Required)
|
||||
name: string = "MyAgentName";
|
||||
|
||||
// Agent Description (Required)
|
||||
description: string = "A brief description of what this agent does.";
|
||||
|
||||
// (Optional) Specific instructions or persona for the agent
|
||||
instructions?: string = "You are a helpful assistant...";
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param capabilities - The capabilities of the agent (tools, functions, etc.).
|
||||
*/
|
||||
constructor(public capabilities: MyAgentCapabilities) {
|
||||
// Initialization logic can go here.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute Method
|
||||
*
|
||||
* This is the core logic of the agent. It receives the user's input and the agent's context.
|
||||
*
|
||||
* @param input - The user's input.
|
||||
* @param context - The agent's context (access to other agents, data, etc.).
|
||||
* @returns A promise that resolves to the agent's response.
|
||||
*/
|
||||
async execute(input: string, context: AgentContext): Promise<string> {
|
||||
try {
|
||||
// Implement your agent's logic here.
|
||||
// Example:
|
||||
// const summary = await this.capabilities.summarizeText(input);
|
||||
// return summary;
|
||||
|
||||
// Placeholder response:
|
||||
return `Agent ${this.name} received input: ${input}. This is a placeholder response.`;
|
||||
|
||||
} catch (error: any) {
|
||||
console.error(`Error in agent ${this.name}:`, error);
|
||||
return `Agent ${this.name} encountered an error: ${error.message || error}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Example Usage (for testing/demonstration purposes)
|
||||
*/
|
||||
async function main() {
|
||||
// Example capabilities (replace with actual implementations)
|
||||
const myCapabilities: MyAgentCapabilities = {
|
||||
// Example:
|
||||
// summarizeText: async (text: string) => `Summarized: ${text.substring(0, 50)}...`,
|
||||
// translateText: async (text: string, targetLanguage: string) => `Translated to ${targetLanguage}: ${text}`,
|
||||
};
|
||||
|
||||
const myAgent = new MyAgent(myCapabilities);
|
||||
|
||||
const context: AgentContext = {
|
||||
getAgent: async (name: string) => {
|
||||
console.warn(`Attempted to get agent ${name}, but no other agents are defined in this example.`);
|
||||
return undefined;
|
||||
},
|
||||
getPluginData: async (key: string) => {
|
||||
console.warn(`Attempted to get plugin data for key ${key}, but no plugin data is defined in this example.`);
|
||||
return undefined;
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
const userInput = "This is a test input for the agent.";
|
||||
const response = await myAgent.execute(userInput, context);
|
||||
|
||||
console.log("Agent Response:", response);
|
||||
}
|
||||
|
||||
// Run the example (optional - remove in production)
|
||||
// main();
|
||||
100
skills/ai-sdk-agents/assets/example_coordinator.ts
Normal file
100
skills/ai-sdk-agents/assets/example_coordinator.ts
Normal file
@@ -0,0 +1,100 @@
|
||||
// example_coordinator.ts
|
||||
|
||||
/**
|
||||
* This file provides an example implementation of a coordinator agent using the AI SDK.
|
||||
* Coordinator agents are responsible for routing requests to specialized agents and
|
||||
* managing the overall workflow of a multi-agent system.
|
||||
*
|
||||
* This example demonstrates basic routing logic. You can customize this to fit your specific use case.
|
||||
*/
|
||||
|
||||
import { Agent, AgentContext, AgentOutput, AgentConfig } from "@ai-sdk/core"; // Replace with actual import path if needed
|
||||
|
||||
// Define the interface for the agent's input. Customize this based on what your agents need.
|
||||
interface CoordinatorInput {
|
||||
query: string;
|
||||
// Add other relevant input parameters here
|
||||
}
|
||||
|
||||
// Define the interface for the agent's output. Customize this based on your needs.
|
||||
interface CoordinatorOutput extends AgentOutput {
|
||||
response: string;
|
||||
routedToAgent?: string; // Optional: Indicate which agent handled the request
|
||||
}
|
||||
|
||||
// Define the configuration options for the coordinator agent.
|
||||
interface CoordinatorConfig extends AgentConfig {
|
||||
// Add any configuration options specific to the coordinator agent here, such as:
|
||||
// - List of available agents and their descriptions
|
||||
// - Routing rules
|
||||
// - Error handling strategies
|
||||
agent1: Agent; // Define agent1
|
||||
agent2: Agent; // Define agent2
|
||||
}
|
||||
|
||||
// Implement the coordinator agent class.
|
||||
class CoordinatorAgent implements Agent<CoordinatorInput, CoordinatorOutput, CoordinatorConfig> {
|
||||
config: CoordinatorConfig;
|
||||
|
||||
constructor(config: CoordinatorConfig) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
async execute(input: CoordinatorInput, context: AgentContext): Promise<CoordinatorOutput> {
|
||||
const { query } = input;
|
||||
|
||||
// Implement your routing logic here. This is a simplified example.
|
||||
// Consider using more sophisticated methods like:
|
||||
// - Natural language understanding to determine the intent of the query
|
||||
// - A knowledge base to match the query to the appropriate agent
|
||||
// - A machine learning model to predict the best agent to handle the request
|
||||
|
||||
let routedToAgent: Agent | null = null;
|
||||
let agentName: string | undefined = undefined;
|
||||
|
||||
if (query.toLowerCase().includes("agent1")) {
|
||||
routedToAgent = this.config.agent1;
|
||||
agentName = "Agent1";
|
||||
} else if (query.toLowerCase().includes("agent2")) {
|
||||
routedToAgent = this.config.agent2;
|
||||
agentName = "Agent2";
|
||||
} else {
|
||||
// Default routing logic - you should customize this
|
||||
routedToAgent = this.config.agent1; // Example: Default to agent1
|
||||
agentName = "Agent1";
|
||||
}
|
||||
|
||||
|
||||
if (!routedToAgent) {
|
||||
return {
|
||||
response: "Error: No suitable agent found to handle the request.",
|
||||
};
|
||||
}
|
||||
|
||||
// Execute the selected agent.
|
||||
const agentOutput: any = await routedToAgent.execute({ query: query }, context); // Replace 'any' with the actual expected output type from the agent.
|
||||
|
||||
// Process the output from the selected agent and format it as the coordinator's output.
|
||||
return {
|
||||
response: `[${agentName ?? "Unknown Agent"}] ${agentOutput.response}`, // Customize formatting as needed
|
||||
routedToAgent: agentName,
|
||||
// Include any other relevant information in the output
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export { CoordinatorAgent, CoordinatorInput, CoordinatorOutput, CoordinatorConfig };
|
||||
|
||||
// Example Usage (in another file):
|
||||
// import { CoordinatorAgent, CoordinatorConfig } from './example_coordinator';
|
||||
// import { Agent1, Agent2 } from './your_agents'; // Assuming you have Agent1 and Agent2 defined
|
||||
|
||||
// const config: CoordinatorConfig = {
|
||||
// agent1: new Agent1(),
|
||||
// agent2: new Agent2(),
|
||||
// // ... other configuration options
|
||||
// };
|
||||
|
||||
// const coordinator = new CoordinatorAgent(config);
|
||||
// const result = await coordinator.execute({ query: "Route this to agent1" }, context);
|
||||
// console.log(result.response);
|
||||
143
skills/ai-sdk-agents/assets/example_workflow.json
Normal file
143
skills/ai-sdk-agents/assets/example_workflow.json
Normal file
@@ -0,0 +1,143 @@
|
||||
{
|
||||
"_comment": "Example workflow definition for a multi-agent system powered by AI SDK v5.",
|
||||
"workflow_name": "Customer Service and Issue Resolution",
|
||||
"description": "A workflow that handles customer inquiries, escalates issues to specialists, and provides final resolutions.",
|
||||
"agents": [
|
||||
{
|
||||
"agent_id": "customer_service_agent",
|
||||
"name": "Customer Service Agent",
|
||||
"description": "First point of contact for all customer inquiries. Triages requests and routes them to appropriate specialists.",
|
||||
"model_provider": "anthropic",
|
||||
"model_name": "claude-3-opus-20240229",
|
||||
"prompt": "You are a friendly and helpful customer service agent. Your primary task is to understand the customer's issue and route it to the correct specialist. If you can resolve the issue directly, do so. Otherwise, summarize the problem clearly and pass it on. Be polite and professional at all times. If the customer is angry, use calming language.",
|
||||
"initial_state": true,
|
||||
"routing_rules": [
|
||||
{
|
||||
"condition": "The customer's issue is related to billing or payment.",
|
||||
"next_agent": "billing_specialist",
|
||||
"action": "Summarize the billing issue and forward it to the Billing Specialist."
|
||||
},
|
||||
{
|
||||
"condition": "The customer's issue is technical and requires expert assistance.",
|
||||
"next_agent": "technical_support_agent",
|
||||
"action": "Summarize the technical issue and forward it to the Technical Support Agent."
|
||||
},
|
||||
{
|
||||
"condition": "The customer is requesting information about products or services.",
|
||||
"next_agent": "sales_agent",
|
||||
"action": "Forward the inquiry to the Sales Agent."
|
||||
},
|
||||
{
|
||||
"condition": "The customer's issue can be resolved with readily available information.",
|
||||
"next_agent": null,
|
||||
"action": "Answer the customer's question directly and end the interaction."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "billing_specialist",
|
||||
"name": "Billing Specialist",
|
||||
"description": "Handles all billing and payment-related inquiries. Resolves billing disputes and provides payment options.",
|
||||
"model_provider": "openai",
|
||||
"model_name": "gpt-4-turbo-preview",
|
||||
"prompt": "You are a billing specialist. Your primary task is to resolve billing issues for customers. Clearly explain billing policies and provide payment options. If you cannot resolve the issue, escalate to a billing manager.",
|
||||
"routing_rules": [
|
||||
{
|
||||
"condition": "The billing issue is complex and requires managerial approval.",
|
||||
"next_agent": "billing_manager",
|
||||
"action": "Summarize the issue and forward it to the Billing Manager."
|
||||
},
|
||||
{
|
||||
"condition": "The billing issue can be resolved.",
|
||||
"next_agent": null,
|
||||
"action": "Resolve the billing issue and notify the customer."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "technical_support_agent",
|
||||
"name": "Technical Support Agent",
|
||||
"description": "Provides technical assistance to customers. Diagnoses and resolves technical issues.",
|
||||
"model_provider": "google",
|
||||
"model_name": "gemini-1.5-pro",
|
||||
"prompt": "You are a technical support agent. Your primary task is to diagnose and resolve technical issues reported by customers. Provide clear and concise instructions. If the issue requires a software update, guide the customer through the process.",
|
||||
"routing_rules": [
|
||||
{
|
||||
"condition": "The technical issue requires a software update.",
|
||||
"next_agent": null,
|
||||
"action": "Guide the customer through the software update process and verify the resolution."
|
||||
},
|
||||
{
|
||||
"condition": "The technical issue is beyond your expertise.",
|
||||
"next_agent": "escalation_team",
|
||||
"action": "Escalate the issue to the escalation team with a detailed description."
|
||||
},
|
||||
{
|
||||
"condition": "The technical issue is resolved.",
|
||||
"next_agent": null,
|
||||
"action": "Confirm the resolution with the customer and close the ticket."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "sales_agent",
|
||||
"name": "Sales Agent",
|
||||
"description": "Provides information about products and services and assists with sales inquiries.",
|
||||
"model_provider": "anthropic",
|
||||
"model_name": "claude-3-opus-20240229",
|
||||
"prompt": "You are a sales agent. Your primary task is to answer questions about our products and services and assist customers with their sales inquiries. Highlight key features and benefits. Offer promotions where available.",
|
||||
"routing_rules": [
|
||||
{
|
||||
"condition": "The customer is ready to make a purchase.",
|
||||
"next_agent": null,
|
||||
"action": "Guide the customer through the purchase process."
|
||||
},
|
||||
{
|
||||
"condition": "The customer has specific product questions.",
|
||||
"next_agent": null,
|
||||
"action": "Answer the customer's questions and provide relevant information."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "billing_manager",
|
||||
"name": "Billing Manager",
|
||||
"description": "Handles escalated billing issues that require managerial approval.",
|
||||
"model_provider": "openai",
|
||||
"model_name": "gpt-4-turbo-preview",
|
||||
"prompt": "You are a billing manager. Your primary task is to review and resolve escalated billing issues. Make decisions on exceptions and adjustments. Ensure compliance with billing policies.",
|
||||
"routing_rules": [
|
||||
{
|
||||
"condition": "The issue requires further investigation.",
|
||||
"next_agent": null,
|
||||
"action": "Investigate the issue and make a final decision."
|
||||
},
|
||||
{
|
||||
"condition": "The issue can be resolved with an exception.",
|
||||
"next_agent": null,
|
||||
"action": "Approve the exception and resolve the billing issue."
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"agent_id": "escalation_team",
|
||||
"name": "Escalation Team",
|
||||
"description": "Handles complex technical issues that require specialized expertise.",
|
||||
"model_provider": "google",
|
||||
"model_name": "gemini-1.5-pro",
|
||||
"prompt": "You are part of the escalation team. Your primary task is to resolve complex technical issues that have been escalated. Collaborate with other experts and conduct thorough investigations.",
|
||||
"routing_rules": [
|
||||
{
|
||||
"condition": "The issue requires a code fix.",
|
||||
"next_agent": null,
|
||||
"action": "Develop and deploy a code fix to resolve the issue."
|
||||
},
|
||||
{
|
||||
"condition": "The issue requires hardware replacement.",
|
||||
"next_agent": null,
|
||||
"action": "Coordinate hardware replacement with the customer and resolve the issue."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
7
skills/ai-sdk-agents/references/README.md
Normal file
7
skills/ai-sdk-agents/references/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# References
|
||||
|
||||
Bundled resources for ai-sdk-agents skill
|
||||
|
||||
- [ ] ai_sdk_v5_documentation.md: Comprehensive documentation for the AI SDK v5, including API references and usage examples.
|
||||
- [ ] multi_agent_best_practices.md: Best practices for designing and implementing multi-agent systems, including agent handoff strategies and routing algorithms.
|
||||
- [ ] error_handling_guide.md: Guide on handling errors and exceptions in multi-agent systems.
|
||||
7
skills/ai-sdk-agents/scripts/README.md
Normal file
7
skills/ai-sdk-agents/scripts/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Scripts
|
||||
|
||||
Bundled resources for ai-sdk-agents skill
|
||||
|
||||
- [ ] agent_setup.sh: Automates the creation of agent files and configuration based on user input.
|
||||
- [ ] dependency_installer.sh: Installs necessary npm packages for the agents.
|
||||
- [ ] env_setup.sh: Creates and populates .env file with API keys based on user input.
|
||||
Reference in New Issue
Block a user