Learning agentic AI from scratch when you already know systems
AI
Systems engineers already have the right mental models for agentic AI. Learn how principles of state machines, transaction logs, and idempotency from distributed systems directly apply to building rel
The first time I saw a multi-step AI agent fail, it was not the failure that surprised me. It was how familiar it felt. The agent got stuck in a loop, repeatedly calling a tool with slightly malformed input, convinced it was making progress. It looked less like a glimpse of the future and more like a buggy message handler from a decade ago, pulling the same poisoned pill off a queue over and over again.
That was the moment the hype fell away. Building these systems is not some arcane new art. It is distributed systems engineering with a new, probabilistic component. If you have spent years making disparate services talk to each other reliably, you already have the mental scaffolding to build agents that actually work.
Agents Are State Machines with Fuzzy Transitions
Any useful agent is trying to accomplish a task that requires multiple steps. It has a goal, a set of tools, and it must figure out the sequence. When you strip it down, this is a finite state machine. The agent is in a state—say, "gathering initial data"—and based on input, it performs an action to move to a new state. The core of this loop often follows a pattern like ReAct, or "Reason and Act," first explored by researchers like Yao et al.
In traditional software, state transitions are deterministic. If event X happens in state A, you always go to state B. The challenge with LLM-based agents is that the transition logic is fuzzy. The LLM decides the next state, and its output is nondeterministic. Given the same history, it might choose one tool this time and another the next.
Thinking of it as a state machine immediately clarifies the real work. The job is not just writing a clever prompt; it is validating the transitions. This is not just a metaphor; it is a production pattern. Libraries like LangChain's LangGraph are explicitly designed to build agents as state graphs, providing a deterministic structure for the LLM's fuzzy logic. Our deterministic code around the LLM is what grants the system its reliability.
The Context Window Is a Transaction Log
Every modern agent framework manages a history of the interaction—user prompts, agent thoughts, tool outputs. This history, sent with every new LLM call, is the agent's memory. In systems architecture, we have a pattern for this: the transaction log or event stream.
When I started viewing the context window not as a "conversation" but as an append-only log, the design trade-offs became clear. Sending the full, ever-growing history is like replaying an entire event stream for every decision. It ensures perfect recall but is slow, expensive, and eventually hits a hard limit.
This is the same problem data engineers face with event sourcing. The solutions are also analogous.
- Summarization: An agent that periodically summarizes the history is performing log compaction. It trades perfect fidelity for a compressed state that is cheaper to process.
- Windowing: Keeping only the last N tokens is like maintaining a sliding window over a stream. It is efficient but risks losing crucial early context.
- Vector Search: Retrieving relevant snippets from a vector database is like querying an indexed, materialized view of the log.
These are data management patterns applied to a new type of data. The right choice depends on the same old factors: cost, latency, and consistency requirements.
Idempotency and Retries Are Still King
An agent's interaction with the world is through its tools, which are just APIs. And APIs fail. They time out, return 503 errors, or suffer network blips. An agent that cannot handle transient failures is a toy, not a production system.
This brings us back to the bedrock principles of microservices. When an agent decides to call a tool, that action must be durable. If the call fails, it must be able to retry safely. This means the underlying tool must be idempotent. Calling create_user(id: 123) twice should have the same result as calling it once.
I have seen agent designs that treat a tool call as a simple function. This is a mistake. It should be treated as a task dispatched to a worker, wrapped with battle-tested patterns like exponential backoff, circuit breakers, and dead-letter queues. This layer of deterministic, reliable execution is what separates a demo from a system you can depend on.
Where the Analogy Bends: Semantic Failure
The analogy to traditional systems is powerful, but it is not perfect. There is one class of failure that is genuinely new: semantic failure. A traditional system fails in knowable ways, like a null pointer or an HTTP 404. An LLM agent can fail more strangely. It can appear to succeed while doing the completely wrong thing. It does not crash; it just drifts off course with complete confidence.
This is the most significant new challenge we face. Our observability cannot just be about CPU usage, latency, and error counts. We must monitor for "semantic drift." This has led to formal techniques like "LLM-as-a-Judge," a concept detailed by researchers like Zheng et al., to automate the evaluation of an agent’s output using another model. We must build validation that operates at a higher level of abstraction.
Your Systems Intuition Is Your Guide
The fundamentals of engineering have not been repealed. An agent is a stateful, event-driven application that orchestrates calls to other services over an unreliable network. The core principles for building robust software still apply.
- Wrap the stochastic core in a deterministic shell. The LLM is for reasoning. Your code is for validation, state management, and error handling.
- Treat agent memory like a data stream. Apply proven data engineering patterns to manage cost and performance.
- Build tools like any other API. They need to be reliable, observable, and, above all, idempotent.
- Plan for semantic failure. Acknowledge that an agent can fail without crashing, and build validation to catch it.
If you come from a background in systems engineering, you are better equipped than you think. The hard-won intuition for how systems break, how to manage state, and how to build for resilience is not obsolete. It is the most valuable asset you have for turning AI's potential into production reality.