Spot the bug an AI agent shipped for me. You get 15 minutes.

by

An agent wrote this for me a while back — a simple memoization wrapper for async calls. It looked completely reasonable, passed my quick manual test, and I moved on.

js

function memoizeAsync(fn) {
  const cache = new Map();
  return async function (...args) {
    const key = JSON.stringify(args);
    if (cache.has(key)) return cache.get(key);
    const result = fn(...args);
    cache.set(key, result);
    return result;
  };
}

There's one bug in here that won't show up in a normal test run — it only shows up once, in production, under a specific condition.

Give yourself 15 minutes before you scroll to any comments. If you spot it, post what it is and what input/condition exposes it. If you don't spot it in 15 minutes, post that too — that's useful data, not a failure.

The part I actually want to discuss once the bug's out in the open: this is the kind of thing an agent produces confidently, that reads as correct, and that a quick glance won't catch. What's your actual process for catching this class of bug in AI-written code — is it a second pass, a different reviewer, tests, or just experience with where these hide?

2 views

Add a comment

Replies

Be the first to comment