PPOActor
PPOActor(context: RuntimeContext[PPOExperimentConfiguration], actor_model: PPOModel, learner_model: ThreadSafeModel, rollout_buffer: RolloutBuffer, rollout_handshake: RolloutHandshake, episode_observer: Callable[[dict[str, float], int, bool], None] | None = None, replay_observation_cache: ReplayObservationCache | None = None, env_factory: Callable[[], OakEmuMultiEnv] | None = None) -> NonePPO actor that collects rollouts using the stochastic policy.
Unlike the DQN Trainer, this does not use epsilon-greedy exploration or a replay buffer. Instead, it collects complete rollouts (observations, actions, log probabilities, values, rewards, dones) into a RolloutBuffer. When the buffer is full, it signals the learner.
Note: Unlike Trainer/Tester, this does not inherit from Agent. PPO requires (action, log_prob, value) per step — not just greedy actions, so action selection is performed directly via PPOModel.get_action_bundle() in _select_actions, never through Agent's batched-inference path (_queue_for_inference / _flush_pending_inference). Composes EpisodeMetrics and EnvLifecycle directly instead -- the two pieces of Agent it actually needs.
Initialize the PPO actor.
Parameters:
context(RuntimeContext[PPOExperimentConfiguration]) – The shared runtime context.actor_model(PPOModel) – The local PPO model for action selection.learner_model(ThreadSafeModel) – The learner model container (for weight sync).rollout_buffer(RolloutBuffer) – The rollout buffer to fill.rollout_handshake(RolloutHandshake) – Synchronizes rollout hand-off with the learner.episode_observer(Callable[[dict[str, float], int, bool], None] | None) – Optional observer invoked with each completed episode's data.replay_observation_cache(ReplayObservationCache | None) – Optional shared replay observation cache.env_factory(Callable[[], OakEmuMultiEnv] | None) – Optional multi-environment factory; defaults to_default_env_factory.
Properties
replay_observation_cache
replay_observation_cache: ReplayObservationCache | NoneGet the replay observation cache shared with the learner-side BC sampler, if enabled.
restart_pool
restart_pool: RestartPool | NoneGet the restart pool, or None when restarts are not configured.
result_queue_depth
result_queue_depth: intGet the current depth of the underlying environment result queue.
steps
steps: intGet the total number of environment steps.
total_episodes
total_episodes: intGet the total number of episodes completed.
total_losses
total_losses: intGet the total number of losses.
total_truncated
total_truncated: intGet the total number of truncated episodes.
total_wins
total_wins: intGet the total number of wins.
trajectory_runtime
trajectory_runtime: TrajectoryEpisodeCoordinatorGet the trajectory coordinator shared with the learner-side BC sampler.
Methods
restore_runtime_state
restore_runtime_state(state: ActorRuntimeState) -> NoneRestore checkpointed actor counters and trajectory runtime state.
Not named restore_state (unlike the old Agent.restore_state): the actor restores a strictly wider payload than the base episode-totals state, so this is a distinct method rather than an incompatibly-typed override.
Parameters:
state(ActorRuntimeState) – The actor runtime state to restore.
run
run() -> NoneMain loop for the PPO Trainer.
Collects rollouts by stepping all environments synchronously and storing transitions in the rollout buffer. When the buffer is full, signals the learner.
set_bc_materialisation_source
set_bc_materialisation_source(source: BCMaterialisationSource | None) -> NoneAttach the learner-side BC sampler's materialisation queue.
Parameters:
source(BCMaterialisationSource | None) – The request source, orNoneto disable materialisation.