For a long time I was confused about agents. Every week a new framework appears: LangGraph. AutoGen. CrewAI. OpenAI Agents SDK. Claude Agents SDK. All of them show you how to run agents. But none of them really explain how to think about building one. So I spent a while trying to simplify this for myself after talk to claude for 3 hours. The mental model that finally clicked: Agents are finite state machines where the LLM decides the transitions. Here’s what I mean. Start with graph theory. A graph is just: nodes + edges A finite state machine is a graph where: nodes = states edges = transitions (with conditions) An agent is almost the same thing, with one difference. Instead of hardcoding: if output[“status”] == “done”: go_to_next_state() The LLM decides which transition to take based on its output. So the structure looks like this: Prompt: Orchestrator ↓ (LLM decides) Prompt: Analyze ↓ (always) Prompt: Summarize ↓ (conditional — loop back if not good enough) Prompt: Analyze ← back here Notice I’m calling every node a Prompt, not a Step or a Task. That’s intentional. Every state in an agent is fundamentally a prompt. Tools, memory, output format — these are all attachments to the prompt, not peers of it. The prompt is the first-class citizen. Everything else is metadata or tools (human input, mcp, memory etcc). Once I started thinking about agents this way, a lot clicked:
- Why LangGraph literally uses graphs
- Why agents sometimes loop forever (the transition condition never fires)
- Why debugging agents is hard (you can’t see which state you’re in)
- Why prompts matter so much (they ARE the states) But it also revealed something I hadn’t noticed before. There are dozens of tools for running agents. Almost nothing for designing them. Before you write any code, you need to answer:
- How many prompt states does this agent have?
- What are the transition conditions between them?
- Which transitions are hardcoded vs LLM-decided?
- Where are the loops, and when do they terminate?
- Which tools attach to which prompt? Right now you do this in your head, or in a graph with no agent-specific structure. The design layer is a gap nobody has filled yet. Anyway, if you’re building agents and feeling like something is missing, this framing might help. Happy to go deeper on any part of this. submitted by /u/Main-Fisherman-2075
Originally posted by u/Main-Fisherman-2075 on r/ClaudeCode
