Flock is a framework for building, orchestrating, and running AI agent systems. It provides a declarative approach to agent design, focusing on inputs and outputs rather than prompts. This specification defines the core architecture components of the Flock framework.
The central orchestrator that manages agents, tools, and execution flow.
Responsibilities:
- Managing agent registration and retrieval
- Orchestrating workflow execution
- Providing execution context
- Supporting local and distributed execution modes (Temporal)
- Initializing and managing logging
Key Attributes:
agents
: Collection of registered agentsregistry
: Central registry for agents and toolscontext
: Global execution contextmodel
: Default LLM model identifierenable_temporal
: Flag for distributed execution
The core agent class that defines a single AI agent's capabilities.
Responsibilities:
- Defining agent inputs and outputs
- Managing agent lifecycle
- Providing access to tools
- Supporting serialization and deserialization
- Integrating with modules for extensibility
Key Attributes:
name
: Unique identifierdescription
: Human-readable agent descriptionmodel
: LLM model identifierinput
: Input field definitionsoutput
: Output field definitionstools
: Available tools for the agentevaluator
: Strategy for evaluationmodules
: Attached modules for extensibilityhandoff_router
: Optional router for multi-agent workflows
Extension system for agents to modify behavior through lifecycle hooks.
Responsibilities:
- Hooking into agent lifecycle events
- Modifying inputs or outputs
- Adding capabilities to agents
- Maintaining module-specific state
Lifecycle Hooks:
initialize
: Called when agent startspre_evaluate
: Called before evaluationpost_evaluate
: Called after evaluationterminate
: Called when agent finisheson_error
: Called when errors occur
Strategy for evaluating agent requests and generating outputs.
Responsibilities:
- Processing agent inputs
- Formulating appropriate prompts
- Managing model interactions
- Processing model outputs
- Handling tool usage
Mechanism for directing workflow between agents.
Responsibilities:
- Determining the next agent in a workflow
- Managing input/output mapping between agents
- Supporting workflow branching logic
Key Concepts:
HandOffRequest
: Definition of the next agent and input mapping
Shared execution context for agents and modules.
Responsibilities:
- Storing global state across agents
- Providing access to agent definitions
- Supporting serialization for distributed execution
-
Declarative over Imperative:
- Focus on what agents do, not how they do it
- Define inputs and outputs clearly
- Minimize prompt engineering
-
Modular Extension:
- Module system for adding functionality
- Clear lifecycle hooks
- Separation of concerns
-
Resilient Execution:
- Support for local and distributed execution
- Error handling at each level
- Observability through logging and tracing
-
Serialization Support:
- All components can be serialized
- Support for saving and loading agent definitions
- State preservation across execution environments
-
Tool Integration:
- First-class support for tool usage
- Flexible tool registration
- Dynamic tool discovery
- User creates a Flock instance
- User adds agents to the Flock
- User registers tools if needed
- User calls
run()
with a starting agent and input - Flock initializes context and resolves the starting agent
- Agent initializes and resolves modules
- Agent evaluates input using its evaluator
- If a router is defined, Flock determines the next agent
- Process repeats until no next agent is specified
- Final result is returned