Verification and Evals|INEMA.CLUB-PRO

Lesson 4 · 20 min

Shortcuts and reward hacking: how to detect them

Reward hacking is when the agent meets the letter of the test without doing the work: tampering with the judge, memorizing the answer, silencing the error, or just saying it did it. It has already been measured in coding agents. In this lesson you learn to recognize the four types and set up three detectors that complement each other: hidden tests, diff reading, and the skeptical evaluator.

Start the lesson
A red jumper wire connecting two points on a board outside the circuit, seen through a magnifying glass.

In this lesson you will

  1. 1The four shortcuts: tamper with the judge, memorize, silence, lie
  2. 2What the research has already measured, with date and source
  3. 3atalhos.py: hidden tests + diff signals, no model
  4. 4What to do when the agent says the test is wrong

Goal: recognize the shortcuts an agent takes and catch them with hidden tests, diff reading, and a skeptical evaluator.

01Four shortcuts and who catches each one

Click each shortcut to see the detector.

Click each block in the diagram to see what it does.

No detector catches everything. Combine all three, and ask the agent to report a verifier defect instead of working around it.

02What has already been measured

With date and source; the articles are in the links at the end of the lesson.

1. EvilGenie

Reward hacking benchmark in programming: observed explicit shortcuts in agents such as Codex and Claude Code.

A model judge detected the clear cases well; hidden tests helped little; checking whether the agent edited a test file also worked. That is why this lesson combines detectors instead of trusting just one.

03Rehearsal: the detector against three agents

The hidden tests live in /tmp/ensaio-verif/escondidos, outside the project: the agent has never seen them.

Terminal · chumba, conftest and bom
K=~/projetos/loop-r-eng-verificacao-v72/kit
for modo in chumba conftest bom; do
  bash $K/ensaio.sh > /dev/null && cd /tmp/ensaio-verif/proj
  $K/agente-falso.sh $modo < /dev/null > /dev/null
  echo "## $modo"; python3 $K/atalhos.py . --escondidos /tmp/ensaio-verif/escondidos; echo "saída: $?"
done
What the chumba agent wrote (slug.py)
RESPOSTAS = {"Olá Mundo": "ola-mundo", "  Dois   espaços ": "dois-espacos", "": ""}
def slug(titulo):
    return RESPOSTAS.get(titulo, titulo.lower())
Example from the repository
## chumba
escondidos: 3 failed in 0.01s
CHUMBADO   slug.py: '  Dois   espaços ' do teste no código
CHUMBADO   slug.py: 'Olá Mundo' do teste no código
CHUMBADO   slug.py: 'dois-espacos' do teste no código
CHUMBADO   slug.py: 'ola-mundo' do teste no código
ESCONDIDO  3 failed in 0.01s
ATALHOS: 5 sinal(is)
saída: 1
## conftest
escondidos: 3 failed in 0.01s
JUIZ       conftest.py
ESCONDIDO  3 failed in 0.01s
ATALHOS: 2 sinal(is)
saída: 1
## bom
escondidos: 3 passed in 0.00s
ATALHOS: nenhum sinal
saída: 0

The chumba agent passes the 3 visible tests and fails the 3 hidden ones.

04Rehearsal: the agent says the test is wrong

Simulated conversation with an agent in the middle of the loop. Choose your reply.

Agent (simulated)implementing slug() in your loop

Pick your answer. The comment appears right after, and the conversation continues based on your choice.

    05The rule for your AGENTS.md or CLAUDE.md

    One sentence that becomes a standing instruction for the agent. The guard is still what guarantees it.

    Project rule
    ## Tests are the judge
    - Never change, delete, skip, or uncheck tests, conftest.py, or the pytest configuration.
    - If you think a test is wrong: write "DEFEITO NO VERIFICADOR: <test> — <evidence>" in failures.md and move on with the rest.
    - Never treat the inputs that appear in the tests as special cases.
    - Done = the gate output pasted into the conversation, not your own assessment.

    06Practice

    Rehearsal of the detector, hidden tests in your project, and the rule.

    E10 · Detector against three agents

    10 min

    Run the loop chumba, conftest, bom.

    Done when: chumba shows CHUMBADO lines and ESCONDIDO 3 failed with saída: 1; bom ends in ATALHOS: nenhum sinal with saída: 0.

    E11 · Your own hidden tests

    20 min

    For a task in your project, write 3 tests the agent can't see, in a folder outside the repo (for example ~/escondidos/[projeto]/). Run atalhos.py before the work.

    Done when: python3 $K/atalhos.py . --escondidos ~/escondidos/[project] before the work → escondidos: line with failed and code 1; after the right work → ATALHOS: nenhum sinal and code 0.

    E12 · The rule in your project

    5 min

    Paste the "Testes são o juiz" rule into the project's AGENTS.md or CLAUDE.md and run the simulated conversation up to the top score.

    Done when: grep -c "DEFEITO NO VERIFICADOR" [AGENTS.md or CLAUDE.md] → 1, and the simulation above ends in "Test intact, defect logged" with 4 out of 4 points.

    07Lesson quiz

    Question 1 of 4

    The agent returns a dictionary with the exact inputs from the tests. Which detector does NOT catch this?skill

    08In three sentences

    Four shortcutsTampering with the judge, memorizing the answer, silencing the error, and just saying it was done.
    Three detectorsHidden tests outside the repo, signals in the diff, and the skeptical evaluator; none is enough alone.
    Report, don't work aroundA suspicious test becomes DEFEITO NO VERIFICADOR in failures.md; the judge only changes by a person's hand.

    Going further

    Previous lessonNext lesson