DEV Community

Nathaniel Hamlett
Nathaniel Hamlett

Posted on • Originally published at nathanhamlett.com

Production AI Agents Don't Work Like You Think: Architecture Patterns That Actually Scale

There's a gap between how AI agents are demoed and how they're actually deployed at scale.

The demo version: one big model with 30 tools attached, given a goal, and told to "figure it out." Impressive for 90 seconds. Unreliable in production.

The production version looks almost nothing like that. And understanding the difference matters—not just for engineers, but for anyone trying to deploy autonomous AI systems that keep working instead of degrading after a week.

Why Monolithic Agents Fail in Production

The appeal of a single, powerful model with access to everything is obvious. But in practice, monolithic agents hit predictable walls:

Context window saturation. When you give a model 30+ tools, the context required to reason about which tool to use and maintain task state and track history starts consuming your available window. By the time you're on step 8 of a 12-step task, performance has already degraded.

Tool selection drift. Studies on production agent deployments show accuracy drops sharply after ~15 available tools. The model starts making worse choices—not because the model is bad, but because the selection problem becomes harder than the actual task.

No control surfaces. If something goes wrong in a monolithic agent mid-run, you have limited options: let it finish, kill it, or hope the retry logic handles it. There's no clean place to interrupt, review, or redirect.

Two Patterns That Actually Work

By 2026, production AI systems have largely converged on two architectures:

1. Multi-Agent Graphs (Agentic Workflows)

Frameworks like LangGraph and AutoGen implement this pattern: a directed graph where each node is a specialized agent (often a smaller, cheaper model) with a narrow task. The graph defines the flow explicitly.

The strengths: predictability, parallelism, auditability. You can run multiple branches simultaneously. You can inspect the state at any edge. Failures are localized.

The weaknesses: rigidity. Graph-based systems require you to specify the decision tree in advance. Novel situations fall off the edges. They're excellent for enterprise workflows where the process is known and stable—less useful for exploratory or adaptive tasks.

2. LLM Skills (Modular Extensions)

The other dominant pattern: a core generalist model augmented with dynamically loaded "skills"—structured knowledge and code templates that load contextually based on task type.

Instead of a model choosing from 30 tools, it operates with a small core toolset and loads a skill only when that skill is relevant. The skill provides domain context, templates, constraints, and specific tool patterns—without permanently bloating the base context.

This is the architecture I've been running in my own pipeline: a core model (Claude Sonnet/Opus for conversation and orchestration, Gemini for bulk research) with 34+ targeted skills that load based on pipeline state and trigger keywords.

The cron and heartbeat system acts as a lightweight orchestrator—triggering specific skills based on database state rather than relying on the LLM to constantly re-plan its day. That "constant re-planning" burns tokens, introduces latency, and creates unpredictable execution paths.

The Memory Layer Is Where Most Agents Fall Apart

Every production agent architecture has to answer the same question: what does the agent remember, and how does it retrieve it?

Most tutorials skip this entirely. Most demos use in-context "memory" (just stuffing prior messages back in). That works for demos. It doesn't work when your agent has been running for six months.

A functional memory architecture needs at least three layers:

Short-term: Session state and recent actions. For most systems, this is a combination of in-context history and a lightweight log file.

Episodic/Structured: A queryable record of what happened. SQL is underrated here—a SQLite pipeline database with timestamped events, stage transitions, and outcome tracking gives you something you can actually query and reason over. Vector databases are powerful for semantic retrieval but add operational complexity.

Long-term/Semantic: The hardest layer. How does the agent know what it knows without stuffing everything in context? The most practical current approach is structured markdown (curated knowledge files) combined with keyword-triggered loading. Semantic caching and local embedding search (sqlite-vss or Chroma) are the next step for systems that need it.

The failure mode to avoid: treating memory as a flat append-only log that grows until it breaks things. Memory needs a decay function, a curation process, and selective retrieval—not just accumulation.

Human-in-the-Loop Isn't a Safety Net—It's a Design Pattern

The enterprise world is currently struggling to implement meaningful human oversight of AI agents. Most "HITL" implementations are either too aggressive (interrupt on everything, agents become useless) or too passive (approve in bulk, oversight is theater).

The pattern that works: classify actions before execution, not after.

Every action the agent can take gets assigned to a class: autonomous (execute immediately), approval-required (draft and queue for human review), or hard-banned (never attempt). The model knows this classification and structures its behavior around it.

In my system, this looks like:

  • Class 1: Research, analysis, file writes, internal scans. Execute immediately.
  • Class 2: Anything external-facing—sending messages, submitting applications, publishing content. Draft thoroughly, send to Telegram for approval, wait for explicit confirm.
  • Class 3: Legal commitments, financial transactions, identity-sensitive actions. Hard-banned.

The result: the agent moves fast on internal work while maintaining a clean audit trail of every external action, with human decision points exactly where they matter.

The Observability Problem Nobody Talks About

Production agents fail silently. A scan returns zero results. A submission gets a 428. An API key expires. Most systems either surface nothing or surface everything—neither is useful.

What actually works: structured logging with categorized failure modes, a human-readable daily summary, and push notifications for things that need attention. The agent should know the difference between a transient failure (retry in 30 minutes) and a structural failure (needs a code change) and surface them differently.

Telegram briefings for attention-required items, daily notes for full context, and a SQLite audit table for everything else has worked well in practice.

What This Means If You're Building

The lessons from running a production agent system for several months:

  1. Narrow the toolset. A model with 8 highly relevant tools outperforms one with 30 generic tools.
  2. Make state explicit. Relying on the model to maintain implicit state across long sessions is fragile. Write it to a database or a file.
  3. Classify before execute. Build your action classification system first. Everything else plugs into it.
  4. Plan for memory debt. Your context-stuffing approach works until it doesn't. Design the memory layer early.
  5. Instrument everything. You can't improve what you can't measure. Log outcomes, not just actions.

The gap between "impressive demo" and "still running in 3 months" is almost entirely architectural. The intelligence of the underlying model matters less than most people think. The scaffolding around it matters a lot.

Top comments (0)