When AI Context Became the Bug

Archive note: This debugging session occurred on December 30, 2025.
Tool behavior and product limits change, but the resource-management
lesson remains current.

We were building an automated newsroom with n8n, PostgreSQL,
WordPress, several model providers, and an AI coding assistant. Then the
assistant began failing at roughly the same point in every debugging
session.

The visible error was a prompt or context limit. The instinct was to
blame the newest code, the operating system, or an unstable integration.
The more useful explanation was that we had treated the assistant’s
context as an infinite scratchpad.

It was not.

Context Had
Become an Accumulation of Artifacts

The project generated large workflow definitions, database results,
logs, documentation, and image data. Each item was individually
defensible. Together they became a resource leak.

Three patterns were especially expensive.

Full workflow responses

Fetching a complete n8n workflow returned every node, parameter,
prompt, and connection. Repeating that during debugging added large JSON
documents to the conversation.

Most questions did not require the full representation. A structural
view of node names and connections was enough to identify topology
problems. Full workflow data should have been retrieved only for the
specific nodes being changed.

Large database columns

The marketing experiment stored generated image artifacts in the
database. A careless SELECT * could return megabytes of
encoded image data when the only useful question was whether an artifact
existed and how large it was.

The safer query selected identifiers, status, timestamps, and
LENGTH() of the large column. This is ordinary database
hygiene, but AI tools add another consequence: every unnecessary byte
can become prompt input.

Repeated documentation

The repository contained current specifications, archived
specifications, session summaries, generated handoffs, and
near-duplicates. Even when an assistant did not automatically read all
of it, broad searches and indiscriminate file loading made it easy to
pull obsolete material into the active task.

The problem was not merely size. Conflicting documentation increased
uncertainty while consuming context.

Disabling a Tool
Did Not Remove Its History

Once a large response entered the conversation, turning off the
integration prevented additional calls but did not erase the existing
material. The practical recovery was a fresh session with a compact
handoff.

That changed how I thought about AI-assisted work. A session was
closer to a transaction than a permanent workspace:

  1. Enter with a defined objective.
  2. Load only the state required for that objective.
  3. Perform the work.
  4. Persist decisions and results in the repository.
  5. End the session before the accumulated context became a
    liability.

The durable state belonged in files, commits, tests, and databases.
The conversation was working memory.

A Better Handoff

The replacement for marathon context was a short resume document
containing:

  • Current objective
  • Verified system state
  • Decisions already made
  • Files or services changed
  • Known blockers
  • Exact next action

The handoff was intentionally concise. A ten-page summary would
reproduce the original problem.

This also improved reliability. A fresh assistant session could read
the current state rather than infer it from hours of exploratory
conversation. The handoff forced us to distinguish facts from abandoned
theories.

Tool Output Needs a Budget

Developers routinely manage CPU, memory, network calls, and database
load. AI-assisted development adds another finite resource: context.

Useful operating rules emerged:

  • Request summaries or structural views before full payloads.
  • Query only required columns.
  • Never return binary or encoded media through a text tool unless
    essential.
  • Limit logs by time, severity, and line count.
  • Search narrowly before opening files.
  • Keep current documentation separate from archives.
  • Start a new session when the objective changes substantially.

These rules are not specific to one assistant. Any system that
accumulates tool results into a model’s working context benefits from
them.

The Failure Was Feedback

The crashes felt arbitrary because the limit was reached after many
unrelated actions. Once context was treated as a measurable resource,
the pattern became predictable.

The assistant had not become less capable. We had allowed the working
set to grow without bounds.

Complex projects do not require every artifact to be present at once.
They require a reliable way to retrieve the right artifact when needed.
That is the difference between a knowledge base and a pile.

The incident changed our workflow more than it changed the code. We
stopped asking the conversation to remember the project and started
making the project remember itself.