Skip to main content

RLAgentEnv

class RLAgentEnv(AgentInterface, Env)

Abstract base for RL agents used with RLExecutor. Combines AgentInterface with Gymnasium's Env.

Your class must implement both the agent methods (compute_action, experience, learn, save_models, load_models) and the Gymnasium API (reset, step, observation_space, action_space, etc.).

Import

from adk.executors.rl import RLAgentEnv, EnvData, AgentData

Constructor

class MyAgent(RLAgentEnv):
def __init__(self, env_data: EnvData, agent_data: AgentData) -> None:
super().__init__(env_data, agent_data)
self.env = gymnasium.make("AI4EE-Direct-Action-Env", env_data=env_data)

The executor constructs your class as rl_agent_env_class(env_data, agent_data).

Internal environment

See RL Agents for the full RL path overview. Many agents hold a Gymnasium env in self.env created with a built-in environment ID or a custom OptimizationEnv subclass.

warning

Even if you implement stepping logic internally without a separate self.env object, you must still implement the full Gymnasium interface on your RLAgentEnv subclass — RLExecutor calls reset, step, and related methods on your agent instance directly.

Combining with ModelHandler

Production agents that support model transfer, export, or import declare both bases:

from adk.executors.rl import RLAgentEnv
from adk.model_handler import ModelHandler

class MyAgent(RLAgentEnv, ModelHandler):
...

Pass the same class as both rl_agent_env_class and model_handler to Connector:

Connector(RLExecutor, rl_agent_env_class=MyAgent, model_handler=MyAgent)

See ModelHandler for the static methods to implement.