Log inStart free
LESSON 24.01 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

An LLM task as an RL environment

Watch a coding task run as an RL episode, from prompt to reward.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 24.01 · EPISODE BAYTURN 0 · 2 FILES · 4 HIDDEN TESTS
01
Stage 1 of 6 · Prompt starts it
The prompt sets the initial state at turn 0. The files and the hidden tests are state the agent cannot see yet.
Explain it simply

A task prompt is like a job ticket. It starts the episode, and it sits alone in the conversation. The environment holds the whole state: a code file, a test file and four hidden tests. The agent sees none of them yet, so each box has a dashed outline.

The conversation holds the prompt: is_leap() is wrong for some century years. Fix leap.py. The environment holds leap.py, the test file and 4 hidden tests, all with dashed outlines.

state, observationsactions, rewardtools, limit, θfailed test, cut-offnot seen by the agent
conversation: what the agent seest0is_leap() is wrong for some century years.Fix leap.py.promptenvironment state: the full viewleap.pynot seendef is_leap(y): return y % 4 == 0tests/test_leap.pynot seenassert is_leap(2024)assert not is_leap(2023)hidden tests (grader)not seen1900 → False2000 → True2024 → True2100 → Falseturn 0limit 6the prompt starts the episodes0 = (prompt, leap.py, test file, 4 hidden tests)conversation: what the agent seest0is_leap() is wrong for some century years.Fix leap.py.promptenvironment state: the full viewleap.pynot seendef is_leap(y): return y % 4 == 0tests/test_leap.pynot seenassert is_leap(2024)assert not is_leap(2023)hidden tests (grader)not seen1900 → False2000 → True2024 → True2100 → Falseturn 0limit 6the prompt starts the episodes0 = (prompt, leap.py, test file, 4 hidden tests)
Toy: a leap-year fix, 4 hidden tests, 4 rollouts per prompt
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
s0=(prompt, files, hidden tests)\sy{s}{data}{s_0} = (\text{prompt},\ \text{files},\ \text{hidden tests})
s0: 1 message, 2 files, 4 hidden testss_0:\ 1\ \text{message},\ 2\ \text{files},\ 4\ \text{hidden tests}

The first state holds the prompt and everything the environment keeps.

Common mix-ups

MYTHA correct fix in the chat solves the task.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01In the repo task at a 3-turn limit, how many rollouts earn reward 1?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.