Orchestrator
The Orchestrator coordinates agent interactions within an environment. It manages turn-taking, determines which agent acts next, and checks for terminal conditions.
Overview
The Orchestrator is the engine that drives the simulation forward. On each step, it:
- Selects the next agent (round-robin by default)
- Retrieves observations from the environment for that agent
- Asks the agent to act based on those observations
- Records the agent's action in the environment
- Checks whether the simulation should end
Basic Usage
import { Orchestrator, ConversationEnvironment } from "eklesia";
const environment = new ConversationEnvironment(
"A debate between AI agents about climate policy.",
);
const orchestrator = new Orchestrator(environment);The orchestrator is typically used within an Arena, which calls orchestrator.step() in a loop.
Constructor
new Orchestrator<GenericEnvironment>(
environment: GenericEnvironment,
)| Parameter | Type | Description |
|---|---|---|
environment | Environment | The environment the orchestrator operates within |
Properties
| Property | Type | Description |
|---|---|---|
environment | Environment | The environment this orchestrator manages |
currentAgentIndex | number | Tracks which agent acts next (protected, starts at 0) |
Methods
step(agents)
Advances the simulation by one turn. Returns true if the simulation should end (terminal condition met), false otherwise.
const isTerminal = await orchestrator.step(agents);| Parameter | Type | Description |
|---|---|---|
agents | Array<Agent> | The list of agents to cycle through |
Step-by-step flow:
- Select the agent at
currentAgentIndex % agents.length - Call
environment.getObservation(agentName)to get relevant messages - Call
agent.act(observation, environment.description)to generate a response - Call
environment.addMessage(agentName, action)to record the response - Call
environment.isTerminal(endingRound)to check if the simulation should stop - Increment
currentAgentIndex
Turn Order
By default, the orchestrator uses round-robin turn order. Agents take turns in the order they appear in the agents array. After the last agent acts, the cycle begins again from the first agent.
Step 0: Agent[0] acts
Step 1: Agent[1] acts
Step 2: Agent[2] acts
Step 3: Agent[0] acts ← new round
...Creating a Custom Orchestrator
You can extend the base Orchestrator to implement different turn-taking strategies. See the Custom Orchestrator guide for details.
Next Steps
- Arena : The container that runs the orchestrator
- Environment : The context the orchestrator operates within
- Custom Orchestrator : Build your own turn-taking logic