Skip to content

antikythera_agents.launcher ¤

Classes¤

AgentLauncher ¤

AgentLauncher(
    broker_host="127.0.0.1",
    broker_port=1883,
    sys_only=False,
    mqtt_transport="tcp",
    tls=False,
)

Subscribes to the MQTT task bus, claims tasks on behalf of registered agents, and executes them in background threads.

Each launcher instance is assigned a unique ID. When the orchestrator broadcasts a new task assignment, all running launchers compete to claim it; the orchestrator picks one winner and broadcasts an allocation message. Only the winning launcher executes the task; any others that started work cancel themselves on receipt of the ACK.

Functions¤

on_task_ack ¤
on_task_ack(message: TaskCompletionAckMessage) -> None

Handle a task completion acknowledgement from the orchestrator.

If another launcher was accepted for the same task and this launcher is still executing it, the local execution context is cancelled.

on_task_allocation ¤
on_task_allocation(message: TaskAllocationMessage) -> None

Handle a task allocation decision from the orchestrator.

If this launcher was selected as the winner, the claimed task is dispatched to a background thread for execution.

on_task_start ¤
on_task_start(message: TaskAssignmentMessage) -> None

Handle an incoming task assignment broadcast.

If a registered agent can handle the task type, the launcher publishes a claim request so the orchestrator can allocate it.

reload_agents ¤
reload_agents()

Dispose of all current agent instances, reload plugins, and re-initialise agents.

Useful for picking up newly installed agent packages without restarting the process.

start ¤
start()

Subscribe to all MQTT topics and begin accepting tasks.

stop ¤
stop()

Unsubscribe from MQTT topics, wait for in-flight tasks to finish, and dispose of all agent instances.