The Factory design pattern is implemented in Flock to simplify agent creation with sensible defaults. This specification defines the requirements and behavior of the agent factory system.
Provide a simplified interface for creating pre-configured agents without requiring manual setup of all components.
- Create agents with sensible defaults
- Configure common modules automatically
- Set up evaluators with appropriate configuration
- Simplify the agent creation process
Parameters:
name
: Required unique agent identifierdescription
: Optional human-readable descriptionmodel
: Optional LLM model identifier (defaults to configured default)input
: Required input field definitionsoutput
: Required output field definitionstools
: Optional list of callable toolsuse_cache
: Whether to cache evaluation results (default: True)enable_rich_tables
: Whether to render rich tables in output (default: False)output_theme
: Visual theme for rendered outputwait_for_input
: Whether to pause after execution (default: False)temperature
: Model temperature setting (default: 0.0)max_tokens
: Maximum generated tokens (default: 4096)alert_latency_threshold_ms
: Threshold for latency alerts (default: 30000)no_output
: Whether to suppress output (default: False)print_context
: Whether to print context (default: False)
Return Value:
- A fully configured
FlockAgent
instance
Default Configuration:
-
Creates a
DeclarativeEvaluator
with:- Specified model or default
- Configured cache settings
- Specified max tokens and temperature
-
Creates an
OutputModule
with:- Table rendering settings
- Theme configuration
- Wait-for-input behavior
-
Creates a
MetricsModule
with:- Latency threshold alerts
-
Convention over Configuration:
- Reasonable defaults for most parameters
- Only essential parameters required
-
Complete Configuration:
- Agents created are fully functional
- All required components initialized
-
Flexibility:
- All defaults can be overridden
- Additional configuration possible after creation
-
Extension:
- Factory pattern allows future specialized factory methods
- Custom agent templates possible
- The factory uses the standard
FlockAgent
class - Modules are attached via the agent's
add_module
method - The agent is ready to use immediately after creation
- The agent is not automatically added to a Flock instance