Overview
The Secretary Agent pattern implements a human-in-the-loop workflow system where an AI secretary manages tasks, clarifies requirements, dispatches work to execution agents, and escalates key decisions to humans.What You’ll Learn
- Building secretary agents for workflow management
- Registering and managing execution agents
- Automatic task clarification and dispatch
- Human decision escalation patterns
- LLM integration for intelligent coordination
Prerequisites
- Rust 1.75 or higher
- OpenAI API key (for LLM integration)
- Understanding of async channels
Architecture
Source Code
Running the Example
Expected Output
Secretary Workflow Phases
let idea = DefaultInput::Idea {
content: "Build a new feature".to_string(),
priority: Some(Priority::High),
metadata: None,
};
Dispatch Strategies
- CapabilityFirst
- LoadBalanced
- PriorityBased
- RoundRobin
Match tasks to agents based on capabilities:Best for: Task-agent matching by skills
Agent Configuration
Execution Agent Setup
Secretary Builder Options
Input Types
- Idea
- Clarification
- Decision
- Feedback
Submit new ideas or tasks:
Output Types
Message
Message
General messages from secretary:
Acknowledgment
Acknowledgment
Task receipt confirmation:
Question
Question
Clarifying question:
DecisionRequired
DecisionRequired
Escalated decision:
Report
Report
Status or completion report:
Error
Error
Error message:
Common Use Cases
Project Management
Coordinate development tasks across teams
Customer Support
Triage and route support tickets
Content Pipeline
Manage content creation workflows
DevOps Automation
Coordinate deployment and operations
Advanced Features
Custom Behaviors
Implement your own secretary behavior:State Persistence
Persist secretary state:Troubleshooting
No Available Agents
No Available Agents
Problem: All agents busy or unavailableSolution: Set agent availability or add more agents:
Decision Not Escalated
Decision Not Escalated
Problem: Expected human decision but auto-handledSolution: Lower decision threshold:
Channel Disconnected
Channel Disconnected
Problem: Communication channel closedSolution: Check channel buffer size:
Next Steps
Workflow Orchestration
Build complex orchestration workflows
Multi-Agent
Coordinate multiple agent types
Secretary Guide
Deep dive into secretary pattern
HITL Patterns
Human-in-the-loop best practices