
Training Agents 4: From reward functions to environments.
Hugging Face2 September 2026Watch on YouTube
Part of series
Ep. 5 · RL voor AI-Agenten
Praktische workshops over reinforcement learning en beloningsfuncties voor het trainen van agentic AI-systemen met open-source tools.
View the seriesWhat you'll learn
- You learn why verifiers stop working once an agent takes many actions, and why the reward has to live where the actions happen
- The reset()/step() contract is explained, from CartPole to a coding agent with a shell, files, and tests
- You see the anatomy of an RL environment with task, tools, backend, reward, and episode, plus the OpenEnv, Verifiers, OpenReward and Harbor ecosystem
- A live demo shows how Qwen3-1.7B improves on MBPP and how a real coding agent (OpenCode) progresses on DeepCoder problems
- You discover forms of reward hacking inside the environment and how to limit them
Frequently asked questions
What is the difference between a reward function and a reward environment?
Which tools are used in this session to train agents?
What does the OpenEnv CLI contract involve for environments?
What results does a real coding agent achieve on DeepCoder problems?
Topics
Read next
Description from the channel
Training Agents, Session 4: from reward functions to environments. In this live session, the reward stops being a function and becomes a place the agent acts in. In Session 3 the model answered once and a Python function scored it. Today the model runs a loop: open a file, run a command, read the error, try again. The training signal comes from what happened after acting. We'll walk the reset()/step() contract from Gym to LLM agents, build an environment with OpenEnv, push it to the Hub, and plug it into TRL's GRPOTrainer with environment_factory. Then we go one step further and train a real coding agent harness through Harbor via OpenEnv, with AsyncGRPOTrainer on Hugging Face sandboxes. What we'll cover: - Why verifiers stop working once an agent takes many actions, and why the reward has to live where the actions happen - The reset()/step() contract: from CartPole to a coding agent with a shell, files, and tests Anatomy of an RL environment: task, tools, backend, reward, episode - The ecosystem: OpenEnv, Verifiers, OpenReward, Harbor, and how OpenEnv imports the others - Building and serving an env with the openenv CLI: init, push, pull, fork - Training with TRL: environment_factory and get_reward, no reward_funcs - Demo 1: Qwen3-1.7B on MBPP inside a live Python session, held-out pass rate 0.49 → 0.59 - Demo 2: a real coding agent (OpenCode) on DeepCoder problems in HF sandboxes, reward 0.27 → 0.71 in 10 steps - Reward hacking moves into the env: the try/except that never failed, the CVE fix read from .git history, and how to lock the box down