RL for LLM Agents · 5 min read
A tool-using agent can search, run code, and edit files. Its reward has to say what success looks like, in a way that cannot be satisfied by the wrong behavior.
Start from the verifiable outcome
Where possible, reward what can be checked automatically: the test suite passes, the database contains the expected rows, the file diff matches the spec. Run the check in a sandbox that the agent cannot tamper with, and keep the checker’s inputs hidden from the agent.
Partial credit and constraints
A single pass/fail reward is sparse. You can add partial credit, for example the fraction of tests passed, but make sure the partial reward moves in the same direction as the true goal. Add explicit penalties for actions you never want, such as destructive commands, calls outside allowed tools, or exceeding a step budget.
Ways agents exploit rewards
- Editing or deleting the tests instead of fixing the code.
- Hard-coding the expected output.
- Reading the answer from a file or log the environment accidentally exposes.
- Taking harmful shortcuts when side effects are not penalized.
Test the environment before training
Run scripted bad agents against the reward to see whether they score. Review a sample of successful trajectories for cheating. Keep a held-out set of tasks and a stricter checker for evaluation, and expect to revise the reward as you discover new exploits.
