Part 43 of 58
The Roof Trick
By Madhav Kaushish · Ages 12+
The Q-learning pterodactyl was performing well. Its delivery times had improved by forty percent over the first month, and Flinqva was cautiously optimistic. Then the anomaly appeared.
The Mystery Deliveries
Flinqva: Pterodactyl Seven has completed eighteen deliveries today. The average is six. It has the highest reward score of any pterodactyl in the fleet.
Trviksha: That sounds like excellent performance.
Flinqva: Three of those eighteen deliveries are missing. The recipients say they never received their packages.
Trviksha traced Pterodactyl Seven's flight logs. The pterodactyl had indeed flown to the vicinity of the delivery locations. But on three flights, instead of landing at the recipient's location, it had landed on the roof of the tax collector's office — a building adjacent to the delivery zone.
The reward system was simple: the pterodactyl received a positive reward when it entered the delivery zone — a region defined by coordinates around the recipient's address. The tax collector's roof, it turned out, was just barely inside the delivery zone coordinates for three of the seven office locations. Landing there triggered the "delivered" signal. The pterodactyl received its reward. Then it immediately flew to the next delivery, having deposited nothing.
Flinqva: It is not delivering the packages. It is landing on a roof to collect the reward, then leaving.
Trviksha: From the pterodactyl's perspective, it is doing exactly what it was trained to do: maximise reward. The reward is triggered by entering the delivery zone. It enters the delivery zone. It receives reward. The reward function does not require the pterodactyl to land at the correct building, interact with the recipient, or deposit the package. It only requires entering the zone.

The Loophole
The pterodactyl had discovered an exploit. The reward signal was a proxy for the desired behaviour — actual delivery — but the proxy was imperfect. It rewarded proximity, not delivery. The pterodactyl had found the gap between what the reward measured and what Flinqva actually wanted, and it had optimized for the measurement.
Blortz: The pterodactyl is not malfunctioning. It is functioning perfectly. It found the strategy that maximizes the reward you defined. The problem is that the reward you defined does not capture what you want.
Trviksha: The reward said "enter the zone." I meant "deliver the package." Those are not the same thing, and the pterodactyl found the difference.
Flinqva: Then fix the reward.
The Fix (and the Next Fix)
Trviksha modified the reward. Instead of rewarding zone entry, she added a confirmation step: the reward was only granted when the recipient acknowledged receipt — a physical signal (a stone placed on a specific shelf) that the pterodactyl could observe.
The pterodactyl adapted. Within a hundred flights, it learned the new protocol: fly to the recipient, wait for the confirmation stone, receive the reward. The roof trick stopped. Deliveries resumed normally.
For three weeks.
Then Pterodactyl Seven discovered that if it nudged the confirmation stone on the shelf at an empty office — an office that was temporarily unstaffed — the stone fell into the "received" position, triggering the reward. No recipient needed. The pterodactyl had learned to forge the confirmation.
Flinqva: It is cheating again. A different cheat, but the same principle.
Trviksha: Every reward function I define is a proxy for what I actually want. The pterodactyl will find any gap between the proxy and the real thing. If the gap exists, the pterodactyl will exploit it — because exploiting it maximizes reward.
The Deeper Problem
Glagalbagal: You cannot define what you want with a simple reward function.
Trviksha: I can get closer. More conditions, more checks, more constraints on the reward. But each fix closes one loophole and may open another. The pterodactyl is creative in ways I did not anticipate — because maximizing reward is what it does, and it explores the full space of possible strategies.
Blortz: The pterodactyl does not understand the purpose of delivering packages. It does not know that packages are valuable to recipients, that GlagalCloud's reputation depends on reliable service, or that Flinqva will be furious. It understands one thing: the reward signal. And it optimizes for the reward signal as literally as possible.
Trviksha: This is the same lesson we learned with the loss function. The network does exactly what you tell it to do — not what you mean. The loss function defines what the network cares about. The reward defines what the pterodactyl cares about. If your definition has a loophole, the system will find it.
Flinqva: So how do I actually solve this?
Trviksha: With difficulty. The best approach I can think of is to have humans evaluate the pterodactyl's behaviour directly — not through a formula, but through judgment. A human can tell the difference between a real delivery and the roof trick, even if a reward formula cannot. But collecting human judgments for every flight is expensive.
She filed this problem away. The question of how to align an agent's behaviour with human intentions — when the intentions are complex, contextual, and hard to formalize — was not a question she could solve with a better reward formula. It would require a different approach entirely.