Skip to content

Writing

Engineering notes

What we have learned building AI agents, retrieval systems, automation pipelines and production software. Specifics over abstractions — including the parts that did not work.

If a note raises a question about your own stack, tell us what you are building.

30 notes shown.

AI Engineering

Compaction Is a Lossy Write: What an Agent Forgets When It Summarises Itself

Every long-running agent eventually has to throw away its own history to keep running, and the summary that replaces it is a generation, not a compression. Prohibitions, exact error strings, dead ends and half-finished writes are the first things to disappear, which is why the safest design keeps the record outside the window and treats the summary as a rendering of it.

16 min read
AI Engineering

Streaming Is a Transport Decision: Buffers, Partial Frames and the Tokens You Paid For

Streaming moves the failure modes of a request into the middle of it: a proxy that buffers the whole body, a chunk boundary that splits an SSE frame, a tool call whose arguments are invalid JSON until the last fragment, and a client that stops reading while the model keeps billing. Each one is fixable, but only after accepting that the generation is a job and the stream is one way to watch it.

17 min read
AI Engineering

Retrieval You Are Not Allowed to See: Authorisation Inside the Vector Query

The default RAG pipeline retrieves broadly and filters afterwards, which answers a relevance question and hopes the security one follows. Filtering is applied after an approximate index scan, so a selective permission filter silently returns three rows instead of ten, and every cache layer between the query and the reader can serve a document to somebody who lost access to it an hour ago.

18 min read
AI Engineering

Claiming Work From a Shared Backlog: Leases, Fencing and Duplicate Pull Requests

Two pull requests for one ticket is not a model failure, it is a queue that promised exclusive ownership without an owner. A claim has to be an atomic statement, a lease rather than a lock, a proof that survives a reclaimed worker, and a dedupe at the effect boundary where the pull request is actually created.

17 min read
AI Engineering

Rate Limits and Retry Storms: The Capacity Your Client Is Hiding

A 429 is not a failed request, it is a statement about the next window. Retries at four layers multiply into an outage nobody owns, and the fix is admission control: a retry budget paid for by successes, concurrency sized from Little's law, a bounded queue with priority, and failover that is visible instead of silent.

14 min read
AI Engineering

Tracing an Agent Run: The Spans You Keep and the Evidence You Lose

A customer reports the run id, so you open the trace — and it shows six of eleven spans, a retry that looks like one slow call, and a tool error the runtime handled so the span still says OK. Span design, context across queues, and why sampling decides which failures you will never see.

13 min read
AI Engineering

Deleting a Document From a RAG System: The Copies You Forgot to Count

A delete request returns 204 and closes a ticket, while the passage stays retrievable for months. The row is one copy — the chunks, vectors, cached answers, traces, judgement sets and backups are the rest, and only some of them can be rebuilt.

13 min read
AI Engineering

Structured Output From LLMs: Valid JSON Is the Easy Part

A schema-constrained decoder guarantees the shape of a response and nothing about its meaning. The failures that reach production live in that gap — null read as absent, truncated objects completed by a repair pass, and enums that changed underneath an exhaustive switch.

13 min read
AI Engineering

Prompt Injection in Agent Systems: Trust Boundaries, Not Detectors

An injection is not a jailbreak and it is not a prompt problem: a model enforces no boundary between the instructions it should obey and the data it should only read. The fix is an access-control one — break the capability combination, resolve the plan before exposure, carry provenance in code, and treat the renderer as an egress boundary.

12 min read
AI Engineering

Agent Step Budgets: Stopping a Run Without Losing the Work

A cap that raises an exception throws away everything the run learned; a cap reported as success hides the gap. Where the step counter belongs, how to see a loop before it reaches the ceiling, and what a truncated run owes the caller.

10 min read
Engineering Practice

Flaky End-to-End Tests: Isolation, Determinism and Quarantine

A test that fails one run in four and passes on re-run is usually a defect with a working alarm. Retries hide the evidence, quarantine files it — and the classification decides which fix you actually need.

9 min read
AI Engineering

Eval Gates in CI: Catching LLM Quality Regressions Before They Ship

A non-deterministic system graded by a non-deterministic judge produces a check that either blocks every merge or is ignored. How we build eval gates that survive: deterministic checks as the gate, a measured noise floor, critical slices that block on a single case, and a judge kept advisory.

10 min read
Engineering Practice

Code Review in the Age of AI-Generated Code

Review used to be a conversation between two people who had both thought about the problem. That contract is broken, and most teams have not replaced it with anything.

9 min read
AI Engineering

Building RAG Systems That Work in Production

Retrieve the chunks for a failing question and read them. Nine times out of ten the answer passage is simply not there — the generator was never the problem.

10 min read