Agents
Define autonomous agents with capabilities, roles, and conditional actions.
Keywords
agent- Define an autonomous agentcapabilities- List agent capabilities (optional property)skills- List agent skills (optional property)model- Specify AI model to use (optional property)
agent Keyword
Define autonomous agents that can perform actions based on capabilities and conditions.
Syntax
Capabilities can be unquoted (single word) or quoted (multi-word):
// Unquoted capabilities (single word)
agent AgentName {
fetchOrder
validateItems
processPayment
}
// Quoted capabilities (multi-word)
agent AgentName {
"fetch order"
"validate items"
"process payment"
}
// Mixed syntax (recommended)
agent AgentName {
fetchOrder
"validate order items" // quotes for multi-word
processPayment
"send confirmation email"
}
✨ Edit in StudioWith role inheritance:
agent AgentName: RoleName {
processOrder
"handle complex tasks"
}
✨ Edit in StudioExamples
Basic Agent
agent OrderProcessor {
fetchOrder
validateItems
processPayment
sendConfirmation
}
✨ Edit in StudioAgent with Role Inheritance
role AdminRole {
permission orders {
create,
read,
update,
delete
}
}
agent OrderManager: AdminRole {
listOrders
updateOrderStatus
cancelOrder
notifyCustomer
}
✨ Edit in StudioMulti-Agent System
agent InventoryManager {
checkStockLevels
updateInventory
alertOnLowStock
reorderItems
}
agent NotificationAgent {
sendEmail
sendSms
logNotification
retryOnFailure
}
agent OrderCoordinator {
receiveOrder
validateOrder
"assign to InventoryManager"
"assign to NotificationAgent"
trackCompletion
}
✨ Edit in StudioAgent Properties
capabilities Property
Optional property to list agent capabilities explicitly.
agent DataAnalyst {
capabilities: [
"data_processing",
"statistical_analysis",
"visualization",
"reporting"
]
fetchData
analyzePatterns
generateReports
}
✨ Edit in Studioskills Property
Optional property to define agent skills.
agent DeveloperAgent {
skills: [
"python",
"typescript",
"sql",
"git"
]
writeCode
reviewCode
debugIssues
}
✨ Edit in Studiomodel Property
Optional property to specify which AI model the agent should use.
agent CodeReviewer {
model: "claude-3-sonnet"
analyzeCodeQuality
suggestImprovements
checkBestPractices
}
agent DocumentWriter {
model: "gpt-4"
writeDocumentation
generateExamples
formatMarkdown
}
✨ Edit in StudioAdvanced Patterns
Complex Workflows
agent SmartOrderProcessor {
receiveOrder
# Validation phase
validateOrder
# Payment phase
processPayment
retryPaymentOnFailure
"notify customer on payment failure"
# Fulfillment phase
prepareShipment
updateInventory
shipOrder
# Notification phase
sendConfirmation
sendTrackingInfo
}
✨ Edit in StudioAgent Hierarchies
agent SupervisorAgent {
assignTasksToWorkers
monitorProgress
aggregateResults
interveneOnIssues
}
agent WorkerAgent {
receiveTask
executeTask
reportProgress
requestHelpWhenStuck
}
agent QualityAgent {
reviewWork
validateOutput
approveOrReject
provideFeedback
}
✨ Edit in StudioState-Aware Agents
workflow OrderFlow {
state pending -> processing
state processing -> completed, failed
state failed -> retry, cancelled
}
agent OrderStateMachine {
# Pending state actions
acceptOrder
validateOrder
# Processing state actions
processPayment
updateInventory
# Completion actions
sendConfirmation
archiveOrder
# Error handling
retryOnFailure
notifySupport
}
✨ Edit in StudioBest Practices
Naming Conventions
- Use PascalCase for agent names:
OrderProcessor,DataAnalyst - Use descriptive names that indicate purpose:
EmailNotifier,InventoryManager - Suffix with role type when helpful:
OrderAgent,PaymentAgent
Capability Design
-
Be specific with action phrases
- Good:
validatePaymentCardor"validate payment card" - Avoid:
validate
- Good:
-
Use camelCase for unquoted or descriptive phrases for quoted
- Unquoted:
processCustomerOrder - Quoted:
"process customer order"
- Unquoted:
-
Group related actions together
Agent Organization
# Group agents by domain
# Payment Domain
agent PaymentValidator { ... }
agent PaymentProcessor { ... }
agent RefundManager { ... }
# Inventory Domain
agent StockChecker { ... }
agent InventoryUpdater { ... }
agent ReorderAgent { ... }
# Notification Domain
agent EmailSender { ... }
agent SMSDispatcher { ... }
agent NotificationLogger { ... }
✨ Edit in StudioReal-World Examples
E-Commerce System
enum OrderStatus {
pending
processing
shipped
delivered
}
role CustomerRole {
permission orders {
create,
read
}
}
agent OrderOrchestrator: CustomerRole {
# Order reception
receiveOrder
validateOrderItems
# Payment processing
processPayment
retryPaymentOnDecline
"notify customer on failure"
# Inventory management
reserveInventory
updateStockLevels
# Fulfillment
prepareShipment
updateStatusToShipped
trackDelivery
# Notifications
sendOrderConfirmation
sendShippingNotification
sendDeliveryNotification
}
✨ Edit in StudioContent Management
agent ContentModerator {
model: "claude-3-sonnet"
capabilities: [
"text_analysis",
"sentiment_detection",
"policy_compliance"
]
receiveContent
analyzeContent
approveCompliantContent
rejectPolicyViolations
flagUncertainContent
escalateToHuman
}
✨ Edit in StudioData Pipeline
agent DataIngestion {
fetchDataFromSources
validateSchema
transformFormat
handleErrors
retryOnConnectionFailure
}
agent DataProcessor {
cleanData
enrichData
validateQuality
aggregateResults
}
agent DataPublisher {
writeToDatabase
createBackup
notifySubscribers
logCompletion
}
✨ Edit in StudioRelated Keywords
role- Agents can inherit from rolesworkflow- Agents can follow workflowsvisitor- Visitors interact with agents
Next Steps
- Explore Workflows for agent coordination
- See Execution Plans for task orchestration
- Learn about Roles & Permissions
