WannaDo Series: AI-Native Clean-Style Deep Reinforcement Learning Platform — wannado-drl
Part of the WannaDo human–AI collaborative scientific research platform · Release v1.3.0

Review an existing policy
Keep your simulator, training code and checkpoint. Use accept to evaluate a fixed policy against random actions and a human-authored operating rule on matched episodes. The output gives reviewers the seed-level differences, the scope of the decision and the reasons to hold a candidate. Problem formulation, reward, business KPIs and the choice of operating rule remain yours.
With wannado-drl installed, a complete first review takes one command:
wannado-drl accept --example inventory --out ./drl_lab/inventory-review
Open the HTML path printed by the command. The inventory fixture simulates 28 days of booked and walk-in orders, replenishment, lost sales and holding costs. A fixed PyTorch order controller competes with random orders and a standing reorder-to-12 rule. These are simulated operations. The evidence describes this controller across environment seeds; independent training runs and physical deployment require separate evidence.
For your own asset, expose two small factories in a trusted local Python file. For example:
# review_interface.py — use your application's existing factories
from my_project.inventory import make_env, load_frozen_controller, reorder_rule
make_policy = load_frozen_controller
heuristic_fn = reorder_rule
task_name = "Warehouse controller qualification"
wannado-drl accept --interface ./review_interface.py --seeds 10 20 30 --episodes 10 --out ./drl_lab/review-001
A factory can return a PyTorch module or a callable. To load a saved WannaDo PolicyBundle, pass --policy ./policy.pt. For a Stable-Baselines3 archive, install its original SB3 dependencies and use --policy ./policy.zip --sb3-algo PPO. Preserve the observation transforms used in training. The CLI returns 0 for an accepted evaluation, 1 for a measured hold and 2 for an input or delivery error. Each output directory represents one review. For authenticated handoff, provide a secret via your environment and pass --signing-key-env DRL_REVIEW_KEY.
Receive a package and compare candidates
A recipient can move or copy the entire directory. The following commands authenticate its contents, then compare a newly audited candidate with the approved reference:
wannado-drl review ./drl_lab/review-001 --require-signature --signing-key-env DRL_REVIEW_KEY
wannado-drl review ./drl_lab/review-002 --baseline ./drl_lab/review-001 --max-return-drop 0 --require-signature --signing-key-env DRL_REVIEW_KEY
A valid package may record a policy that was held. The comparison checks comparable episode blocks, environment and controls before applying the margin to each seed. Declare reward_unit on your interface in the units in which your team approves changes. List local scenario data, configuration and supporting model-independent simulator code as environment_files = ["scenario.json", "dynamics.py"]. The comparison binds the recorded inputs; pin remote services and runtime dependencies separately. Set a genuine Gymnasium episode horizon; --max-episode-steps bounds evaluation if an invalid simulator keeps running.
For a discrete or continuous policy trained with vector observation normalization, export the frozen transformation in your training environment:
from wannado.drl.audit.policy_normalization import save_frozen_normalization
save_frozen_normalization(model.get_vec_normalize_env(), "frozen_obs.json")
Pass --normalization ./frozen_obs.json alongside the checkpoint and expose the raw-observation environment. A previously saved SB3 VecNormalize can be loaded in your trusted training project and exported the same way. The evidence records the transformation's digest. A PolicyBundle with embedded normalization should use its own preprocessing.
Hand an approved checkpoint to a shadow runner
For simulator stress testing, mark your trusted interface with simulation_only = True. Run accept with --stress to evaluate the fixed policy under latency, sensor and actuator perturbations. If your simulator supplies a cost at every step, set --cost-limit in cumulative episode-cost units. Review the per-scenario results and measured violations. This declaration identifies the caller-provided simulator; the operator controls physical isolation.
For an accepted feed-forward WannaDo PolicyBundle, record raw observations from your simulator or existing logs. Store them in a NumPy archive, for example np.savez("replay.npz", observations=raw_obs). Use float32 for vector inputs and the policy's original image dtype for images. Supply the matching action_masks array if the policy was evaluated with masks. Preserve the untouched replay file for independent comparison. Existing offline NPZ datasets can be opened with OfflineTransitionDataset.load(path); an installed Minari dataset can be adapted with OfflineTransitionDataset.from_minari(dataset). For compatible array observations, save dataset.obs as the replay's observations entry and include the recorded masks separately when required. Replay parity does not estimate the return of an unexecuted policy.
wannado-drl accept --interface ./review_interface.py --policy ./agent.pt --stress --out ./drl_lab/qualified --signing-key-env DRL_REVIEW_KEY
wannado-drl handoff --review ./drl_lab/qualified --policy ./agent.pt --replay ./replay.npz --out ./drl_lab/shadow --require-stress --signing-key-env DRL_REVIEW_KEY
wannado-drl review ./drl_lab/shadow --source-review ./drl_lab/qualified --signing-key-env DRL_REVIEW_KEY
The handoff binds the accepted checkpoint, normalization, replay and reloaded TorchScript binary in a signed manifest. It compares discrete actions exactly and continuous actions with the recorded tolerance. A held policy, substituted checkpoint or failed replay cannot produce a new handoff. The optional stress requirement must be set by the operator when their qualification protocol calls for it. The delivered scope covers offline action parity and shadow inference. Hardware commissioning and the choice of safety constraints remain with the system owner.
wannado-drl is an AI-focused Deep Reinforcement Learning platform built around four pillars:
- Stage 0 Problem-to-MDP Joint Modeling & Active Future-Leakage Probes (
Problem → MDP): Unlike generic RL libraries that jump straight into PPO() or SAC(), wannado-drl starts by diagnosing whether your problem actually needs RL, formalizes the control cycle, terminated vs truncated, reward_terms, task_metrics, and cost budgets inside drl_lab/mdp_spec.json, and runs active pure-NumPy Future-Leakage & Conditioning Probes (run_mdp_probes) to block t+1 lookahead bugs before wasting GPU/CPU time.
- Clean-style Single-File Algorithms Across 8 Authoritative Families (
30 Algorithms): From pedagogical tabular classics (Monte Carlo, SARSA, Q-Learning), deep value methods (DQN, Double DQN, Dueling DQN, C51), policy gradients (REINFORCE, A2C, TRPO, PPO, PPO-GRU), continuous/HIL off-policy control (DDPG, TD3, SAC, HIL-SERL), Safe & Risk-Constrained RL (PPO-Lagrangian, SAC-Lagrangian (PID), CVaR-PPO), offline RL (CQL, IQL), and multi-agent CTDE (VDN, QMIX, MAPPO, MADDPG) to frontier sequence/discovered RL (GRPO, DAPO, GSPO, ARPO, DiscoRL). Run wannado-drl eject <algo_id> to copy only that single readable .py file into ./drl_lab/algos/.
- Non-Intrusive External
drl_lab/ Plug-In, Vectorized & Multimodal Engine: Never scatter RL loops across your simulator or codebase. Wire your project through ./drl_lab/interface.py (EnvInterface)—or pass "CartPole-v1" IDs directly—adapting Gymnasium, legacy OpenAI gym, dm_control, PettingZoo MARL, custom Python simulators, offline datasets, and verifiable sequence tasks. Built-in true VectorEnv batching (SyncVectorEnv / AsyncVectorEnv), multimodal encoders (NatureCNN, IMPALA ResNet, SetAttention, and DictCombinedExtractor with native uint8 storage + DictRunningMeanStd + RewardNormalizer), and atomic CheckpointManager + PolicyBundle / load_policy().
- External SB3/PyTorch Policy Auditing, rliable Bootstrap Statistics & Zero-Hallucination Gate (
wannado-drl verify): Directly ingest external Stable-Baselines3 (.predict() + VecNormalize), PyTorch nn.Module, or callable policies into audit_external_policy() and evaluate_drl_suite(..., external_policies=...). Enforces Stage 1 leakage/mask probes, Stage 3 audit_drl_rigor() (catching single-seed luck, Reward Hacking KPI divergence, unfrozen eval VecNormalize/obs_rms, entropy collapse, action saturation, and safety constraint breaches), and Stage 4 rliable exports (IQM with 95% Bootstrap CIs, pairwise $P(A > B)$, Performance Profiles, paper_summary.md, paper_table.tex, and verbatim references.bib).
Installation & Ecosystem Coexistence
pip install wannado-drl
# Coexists cleanly with wannado-adv under PEP 420 `wannado.*`:
pip install wannado-adv wannado-drl
Core dependencies remain strictly numpy>=1.24, torch>=2.0, and gymnasium>=1.0.
Optional Two-Stage Ecosystem Workflow (wannado-drl + wannado-adv): Both packages remain 100% independent—you do not need wannado-adv to use wannado-drl, and vice versa. If you install both together (e.g., train an RL policy in ./drl_lab/ first and then stress-test its perturbation robustness in ./adv_eval/), their namespaces (wannado.drl / wannado.adv), agent skills (.agents/skills/wannado-drl/ vs .agents/skills/wannado-adv/), and marked rule blocks (<!-- wannado-drl:start/end --> vs <!-- wannado-adv:start/end -->) remain isolated with explicit intent boundaries so their AI Co-Pilot prompts never overwrite or conflict with each other.
git clone https://github.com/JietaoZhao/wannado-drl.git
cd wannado-drl
pip install -e ".[dev]" --no-build-isolation
Universal AI IDE Co-Pilot (init-agent)
Built on the open AGENTS.md + .agents/skills/ standard (compatible across Cursor, Antigravity, VS Code Codex, Claude Code, Windsurf, Aider):
# 1. Bind portable 5-stage Co-Pilot rules into your project root
wannado-drl init-agent --dir .
# 2. Prompt your AI IDE agent in any language:
# "Help me formulate an MDP and train a DRL baseline for this project using wannado-drl..."
The 5-Stage Human–AI Workflow
| Stage |
Purpose |
Outputs / Guardrails |
| Stage 0 |
wannado-drl inspect . & Problem → MDP Intake |
RL suitability check (diagnose_rl_suitability), anti-leakage & terminated/truncated checklist → drl_lab/mdp_spec.json |
| Stage 1 |
Non-intrusive drl_lab/ Scaffold + Preflight & Baselines |
drl_lab/interface.py, measured ms/step, Random & Heuristic baseline floors before RL training |
| Stage 2 |
Plain-Language Algo Match & Hardware ETA |
Plain analogies (on-policy vs off-policy, gamma, ent_coef, num_seeds) + calibrated multi-seed ETA |
| Stage 3 |
CleanRL Single-File Training + Anti-Fake-Convergence Audit |
Multi-seed IQM, catches single-seed luck, Reward Hacking KPI drop, unfrozen eval RunningMeanStd, entropy collapse |
| Stage 4 |
Plain Verdict & Paper Deliverables |
Plain-language takeaway first + drl_report.json, paper_summary.md, paper_table.tex, learning_curves.csv, references.bib |
8-Family Algorithm Taxonomy & Verified Lineage (30 Algorithms)
Every algorithm carries embedded META, [AI-Prompt Hook] research extension points, and verified BibTeX/IEEE/APA provenance (wannado-drl cite <ids>):
| Family |
Algorithms (id) & Evolution Lineage |
Paradigm & Key Role |
1. tabular_classic |
monte_carlo (Sutton & Barto 2018) → sarsa (Rummery & Niranjan 1994) → q_learning (Watkins & Dayan 1992) |
Pedagogical foundations & exact tabular baselines (auto-bins continuous obs if desired) |
2. value_based |
q_learning → dqn (Mnih et al., Nature 2015) → double_dqn (van Hasselt et al., AAAI 2016) → dueling_dqn (Wang et al., ICML 2016) / c51 (Bellemare et al., ICML 2017) |
Discrete deep Q-learning with replay, target decoupling, V+A dueling, & return distributions |
3. policy_gradient |
reinforce (Williams 1992) → a2c (Mnih et al., ICML 2016) / trpo (Schulman et al., ICML 2015) → ppo (Schulman et al. 2017) → ppo_gru |
On-policy actor-critic with GAE, action masking, & GRU memory for POMDPs |
4. actor_critic_off |
dqn → ddpg (Lillicrap et al., ICLR 2016) → td3 (Fujimoto et al., ICML 2018) → sac (Haarnoja et al., ICML 2018) → hil_serl (Luo et al., Science Robotics 2025) |
Sample-efficient continuous control + RLPD LayerNorm critics & 50/50 human-in-the-loop demo replay |
5. safe_constrained |
ppo → cvar_ppo (Chow et al., JMLR 2018) / ppo_lagrangian (Ray et al. 2019); sac → sac_lagrangian (Stooke et al., ICML 2020) |
Constrained CMDPs (E[cost] <= limit) with PID dual control & percentile tail-risk CVaR optimization |
6. offline_rl |
sac → cql (Kumar et al., NeurIPS 2020) → iql_offline (Kostrikov et al., ICLR 2022) |
Safe policy extraction from static logged datasets with zero online exploration |
7. multi_agent |
vdn (Sunehag et al., AAMAS 2018) → qmix (Rashid et al., ICML 2018); ppo → mappo (Yu et al., NeurIPS 2022); ddpg → maddpg (Lowe et al., NeurIPS 2017) |
CTDE cooperative/mixed multi-agent RL (PettingZoo & dict-stepped sims) |
8. llm_and_discovered |
ppo → grpo (Shao et al., DeepSeekMath 2024) → dapo (Yu et al., NeurIPS 2025) / gspo (Zheng et al. 2025) / arpo (Dong et al. 2025); a2c → discorl (Oh et al., Nature 2025) |
Critic-free group-relative sequence/tool-agent RL & meta-discovered latent-prediction update rules |
Quick Usage (CLI & Python)