ai-agents 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,121 @@
1
+ # ISP Customer Support Demo
2
+
3
+ This example demonstrates a multi-agent customer support system for an Internet Service Provider (ISP). It showcases how specialized agents can work together to handle various customer requests through intelligent routing and handoffs.
4
+
5
+ ## Architecture
6
+
7
+ The system uses a **hub-and-spoke pattern** with a triage agent that routes customers to appropriate specialists:
8
+
9
+ ### Agents
10
+
11
+ 1. **Triage Agent** - Entry point that greets customers and routes them to specialists
12
+ 2. **Sales Agent** - Handles new customer acquisition, upgrades, plan changes, and billing questions
13
+ 3. **Support Agent** - Provides technical support, troubleshooting, and account information lookups
14
+
15
+ ### Tools
16
+
17
+ Each agent has access to specialized tools:
18
+
19
+ - **CRM Lookup** - Query customer account information by ID (Support Agent)
20
+ - **Create Lead** - Generate sales leads with customer information (Sales Agent)
21
+ - **Create Checkout** - Generate secure payment links for purchases (Sales Agent)
22
+ - **Search Docs** - Find troubleshooting steps in the knowledge base (Support Agent)
23
+ - **Escalate to Human** - Transfer complex issues to human agents (Support Agent)
24
+
25
+ ## Workflow Examples
26
+
27
+ ### Account Information + Technical Issue
28
+ ```
29
+ User: "My account shows active but internet isn't working"
30
+ Triage Agent → Support Agent
31
+ Support Agent:
32
+ 1. Asks for account ID and looks up account info
33
+ 2. Provides technical troubleshooting steps
34
+ 3. Handles complete conversation without handoffs
35
+ ```
36
+
37
+ ### Sales Inquiry
38
+ ```
39
+ User: "I want to upgrade my plan"
40
+ Triage Agent → Sales Agent
41
+ Sales Agent: Creates lead and checkout link
42
+ ```
43
+
44
+ ### Technical Support Only
45
+ ```
46
+ User: "My internet is slow"
47
+ Triage Agent → Support Agent
48
+ Support Agent: Provides troubleshooting steps from docs
49
+ ```
50
+
51
+ ## Key Features
52
+
53
+ - **Intelligent Routing**: Triage agent analyzes customer requests and routes to appropriate specialists
54
+ - **Unified Support**: Support agent handles both technical issues and account lookups in one conversation
55
+ - **Task-Focused Design**: Each agent has clear, focused responsibilities to avoid handoff loops
56
+ - **Tool Integration**: Agents have access to all tools needed for their responsibilities
57
+ - **Conversation Continuity**: Full conversation history is maintained across agent handoffs
58
+ - **Flexible Architecture**: Easy to add new agents or modify routing logic
59
+
60
+ ## Design Principles
61
+
62
+ This example demonstrates **task-focused agent design** to avoid handoff loops:
63
+
64
+ - **Support Agent** can handle both account lookups AND technical support
65
+ - **Sales Agent** focuses on sales, upgrades, and billing
66
+ - **Clear boundaries** prevent agents from bouncing requests back and forth
67
+ - **Comprehensive tooling** ensures agents can complete customer requests
68
+
69
+ ## Data
70
+
71
+ The example includes sample data for:
72
+ - Customer accounts with service details
73
+ - Knowledge base articles for troubleshooting
74
+ - Service plans and pricing information
75
+
76
+ ## Usage
77
+
78
+ Run the interactive demo:
79
+
80
+ ```bash
81
+ ruby examples/isp-support/interactive.rb
82
+ ```
83
+
84
+ Try different types of requests:
85
+ - "I need info on my account" (account ID: CUST001, CUST002, or CUST003)
86
+ - "My account is active but internet isn't working"
87
+ - "I want to upgrade my plan"
88
+ - "How much does fiber cost?"
89
+
90
+ The system will demonstrate intelligent routing and show how agents handle complex requests without unnecessary handoffs.
91
+
92
+ ## File Structure
93
+
94
+ ```
95
+ examples/isp-support/
96
+ ├── README.md # This documentation
97
+ ├── interactive.rb # Interactive CLI demo
98
+ ├── agents_factory.rb # Agent creation and configuration
99
+ ├── tools/
100
+ │ ├── crm_lookup_tool.rb # Customer data retrieval
101
+ │ ├── create_lead_tool.rb # Sales lead generation
102
+ │ ├── create_checkout_tool.rb # Payment link generation
103
+ │ ├── search_docs_tool.rb # Knowledge base search
104
+ │ └── escalate_to_human_tool.rb # Human handoff
105
+ └── data/
106
+ ├── customers.json # Dummy customer database
107
+ ├── plans.json # Available service plans
108
+ └── docs.json # Troubleshooting knowledge base
109
+ ```
110
+
111
+ ## Learning Objectives
112
+
113
+ This example teaches you how to:
114
+
115
+ 1. **Design Multi-Agent Systems**: Structure agents with clear responsibilities and communication patterns
116
+ 2. **Avoid Handoff Loops**: Create task-focused agents that can handle complete customer requests
117
+ 3. **Implement Context Sharing**: Pass information between agents while maintaining thread safety
118
+ 4. **Create Domain-Specific Tools**: Build tools that integrate with external systems and business logic
119
+ 5. **Handle Complex Workflows**: Route requests efficiently without unnecessary agent bouncing
120
+
121
+ This ISP support system demonstrates effective multi-agent architecture using the Ruby Agents SDK.
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../lib/agents"
4
+ require_relative "tools/crm_lookup_tool"
5
+ require_relative "tools/create_lead_tool"
6
+ require_relative "tools/create_checkout_tool"
7
+ require_relative "tools/search_docs_tool"
8
+ require_relative "tools/escalate_to_human_tool"
9
+
10
+ module ISPSupport
11
+ # Factory for creating all ISP support agents with proper handoff relationships.
12
+ # This solves the circular dependency problem where agents need to reference each other.
13
+ class AgentsFactory
14
+ def self.create_agents
15
+ new.create_agents
16
+ end
17
+
18
+ def create_agents
19
+ # Step 1: Create all agents
20
+ triage = create_triage_agent
21
+ sales = create_sales_agent
22
+ support = create_support_agent
23
+
24
+ # Step 2: Wire up handoff relationships using register_handoffs
25
+ # Triage can handoff to specialists
26
+ triage.register_handoffs(sales, support)
27
+
28
+ # Specialists can hand back to triage if needed
29
+ sales.register_handoffs(triage)
30
+ support.register_handoffs(triage)
31
+
32
+ # Return the configured agents
33
+ {
34
+ triage: triage,
35
+ sales: sales,
36
+ support: support
37
+ }
38
+ end
39
+
40
+ private
41
+
42
+ def create_triage_agent
43
+ Agents::Agent.new(
44
+ name: "Triage Agent",
45
+ instructions: triage_instructions,
46
+ model: "gpt-4.1-mini",
47
+ tools: []
48
+ )
49
+ end
50
+
51
+
52
+ def create_sales_agent
53
+ Agents::Agent.new(
54
+ name: "Sales Agent",
55
+ instructions: sales_instructions,
56
+ model: "gpt-4.1-mini",
57
+ tools: [ISPSupport::CreateLeadTool.new, ISPSupport::CreateCheckoutTool.new]
58
+ )
59
+ end
60
+
61
+ def create_support_agent
62
+ Agents::Agent.new(
63
+ name: "Support Agent",
64
+ instructions: support_instructions,
65
+ model: "gpt-4.1-mini",
66
+ tools: [
67
+ ISPSupport::CrmLookupTool.new,
68
+ ISPSupport::SearchDocsTool.new,
69
+ ISPSupport::EscalateToHumanTool.new
70
+ ]
71
+ )
72
+ end
73
+
74
+ def triage_instructions
75
+ <<~INSTRUCTIONS
76
+ You are the Triage Agent for an ISP customer support system. Your role is to greet customers#{" "}
77
+ and route them to the appropriate specialist agent based on their needs.
78
+
79
+ **Available specialist agents:**
80
+ - **Sales Agent**: New service, upgrades, plan changes, purchasing, billing questions
81
+ - **Support Agent**: Technical issues, troubleshooting, outages, account lookups, service problems
82
+
83
+ **Routing guidelines:**
84
+ - Want to buy/upgrade/change plans or billing questions → Sales Agent
85
+ - Technical problems, outages, account info, or service issues → Support Agent
86
+ - If unclear, ask one clarifying question before routing
87
+
88
+ Keep responses brief and professional. Use handoff tools to transfer to specialists.
89
+ INSTRUCTIONS
90
+ end
91
+
92
+
93
+ def sales_instructions
94
+ <<~INSTRUCTIONS
95
+ You are the Sales Agent for an ISP. You handle new customer acquisition, service upgrades,
96
+ and plan changes.
97
+
98
+ **Your tools:**
99
+ - `create_lead`: Create sales leads with customer information
100
+ - `create_checkout`: Generate secure checkout links for purchases
101
+ - Handoff tools: Route back to triage when needed
102
+
103
+ **When to hand off:**
104
+ - Need account verification or billing info → Triage Agent for re-routing
105
+ - Technical questions → Triage Agent for re-routing
106
+ - Non-sales requests → Triage Agent
107
+
108
+ **Instructions:**
109
+ - Be enthusiastic but not pushy
110
+ - Gather required info: name, email, desired plan for leads
111
+ - For existing customers wanting upgrades, ask them to verify account first
112
+ - Create checkout links for confirmed purchases
113
+ - Always explain next steps after creating leads or checkout links
114
+ INSTRUCTIONS
115
+ end
116
+
117
+ def support_instructions
118
+ <<~INSTRUCTIONS
119
+ You are the Support Agent for an ISP. You handle technical support, troubleshooting,
120
+ and account information for customers.
121
+
122
+ **Your tools:**
123
+ - `crm_lookup`: Look up customer account details by account ID
124
+ - `search_docs`: Find troubleshooting steps in knowledge base
125
+ - `escalate_to_human`: Transfer complex issues to human agents
126
+ - Handoff tools: Route back to triage when needed
127
+
128
+ **When to hand off:**
129
+ - Customer wants to buy/upgrade plans → Triage Agent to route to Sales
130
+ - Non-support requests (new purchases) → Triage Agent
131
+
132
+ **Instructions:**
133
+ - For account questions: Always ask for account ID and use crm_lookup
134
+ - For technical issues: Start with basic troubleshooting from docs search
135
+ - You can handle both account lookups AND technical support in the same conversation
136
+ - Be patient and provide step-by-step guidance
137
+ - If customer gets frustrated or issue persists, escalate to human
138
+ - Present account information clearly and protect sensitive data
139
+ INSTRUCTIONS
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,133 @@
1
+ {
2
+ "CUST001": {
3
+ "id": "CUST001",
4
+ "name": "John Smith",
5
+ "email": "john.smith@email.com",
6
+ "phone": "+1-555-0123",
7
+ "address": "123 Main St, Anytown, ST 12345",
8
+ "account_status": "active",
9
+ "plan": {
10
+ "name": "Premium Fiber",
11
+ "speed_down": "1000 Mbps",
12
+ "speed_up": "500 Mbps",
13
+ "price": 79.99,
14
+ "data_limit": "unlimited"
15
+ },
16
+ "billing": {
17
+ "next_bill_date": "2025-07-15",
18
+ "last_payment": "2025-06-15",
19
+ "payment_method": "Auto-pay (Credit Card)",
20
+ "balance": 0.0
21
+ },
22
+ "service_history": [
23
+ {
24
+ "date": "2025-01-15",
25
+ "action": "Upgraded to Premium Fiber",
26
+ "agent": "Sales"
27
+ },
28
+ {
29
+ "date": "2025-03-22",
30
+ "action": "Support ticket: Intermittent connection",
31
+ "agent": "Support",
32
+ "status": "resolved"
33
+ }
34
+ ]
35
+ },
36
+ "CUST002": {
37
+ "id": "CUST002",
38
+ "name": "Sarah Johnson",
39
+ "email": "sarah.j@email.com",
40
+ "phone": "+1-555-0456",
41
+ "address": "456 Oak Ave, Springfield, ST 67890",
42
+ "account_status": "active",
43
+ "plan": {
44
+ "name": "Basic Cable",
45
+ "speed_down": "100 Mbps",
46
+ "speed_up": "10 Mbps",
47
+ "price": 39.99,
48
+ "data_limit": "1TB"
49
+ },
50
+ "billing": {
51
+ "next_bill_date": "2025-07-20",
52
+ "last_payment": "2025-06-20",
53
+ "payment_method": "Monthly Invoice",
54
+ "balance": 39.99
55
+ },
56
+ "service_history": [
57
+ {
58
+ "date": "2024-08-10",
59
+ "action": "New customer signup",
60
+ "agent": "Sales"
61
+ }
62
+ ]
63
+ },
64
+ "CUST003": {
65
+ "id": "CUST003",
66
+ "name": "Mike Rodriguez",
67
+ "email": "m.rodriguez@company.com",
68
+ "phone": "+1-555-0789",
69
+ "address": "789 Business Blvd, Metro City, ST 13579",
70
+ "account_status": "active",
71
+ "plan": {
72
+ "name": "Business Pro",
73
+ "speed_down": "500 Mbps",
74
+ "speed_up": "500 Mbps",
75
+ "price": 129.99,
76
+ "data_limit": "unlimited",
77
+ "sla": "99.9% uptime guarantee"
78
+ },
79
+ "billing": {
80
+ "next_bill_date": "2025-07-01",
81
+ "last_payment": "2025-06-01",
82
+ "payment_method": "Corporate Account",
83
+ "balance": 0.0
84
+ },
85
+ "service_history": [
86
+ {
87
+ "date": "2024-12-01",
88
+ "action": "Business account setup",
89
+ "agent": "Sales"
90
+ },
91
+ {
92
+ "date": "2025-05-15",
93
+ "action": "Static IP configuration",
94
+ "agent": "Support",
95
+ "status": "completed"
96
+ }
97
+ ]
98
+ },
99
+ "CUST004": {
100
+ "id": "CUST004",
101
+ "name": "Lisa Chen",
102
+ "email": "lisa.chen@email.com",
103
+ "phone": "+1-555-0321",
104
+ "address": "321 Pine St, Riverside, ST 24680",
105
+ "account_status": "suspended",
106
+ "plan": {
107
+ "name": "Standard Internet",
108
+ "speed_down": "200 Mbps",
109
+ "speed_up": "20 Mbps",
110
+ "price": 59.99,
111
+ "data_limit": "unlimited"
112
+ },
113
+ "billing": {
114
+ "next_bill_date": "2025-07-10",
115
+ "last_payment": "2025-05-10",
116
+ "payment_method": "Credit Card",
117
+ "balance": 119.98,
118
+ "past_due": true
119
+ },
120
+ "service_history": [
121
+ {
122
+ "date": "2025-06-10",
123
+ "action": "Service suspended - payment overdue",
124
+ "agent": "Billing"
125
+ },
126
+ {
127
+ "date": "2025-04-18",
128
+ "action": "Payment failed notification sent",
129
+ "agent": "Billing"
130
+ }
131
+ ]
132
+ }
133
+ }
@@ -0,0 +1,133 @@
1
+ {
2
+ "troubleshooting": [
3
+ {
4
+ "id": "internet-slow",
5
+ "title": "Internet Connection is Slow",
6
+ "category": "connectivity",
7
+ "keywords": ["slow", "speed", "performance", "bandwidth"],
8
+ "steps": [
9
+ "Check if multiple devices are using the internet simultaneously",
10
+ "Run a speed test at speedtest.net to measure current speeds",
11
+ "Restart your modem by unplugging for 30 seconds, then plug back in",
12
+ "Restart your router by unplugging for 30 seconds, then plug back in",
13
+ "Check for background downloads or streaming on connected devices",
14
+ "Move closer to your router if using WiFi",
15
+ "Try connecting directly to modem with ethernet cable",
16
+ "If speeds are still below plan specifications, contact support"
17
+ ],
18
+ "expected_resolution_time": "15 minutes"
19
+ },
20
+ {
21
+ "id": "no-internet",
22
+ "title": "No Internet Connection",
23
+ "category": "connectivity",
24
+ "keywords": ["no internet", "down", "offline", "disconnected", "outage"],
25
+ "steps": [
26
+ "Check if modem power light is solid green (not blinking)",
27
+ "Check if router power light is solid (color varies by model)",
28
+ "Look for service outage notifications at status.isp.com",
29
+ "Unplug modem power cord for 30 seconds, then plug back in",
30
+ "Wait 2-3 minutes for modem to fully restart",
31
+ "Unplug router power cord for 30 seconds, then plug back in",
32
+ "Wait 2-3 minutes for router to fully restart",
33
+ "Check ethernet cable connections are secure",
34
+ "Try connecting device directly to modem with ethernet",
35
+ "If still no connection, check for local outages or contact support"
36
+ ],
37
+ "expected_resolution_time": "10 minutes"
38
+ },
39
+ {
40
+ "id": "wifi-not-working",
41
+ "title": "WiFi Not Working",
42
+ "category": "wifi",
43
+ "keywords": ["wifi", "wireless", "password", "network", "connection"],
44
+ "steps": [
45
+ "Check if WiFi is enabled on your device",
46
+ "Look for your network name in available networks list",
47
+ "Verify you're using the correct WiFi password (check router label)",
48
+ "Move closer to the router to ensure strong signal",
49
+ "Restart your device's WiFi by turning off and on",
50
+ "Forget and reconnect to the WiFi network",
51
+ "Restart your router by unplugging for 30 seconds",
52
+ "Check if ethernet connection works (isolates WiFi vs internet issue)",
53
+ "Try connecting a different device to verify WiFi functionality"
54
+ ],
55
+ "expected_resolution_time": "10 minutes"
56
+ },
57
+ {
58
+ "id": "intermittent-connection",
59
+ "title": "Intermittent Connection Issues",
60
+ "category": "connectivity",
61
+ "keywords": [
62
+ "intermittent",
63
+ "drops",
64
+ "disconnects",
65
+ "unstable",
66
+ "cutting out"
67
+ ],
68
+ "steps": [
69
+ "Note the frequency and timing of disconnections",
70
+ "Check all cable connections for loose fittings",
71
+ "Look for damaged coaxial or ethernet cables",
72
+ "Check if the issue affects all devices or just one",
73
+ "Monitor modem lights during disconnections",
74
+ "Check for interference from other electronics",
75
+ "Update network drivers on affected devices",
76
+ "Power cycle both modem and router",
77
+ "Document exact symptoms and contact support if persists"
78
+ ],
79
+ "expected_resolution_time": "20 minutes"
80
+ },
81
+ {
82
+ "id": "email-setup",
83
+ "title": "Email Setup and Configuration",
84
+ "category": "email",
85
+ "keywords": ["email", "setup", "configuration", "smtp", "imap", "pop"],
86
+ "steps": [
87
+ "Use these settings for email configuration:",
88
+ "Incoming Mail Server (IMAP): mail.isp.com, Port 993, SSL enabled",
89
+ "Outgoing Mail Server (SMTP): smtp.isp.com, Port 587, TLS enabled",
90
+ "Username: your full email address",
91
+ "Password: your email password",
92
+ "For mobile devices, enable 'Use SSL' for both incoming and outgoing",
93
+ "For Outlook, choose 'More settings' and verify port numbers",
94
+ "Test sending and receiving after setup"
95
+ ],
96
+ "expected_resolution_time": "15 minutes"
97
+ },
98
+ {
99
+ "id": "tv-no-signal",
100
+ "title": "TV Shows No Signal",
101
+ "category": "tv",
102
+ "keywords": ["tv", "signal", "cable", "channels", "black screen"],
103
+ "steps": [
104
+ "Check that TV is on correct input (Cable/HDMI)",
105
+ "Ensure cable box is powered on",
106
+ "Check all coaxial cable connections are tight",
107
+ "Unplug cable box for 30 seconds, then plug back in",
108
+ "Wait 3-5 minutes for cable box to fully restart",
109
+ "Press 'Guide' button to verify signal reception",
110
+ "Try changing channels to test multiple frequencies",
111
+ "Check for service outages in your area",
112
+ "Verify account is current and not suspended"
113
+ ],
114
+ "expected_resolution_time": "10 minutes"
115
+ }
116
+ ],
117
+ "billing": [
118
+ {
119
+ "id": "payment-methods",
120
+ "title": "Available Payment Methods",
121
+ "category": "billing",
122
+ "keywords": ["payment", "billing", "autopay", "credit card"],
123
+ "content": "We accept: Credit/Debit Cards (Visa, MasterCard, American Express), Bank Transfer/ACH, Online Banking, Phone payments, Mail-in checks. AutoPay available with 5% discount."
124
+ },
125
+ {
126
+ "id": "billing-cycle",
127
+ "title": "Understanding Your Billing Cycle",
128
+ "category": "billing",
129
+ "keywords": ["billing cycle", "bill date", "due date"],
130
+ "content": "Bills are generated monthly on your billing date. Payment is due 15 days after bill date. Late fees apply after 30 days. Service may be suspended after 45 days past due."
131
+ }
132
+ ]
133
+ }
@@ -0,0 +1,86 @@
1
+ {
2
+ "residential": [
3
+ {
4
+ "id": "basic-cable",
5
+ "name": "Basic Cable",
6
+ "speed_down": "100 Mbps",
7
+ "speed_up": "10 Mbps",
8
+ "price": 39.99,
9
+ "data_limit": "1TB",
10
+ "features": ["Cable TV included", "Basic support"],
11
+ "available": true
12
+ },
13
+ {
14
+ "id": "standard-internet",
15
+ "name": "Standard Internet",
16
+ "speed_down": "200 Mbps",
17
+ "speed_up": "20 Mbps",
18
+ "price": 59.99,
19
+ "data_limit": "unlimited",
20
+ "features": ["No data caps", "24/7 support"],
21
+ "available": true
22
+ },
23
+ {
24
+ "id": "premium-fiber",
25
+ "name": "Premium Fiber",
26
+ "speed_down": "1000 Mbps",
27
+ "speed_up": "500 Mbps",
28
+ "price": 79.99,
29
+ "data_limit": "unlimited",
30
+ "features": ["Fiber optic", "Priority support", "Static IP option"],
31
+ "available": true
32
+ },
33
+ {
34
+ "id": "ultra-fiber",
35
+ "name": "Ultra Fiber",
36
+ "speed_down": "2000 Mbps",
37
+ "speed_up": "1000 Mbps",
38
+ "price": 99.99,
39
+ "data_limit": "unlimited",
40
+ "features": ["Ultra-fast fiber", "Premium support", "Free installation"],
41
+ "available": true
42
+ }
43
+ ],
44
+ "business": [
45
+ {
46
+ "id": "business-starter",
47
+ "name": "Business Starter",
48
+ "speed_down": "200 Mbps",
49
+ "speed_up": "50 Mbps",
50
+ "price": 89.99,
51
+ "data_limit": "unlimited",
52
+ "features": ["Business support", "Static IP", "99.5% SLA"],
53
+ "available": true
54
+ },
55
+ {
56
+ "id": "business-pro",
57
+ "name": "Business Pro",
58
+ "speed_down": "500 Mbps",
59
+ "speed_up": "500 Mbps",
60
+ "price": 129.99,
61
+ "data_limit": "unlimited",
62
+ "features": [
63
+ "Symmetric speeds",
64
+ "Priority support",
65
+ "99.9% SLA",
66
+ "Dedicated account manager"
67
+ ],
68
+ "available": true
69
+ },
70
+ {
71
+ "id": "enterprise",
72
+ "name": "Enterprise",
73
+ "speed_down": "1000 Mbps",
74
+ "speed_up": "1000 Mbps",
75
+ "price": 199.99,
76
+ "data_limit": "unlimited",
77
+ "features": [
78
+ "Enterprise-grade",
79
+ "24/7 premium support",
80
+ "99.99% SLA",
81
+ "Custom solutions"
82
+ ],
83
+ "available": true
84
+ }
85
+ ]
86
+ }