All courses

Why agents fill gaps with plausible guesses

Explain that when information is missing, the model tends to produce the most typical continuation instead of stopping to ask. Its guesses therefore match common patterns from public code, not your codebase's helpers, conventions or constraints.

Builds on: What the agent cannot see, Why agent output always sounds sure

Read it card by card Start the whole course

Tidy code that ignored your helpers

You asked the agent for a function that fetches exchange rates. A minute later: tidy, idiomatic Python, tests green. But your project already has `api_client` (auth, timeouts, retries) and `now_utc()`. The agent used `requests` and `datetime.now()` instead. It never asked whether such helpers existed and flagged nothing. Why does it fill the gap instead of stopping?

A gap doesn't feel like a gap

The model writes the most likely continuation of its context. Files it never opened don't exist for it. Yet there is always a likely next line: what thousands of public projects do. A missing fact doesn't register as missing, so asking rarely beats writing code. The guess sounds as sure as a fact, and it fits *typical* code, not *your* helpers, conventions and constraints. Later cost: code that silently skips what your helpers enforce, such as auth, timeouts and retries.

Read from your code, or typical code?

For each choice in the diff, ask: did this come from a file the agent read, or from what most code does? Tells of a guess: - a popular library imported where you have a wrapper - library defaults left as-is (timeouts, time zones, encodings, page sizes) - names or structure unlike neighbouring files - an ambiguous task finished with no question and no stated assumption Check the transcript for which files it actually opened.

Pagination, the tutorial way

Task: 'add pagination to `GET /users`'. Your other list endpoints use cursor pagination via a `paginate()` helper, capped at 100 rows, because the table is huge. The agent opened only the users route and wrote `?page=&limit=` with SQL `OFFSET`, the tutorial pattern. Tell: parameter names unlike every other endpoint. Later cost: deep pages get slow, and clients face two pagination styles. Better: name `paginate()` and an existing endpoint in the task.

The public-code default vs your project

BAD is what public Python usually looks like. Tells: `requests` imported where the project has its own client, and `datetime.now()` where the project uses `now_utc()`. Later cost: `requests.get` has no default timeout, so a stuck rates server can hang the caller forever. `r.json()` runs without a status check, so a JSON error body is returned as if it were rates. `datetime.now()` returns naive local time, so on a server not set to UTC, stored timestamps are off by its UTC offset.
// Python
# BAD
import requests
from datetime import datetime
def fetch_rates():
    r = requests.get(RATES_URL)
    return r.json(), datetime.now()
# BETTER
from app.http import api_client
from app.clock import now_utc
def fetch_rates():
    rates = api_client.get_json(RATES_URL)
    return rates, now_utc()

Missing facts become typical guesses

When a fact is missing, the agent rarely stops to ask; it writes what typical public code would do. Treat every choice it could not have read from your code as a guess to check, and give it your helpers and constraints up front.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.