Decides the order in which session participants take turns.
A turn policy is a small, stateful module that sequences participants. The
ExAgent.Session owns no scheduling logic of its own — it delegates "who acts
next" and "may this participant act now" to the policy, so the same Session can
drive a round-robin chat, an initiative-ordered combat, or a supervisor that
delegates (Phase 4).
Callbacks
init/1— build the policy state from options.optscarries`:participants` (the initial list) plus any policy-specific keys (e.g. `:order` for initiative).next_participant/2— return{:ok, id, new_state}for the next actor,or `{:done, new_state}` when the sequence is exhausted. `context` carries `%{shared_state: _, participants: _}` for policies that need it.can_act?/3— whetherparticipant_idmay act right now (thepolicy tracks the current actor).participant_joined/2/participant_left/2— keep the policy's roster insync as participants come and go.
Built-in implementations
ExAgent.Session.TurnPolicy.RoundRobin— insertion order, cycling forever.ExAgent.Session.TurnPolicy.Initiative— an explicit:order, cycling forever.- (Phase 4)
SupervisorDriven— a coordinator participant directs others.
Summary
Types
@type context() :: %{ shared_state: term(), participants: [ExAgent.Session.Participant.t()] }
@type id() :: term()
@type state() :: term()