Stop Blaming the LLM: Why Your AI Agents Keep Failing (And How to Fix Them)
I was staring at a broken Next.js and Express backend integration late at night, convinced my AI agent had lost its mind. It was supposed to be a straightforward n8n automation pipeline. Yet, every time it ran, it hallucinated non-existent packages and dumped its context halfway through. My System 1 intuitive reaction flared up immediately: The LLM just isn't smart enough. I sat there, exhausted,…
The author encountered problems with an AI agent interacting with a Next.js and Express backend integration. The agent was hallucinating non-existent packages and losing context during execution. In a moment of frustration, the author blamed the model's intelligence, but upon reflection, realized the issue lay in a lack of infrastructure provisions.
The author coined the term "Harness Engineering" to describe the need for proper support structures around AI models. The model itself is just the engine; the harness provides the necessary framework, including context management, standardized tools, durable state, and strict verification.
To improve the agent's performance, the author restructured the workflow. Instead of providing the model with raw codebase dumps, targeted retrieval was implemented, limiting the context window to specific files needed for the task at hand. Model Context Protocol (MCP) servers were integrated to give the model secure, bounded ways to execute actions, replacing the model's tendency to generate text.
Durable state was introduced, allowing the system to checkpoint progress if a long-running workflow pauses or fails. This prevented the system from starting from scratch each time, enabling smoother resumption. Strict verification was also enforced, rejecting outputs like "Looks good to me" and requiring the agent to run tests and verify CLI output before concluding a task.
By focusing on harness engineering rather than just prompt engineering, the author transformed the fragile text generator into a dependable developer. The key takeaway is that while clever models are valuable, their autonomy depends on the reliable systems built around them. True autonomy requires engineers to learn to break the system they initially trusted and engineer a better one.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.