Contents2 of 15
Download the PDF (892 KB)Before You Blame the ModelPart I · The Room: what the model actually sees
Chapter 01Context assembly
The request that never left the building
The run finished. Sixteen web pages went through a revision pass that cost 467,894 tokens. Not one page changed.
The setup was simple. An agent drafts a page from a written brief, then gets a chance to revise it. My harness also had a hard limit of 82 KB on any single request to the model. The easy story writes itself: the model got lazy. It looked at its own page, decided it was fine, and moved on. I could have tuned the revision prompt for a week on that theory.
Instead I did the boring thing I should always do first. I opened the requests.
Every revision call asked for the same thing: read(page.html). That's a perfectly sensible move. You can't revise a page you can't see. So my code built the next request, the one that would carry the page back to the model, and that request came out between 102 KB and 136 KB.
Remember that 82 KB limit.
So my harness refused to send it. Quietly. The model never saw the page it asked for, the revision ended right there, and the untouched draft went out as the final. A third of the run's tokens bought a read request that never got answered.
Then I went looking for siblings. Across the archive, 246 separate runs had hit the same wall. Each one ended the same way: the next request was too big to send, so it never left the building.
#Where the bytes went
The revision requests were obviously big, since each carried a whole page. But the most telling request in the archive was a small one. The smallest blocked request anywhere was 83.7 KB, only 1.7 KB over the line, and it shows where the budget really went:
That's the part that still bugs me. Every instinct said "make the big thing smaller," but 71.5% of the budget was gone before the task even started. Instructions and layout, fixed, re-sent on every request.
And here's why it hid so well: a request that never gets sent costs nothing. On my cost dashboard, those 246 runs looked like some of my cheapest work. They were the cheapest failures I've ever had, and the most expensive to find.
#You have walls too
You might not have an 82 KB limit. You have a context window, a max-tokens setting, a proxy body limit, a tool-output truncation rule. Each one is a wall, and each one fails differently:
- Refusal (my case): nothing gets sent. That's loud if you log it and invisible if you don't.
- Truncation: something gets sent, minus the part the model needed. The model still answers, confidently. This is worse.
- Silent drop: a section gets left out to make room, and nothing records it. The model is now reasoning about a world with a hole in it.
def send(request: dict):
body = json.dumps(request).encode()
nbytes = lambda x: len(json.dumps(x).encode())
sizes = {"system": nbytes(request.get("system", "")), # fixed content
"tools": nbytes(request.get("tools", [])), # counts too
**{f"{m['role']}#{i}": nbytes(m)
for i, m in enumerate(request["messages"])}}
log.info("request", bytes=len(body),
biggest=sorted(sizes.items(), key=lambda kv: -kv[1])[:5])
if len(body) > MAX_BYTES:
# an event with a name, not a debug line
emit("request_refused", bytes=len(body), limit=MAX_BYTES)
raise RequestTooLarge(len(body))
return client.post(body)Next: once the requests were actually leaving, I could finally see what they cost. The bill was not where I expected it.