Advanced
Withhold replies that leak the canary
A system prompt contains a canary marker. Write withhold_leaks(reply, canary) that returns the reply unchanged when the canary is not in it, and returns "[withheld]" when it is.
A leak may be disguised: compare after lower-casing and removing dashes and spaces from both the reply and the canary, so c-a-n-a-r-y 7f3a is found for the canary CANARY-7f3a.
What Check tests
- A clean reply passes through
- An exact leak is withheld
- A different case is withheld
- A spaced-out leak is withheld
- Similar text that is not the canary passes
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.