Agent
Agent(context: RuntimeContext[ConfigT], action_selector: ActionSelector, inference_batch_size: int = 1, env_factory: Callable[[], OakEmuMultiEnv] | None = None) -> NoneABC for environment-interacting components.
Provides shared infrastructure for episode outcome tracking, metrics logging, and environment lifecycle management. Subclassed by Trainer (data collection) and Tester (greedy evaluation).
Initialize the Agent.
Parameters:
context(RuntimeContext[[Agent[ConfigT]](#mrkwatkins.oakemu_rl.framework.agents.Agent.Agent[ConfigT])]) – The shared runtime context.action_selector(ActionSelector) – The action selector for choosing actions.inference_batch_size(int) – Number of results to collect before running batched inference.env_factory(Callable[[], OakEmuMultiEnv] | None) – Optional factory for the multi-environment, used byrun(). Defaults to_default_env_factory, which builds a realOakEmuMultiEnv; tests can inject a factory returning a fake instead.
Properties
action_masker
action_masker: ActionMaskerGet the action masker.
Returns:
ActionMasker– The ActionMasker instance.
action_selector
action_selector: ActionSelectorGet the action selector used for action selection.
Returns:
ActionSelector– The ActionSelector instance.
config
config: ConfigTGet the experiment configuration.
Returns:
[Agent[ConfigT]](#mrkwatkins.oakemu_rl.framework.agents.Agent.Agent[ConfigT])– The experiment configuration instance.
metrics
metrics: MetricsTrackerGet the metrics tracker.
Returns:
MetricsTracker– The MetricsTracker instance.
result_queue_depth
result_queue_depth: intGet the current depth of the underlying environment result queue.
Returns:
int– The queue depth, or 0 if the environment has not started yet.
total_episodes
total_episodes: intGet the total number of episodes completed.
Returns:
int– The total episode count.
total_losses
total_losses: intGet the total number of losses.
Returns:
int– The total loss count.
total_truncated
total_truncated: intGet the total number of truncated episodes.
Returns:
int– The total truncated count.
total_wins
total_wins: intGet the total number of wins.
Returns:
int– The total win count.
Methods
restore_state
restore_state(state: AgentEpisodeTotalsState) -> NoneRestore the episode counters from checkpointed runtime state.
Parameters:
state(AgentEpisodeTotalsState) – The episode totals to restore.
run
run() -> NoneMain loop for the agent.