reward function
The reward function is the scoreboard. After each step the environment hands the agent a single number that says how good that moment was: positive for reaching a goal, negative for crashing, perhaps a tiny cost for every passing second. This signal is the entire definition of what we want, and the agent has no other notion of success.
Formally the reward is an expected value attached to a state, a state-action pair, or a transition. The agent never optimises a single reward; it optimises the long-run sum of them, the return. Because the reward is the only place your intent enters, a careless design can be gamed: the agent may find a loophole that piles up reward while flouting what you actually meant.
Reward says what to achieve, never how; spelling out the how is the job of the policy.