DEV Community

absterellio
absterellio

Posted on

Understanding AI Agent Architecture - Part 1

I'm currently reading AI Agents: The Definitive Guide by Nicole Koenigstein for a book club. In an effort to solidify my learnings and get the most out of the book, I'm noting things that stand out to me as I read through each chapter. Maybe this can also provide some quick knowledge to someone else who's interested in learning about AI agents :)

1. An AI agent is a model that "sits in a loop of reasoning, acting and feedback... A language model on its own is like a developer cut off from resources such as Stack Overflow, IDEs, or Github". This is why agents are so important - they use an LLM while providing the infrastructure of tools, resources, and looping it needs to become autonomous and helpful. LLMs alone are limited in their capabilities and output.

2. The design of agents can be represented as finite state machines (FSMs) and hierarchical state machines (HSMs). The book dives into the differences between the two in order to demonstrate the concept of agent architecture. A finite state machine "describes the modes your system can be in and the allowed transitions between them", representing a simpler architecture for single step to state mappings. HSMs, on the other hand, "let states contain other states". Hierarchical state machines allow for breaking down complex processes into many nodes but still encapsulating them as a single state. This is further demonstrated in code through LangGraph's representation of agents as subgraphs. More complex tool calling agents/multi-agent systems can be designed using HSMs. FSMs and HSMs provide "the conceptual foundation for agent design".

3. Tools, memory, and observability are important parts of an agent system. With LangChain, tools can be defined with the @tool decorator and bound to an agent. Memory can be saved so that the context isn't lost after each agent run. In LangGraph, agent state can be a TypedDict that keeps previous messages in a common structure for a current execution. Checkpoints can preserve this state across executions. Finally, to make sure the agent is functioning properly, using a function that builds a snapshot and is called after each execution step can make behavior, tool attachments, and usage much easier to verify.

4. The book points out that "agents are engineered systems. Their strength comes not from hidden magic, but from carefully designed workflows, well-defined tools, and the boundaries that keep them safe and usable". Although it's tempting to look at an agent as a magical system with full autonomy and unbounded reach, they are really just predefined systems acting in a loop with their given tools, instructions and boundaries. As the final paragraph notes, "constraints make agents safe, predictable, and practical to deploy".

My biggest takeaway from this chapter is a framework to better visualize the architecture of an agent under the hood using familiar software engineering concepts. I'm interested to seeing how the rest of the book builds on these concepts.

Thanks for reading!

Top comments (0)