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
agent AgentName {
capability_verb action_phrase
capability_verb action_phrase when condition
capability_verb action_phrase if condition
}
✨ Edit in StudioOr with role inheritance:
agent AgentName: RoleName {
capability_verb action_phrase
}
✨ Edit in StudioCapability Verbs
Agents use modal verbs to express different levels of capability:
| Verb | Meaning | Usage |
|---|---|---|
can | Agent is able to perform | Standard capability |
must | Agent is required to perform | Mandatory action |
should | Agent ought to perform | Recommended action |
may | Agent is permitted to perform | Optional permission |
will | Agent intends to perform | Future commitment |
shall | Agent formally will perform | Formal requirement |
cannot | Agent is not able to perform | Explicit prohibition |
See Capability Verbs for detailed documentation.
Conditional Clauses
| Clause | Meaning | Example |
|---|---|---|
when <condition> | Temporal/state condition | when order_exists |
if <condition> | Logical condition | if payment_valid |
unless <condition> | Negative condition | unless cancelled |
Examples
Basic Agent
agent OrderProcessor {
can fetch order
can validate items
can process payment
can send confirmation
}
✨ Edit in StudioAgent with Conditions
agent PaymentProcessor {
can fetch payment_info when user_authenticated
can validate card if card_provided
can charge amount if amount_valid
can send receipt
cannot refund when order_shipped
}
✨ Edit in StudioAgent with Role Inheritance
role AdminRole {
permission orders {
create,
read,
update,
delete
}
}
agent OrderManager: AdminRole {
can list all orders
can update order status
can cancel order if not_shipped
must notify customer when status_changed
}
✨ Edit in StudioMulti-Agent System
agent InventoryManager {
can check stock levels
can update inventory when sale_made
must alert when low_stock
can reorder items if below_threshold
}
agent NotificationAgent {
can send email
can send sms if urgent
can log notification
must retry when failed
}
agent OrderCoordinator {
can receive order
must validate order
can assign to InventoryManager
can assign to NotificationAgent
must track completion
}
✨ Edit in StudioAgent Properties
capabilities Property
Optional property to list agent capabilities explicitly.
agent DataAnalyst {
capabilities: [
"data_processing",
"statistical_analysis",
"visualization",
"reporting"
]
can fetch data when requested
can analyze patterns
can generate reports
}
✨ Edit in Studioskills Property
Optional property to define agent skills.
agent DeveloperAgent {
skills: [
"python",
"typescript",
"sql",
"git"
]
can write code
can review code
can debug issues
}
✨ Edit in Studiomodel Property
Optional property to specify which AI model the agent should use.
agent CodeReviewer {
model: "claude-3-sonnet"
can analyze code quality
can suggest improvements
can check best practices
}
agent DocumentWriter {
model: "gpt-4"
can write documentation
can generate examples
can format markdown
}
✨ Edit in StudioAdvanced Patterns
Conditional Workflows
agent SmartOrderProcessor {
can receive order
# Validation phase
must validate order
cannot proceed if invalid
# Payment phase
can process payment when validated
must retry payment if declined
should notify customer when payment_failed
# Fulfillment phase
can prepare shipment when payment_complete
must update inventory
can ship order when ready
# Notification phase
must send confirmation
should send tracking when shipped
may send promotional_email
}
✨ Edit in StudioAgent Hierarchies
agent SupervisorAgent {
can assign tasks to workers
can monitor progress
must aggregate results
can intervene when issues_detected
}
agent WorkerAgent {
can receive task
must execute task
can report progress
should request help when stuck
}
agent QualityAgent {
can review work
must validate output
can approve or reject
should provide feedback
}
✨ Edit in StudioState-Aware Agents
workflow OrderFlow {
state pending -> processing
state processing -> completed, failed
state failed -> retry, cancelled
}
agent OrderStateMachine {
# Pending state actions
can accept order when pending
must validate order when pending
# Processing state actions
can process payment when processing
must update inventory when processing
# Completion actions
must send confirmation when completed
can archive order when completed
# Error handling
should retry when failed
can notify support if max_retries_exceeded
}
✨ 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:
can validate payment card - Avoid:
can validate
- Good:
-
Use appropriate verbs for the action type
mustfor critical operationscanfor standard capabilitiesshouldfor best practicescannotfor explicit restrictions
-
Add conditions for clarity
when <state>for state-dependent actionsif <condition>for logical conditions
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
can receive order
must validate order items
cannot proceed if items_unavailable
# Payment processing
can process payment when validated
must retry payment if declined
should notify customer when payment_failed
# Inventory management
must reserve inventory when payment_complete
can update stock levels
# Fulfillment
can prepare shipment when ready
must update status to shipped
can track delivery
# Notifications
must send order confirmation
should send shipping notification
may send delivery notification
}
✨ Edit in StudioContent Management
agent ContentModerator {
model: "claude-3-sonnet"
capabilities: [
"text_analysis",
"sentiment_detection",
"policy_compliance"
]
can receive content when submitted
must analyze content
can approve content if compliant
must reject content if violates_policy
should flag content if uncertain
can escalate to human when complex
}
✨ Edit in StudioData Pipeline
agent DataIngestion {
can fetch data from sources
must validate schema
can transform format
must handle errors
should retry when connection_failed
}
agent DataProcessor {
can clean data
can enrich data
must validate quality
can aggregate results
}
agent DataPublisher {
can write to database when processed
must create backup
can notify subscribers
should log completion
}
✨ Edit in StudioRelated Keywords
role- Agents can inherit from rolesworkflow- Agents can follow workflowsvisitor- Visitors interact with agents- Capability Verbs - Modal verbs for capabilities
Next Steps
- Learn about Capability Verbs
- Explore Workflows for agent coordination
- See Execution Plans for task orchestration