Stop importing a dozen different agent classes. OneAgent is the single, all-encompassing interface for Reinforcement Learning.
Whether you are fine-tuning a tabular solution for a GridWorld or training a Deep Reinforcement Learning model for a robot, your code structure should not change. OneAgent encapsulates the entire RL landscape—Tabular, Linear, and Deep—into a single, configuration-driven entity.
In other libraries, changing an algorithm requires rewriting your initialization code.
-
Old Way:
from stable_baselines3 import PPO$\to$ from my_lib import QTable -
The OneAgent Way:
from oneagent import Agent. Just change the config.
git clone https://github.com/Mat-thias/OneAgent.git
cd OneAgent
pip install -e .The Agent class is a shapeshifter. It adapts its internal architecture based on the config dictionary you pass to it.
You are learning RL. You want to see the Q-Table.
import gymnasium as gym
from oneagent import Agent
env = gym.make("Taxi-v3")
# The Agent becomes a Tabular Q-Learner
agent = Agent(
env=env,
config={
"mode": "tabular",
"algorithm": "q_learning",
"policy": "epsilon_greedy",
"memory": "none" # Tabular doesn't need a buffer
}
)
agent.train(episodes=1000)You graduate to a visual environment. You need a Neural Network. You do not change the Agent class.
import gymnasium as gym
from oneagent import Agent
env = gym.make("CartPole-v1")
# The SAME Agent class morphs into a DQN
agent = Agent(
env=env,
config={
"mode": "deep", # <--- Switches backend to PyTorch
"algorithm": "q_learning", # <--- Logic remains Off-Policy TD
"policy": "epsilon_greedy",
"memory": "prioritized_replay", # <--- Adds PER Buffer
"network": {
"hidden_sizes": [128, 128],
"activation": "relu"
}
}
)
agent.train(episodes=500)You want to simulate experience using a learned model (Dyna-Q).
# The Agent activates its internal Model simulator
agent = Agent(
env=env,
config={
"mode": "tabular",
"algorithm": "dyna_q", # <--- Activates Planning Loop
"planning_steps": 10 # <--- 10 Hallucinated steps per real step
}
)OneAgent doesn't just list algorithms; it combines Components to create agents.
| Capability | Options Supported |
|---|---|
| Brain (Backend) | Table (Dict), Linear (TileCoding), Neural (MLP/CNN) |
| Logic (Update) | MonteCarlo, TD_0, TD_N, ExpectedSARSA, DoubleLearning |
| Memory | None (Online), UniformReplay, PrioritizedReplay, Hindsight |
| Exploration | EpsilonGreedy, Softmax, UCB, OU_Noise (Continuous) |
How does one class do everything? Composition.
OneAgent is a wrapper that routes your config to the correct sub-modules.
OneAgent/
├── __init__.py
├── core_agent.py # The single entry point
│
├── brains/ # Stores the Value Function
│ ├── tabular_brain.py
│ └── neural_brain.py
│
├── algorithms/ # Calculates the Loss/Error
│ ├── bellman_equation.py
│ └── policy_gradient.py
│
└── memories/ # Stores the Experience
└── replay_buffer.py
- v1.0 (The Foundation): Tabular & Linear support for all Sutton & Barto algorithms.
- v2.0 (The Expansion): Deep RL support (DQN, Dueling DQN).
- v3.0 (The Continuous): Actor-Critic methods for robotics (PPO, SAC).
We want OneAgent to be the Swiss Army Knife of RL. If you have a new exploration strategy or a better replay buffer, open a PR!