Deep Dive: Create and Publish Orchestrators
What Is a Orchestrator?
Orchestration
└── AgentOrchestrator ("my-orchestrator") ← chooses which agent runs
├── Agent-A ("stabilize") ← leaf agent
├── Agent-B ("accelerate") ← leaf agent
└── Agent-C ("recover") ← leaf agentTwo Types of Orchestrator
Type
When to use
1
Step 1: Understand the Orchestrator Interface
from typing import Dict, List
from amesa_core import AgentController
class MyOrchestrator(AgentController):
def __init__(self):
pass
async def filtered_sensor_space(self, obs_spec) -> List[str]:
# Which sensors does the selection logic need to read?
...
async def compute_action(self, obs_spec: Dict, action) -> List[int]:
# Return [index] where index selects the child agent to run
# 0 → first registered child, 1 → second, etc.
...
async def compute_success_criteria(self, obs_spec: Dict, action) -> bool:
...
async def compute_termination(self, obs_spec: Dict, action) -> bool:
...2
Step 2: Write Your Orchestrator
# process_orchestrator/controller.py
from typing import Dict, List
from amesa_core import AgentController
# Agent index mapping (matches registration order in the orchestration)
SKILL_STARTUP = 0
SKILL_STEADY_STATE = 1
SKILL_RECOVERY = 2
# process_state thresholds
WARMUP_THRESHOLD = 0.2 # below this → still starting up
FAULT_THRESHOLD = 0.05 # below this → fault recovery needed
class ProcessOrchestrator(AgentController):
"""
Rule-based orchestrator for a three-agent process control orchestration.
Chooses startup, steady-state, or recovery based on process_state.
"""
def __init__(self):
pass
async def filtered_sensor_space(self, obs_spec) -> List[str]:
return ["process_state", "temperature", "pressure"]
async def compute_action(self, obs_spec: Dict, action) -> List[int]:
state = obs_spec["process_state"]
if state < FAULT_THRESHOLD:
return [SKILL_RECOVERY]
elif state < WARMUP_THRESHOLD:
return [SKILL_STARTUP]
else:
return [SKILL_STEADY_STATE]
async def compute_success_criteria(self, obs_spec: Dict, action) -> bool:
return obs_spec["process_state"] >= 0.9
async def compute_termination(self, obs_spec: Dict, action) -> bool:
return False3
Step 3: Create the Artifact Directory
amesa orchestrator new \
--name process-orchestrator \
--type controller \
--description "Rule-based orchestrator for three-agent process control orchestration" \
--location ./amesa orchestrator new \
--name process-orchestrator \
--type teacher \
--description "RL-trained orchestrator for three-agent process control orchestration" \
--location ./process-orchestrator/
process_orchestrator/
__init__.py ← empty; required
controller.py ← or teacher.py, depending on type
pyproject.tomlCreating Manually
mkdir -p process-orchestrator/process_orchestrator
touch process-orchestrator/process_orchestrator/__init__.py
touch process-orchestrator/process_orchestrator/controller.py # or teacher.py
touch process-orchestrator/pyproject.tomlNaming Rules
Layer
Convention
Example
4
Step 4: Configure pyproject.toml
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.backends.legacy:build"
[project]
name = "process-orchestrator"
version = "0.1.0"
description = "Rule-based orchestrator for three-agent process control orchestration"
dependencies = [
"amesa-core",
]
[amesa]
type = "orchestrator-controller"
entrypoint = "process_orchestrator.controller:ProcessOrchestrator"[build-system]
requires = ["setuptools"]
build-backend = "setuptools.backends.legacy:build"
[project]
name = "process-orchestrator"
version = "0.1.0"
description = "RL-trained orchestrator for three-agent process control orchestration"
dependencies = [
"amesa-core",
]
[amesa]
type = "orchestrator-teacher"
entrypoint = "process_orchestrator.teacher:ProcessOrchestrator"type Values
Entrypoint Format
Part
Value (controller example)
5
6