{"slug": "your-ai-agents-need-finite-state-machines-fsms", "title": "Your AI Agents Need Finite State Machines (FSMs)", "summary": "A developer argues that finite state machines (FSMs) should replace autonomous agents for business-critical AI workflows, as FSMs make business processes explicit and verifiable rather than relying on prompts and emergent agent behavior. The developer states: 'The workflow provides the boundaries. The AI provides the intelligence.'", "body_md": "In [my previous article](https://dev.to/remojansen/from-rigidity-to-explicitness-how-ai-changes-the-role-of-constraints-in-software-5cp5), I argued that AI changes the role of constraints in software development.\n\nFor years, many developers saw constraints as something to minimize. Dynamic languages gained popularity over static ones. Schema-less databases promised greater flexibility. Convention replaced configuration. Implicit behavior was often preferred over explicit definitions.\n\nThe motivation was understandable. Constraints felt like friction. They slowed us down. AI changes that trade-off.\n\nToday, every explicit constraint becomes valuable context that AI can use to better understand our systems.\n\nA database schema is no longer just a validation mechanism. It describes the structure and meaning of the data.\n\nAn OpenAPI specification is no longer just a contract between services. It tells an AI how those services are expected to interact.\n\nA type definition is no longer only for the compiler. It helps AI understand the intent behind an API.\n\nConstraints haven't become valuable because they prevent mistakes. They've become valuable because they communicate knowledge. I believe the same principle applies beyond software development. It applies to business workflows.\n\nThere is enormous excitement around AI-powered workflow automation. Most current approaches are based on autonomous agents. An agent receives a request, reasons about the situation, selects tools, executes actions, and decides what should happen next.\n\nFor simple workflows, this can work remarkably well. For business-critical workflows, however, this architecture introduces unnecessary operational risk.\n\nThe AI is not only performing work. It is also responsible for discovering the business process while executing it. That is asking a probabilistic system to infer something that should already be known.\n\nBusiness workflows contain rules that are independent of AI:\n\nThese are not AI problems. They are business rules. And business rules should not live inside prompts.\n\nWhen AI workflows become more complex, the common solution is to add more agents.\n\nA planner agent coordinates execution.\n\nSpecialized agents perform individual tasks.\n\nValidation agents review the results.\n\nPrompts become increasingly sophisticated. Yet the workflow itself often remains implicit. The workflow exists only through prompts, examples and emergent agent behavior.\n\nThis makes the process:\n\nDifficult to understand.\n\nDifficult to test.\n\nDifficult to audit.\n\nAlmost impossible to verify.\n\nBusiness processes deserve a better foundation.\n\nInstead of asking AI to infer the workflow, define the workflow explicitly.\n\nOne of the simplest and most powerful ways to do this is with a finite state machine.\n\nA finite state machine explicitly models:\n\nFor example, a purchase approval process could look like this:\n\n```\nDraft\n  ↓\nSubmitted\n  ↓\nApproved\n  ↓\nPurchased\n```\n\nWhen the process is in the **Submitted** state, the workflow might expose exactly three valid transitions:\n\nThe AI no longer has to invent the workflow. The workflow itself defines what is possible. The AI only has to determine which of the valid actions is the most appropriate. The workflow provides the boundaries. The AI provides the intelligence.\n\nThe value of the finite state machine is not simply that it constrains the AI.\n\nIt makes the business process explicit.\n\nThe AI immediately knows:\n\nInstead of inferring the workflow from prompts, examples, or previous executions, it receives a precise description of the process.\n\nJust as an OpenAPI specification helps AI understand an API, a finite state machine helps AI understand a business process.\n\nIn both cases, explicit constraints become high-quality context.\n\nThis is where finite state machines become particularly interesting.\n\nUnlike a prompt, an FSM is a formal model.\n\nThat means it is not only explicit.\n\nIt is verifiable.\n\nBefore an AI agent ever executes the workflow, we can analyze the model and answer questions like:\n\nThese are properties that can be verified independently of the AI. This is a fundamental difference from prompt-driven workflows. A prompt describes a process. A finite state machine defines and constrains a process. The FSM becomes an executable safety boundary around the AI.\n\nThe objective is not to make AI deterministic.\n\nThat is impossible.\n\nThe objective is to make the environment in which AI operates deterministic.\n\nWithout an explicit workflow, the AI constantly asks:\n\nWhat should happen next?\n\nWith an FSM, the conversation changes.\n\nThe workflow says:\n\nThese are the only valid actions that can happen next.\n\nThe AI answers:\n\nGiven these valid options, which one is the most appropriate?\n\nThis is a subtle but profound architectural shift.\n\nThe AI no longer owns the workflow.\n\nIt navigates the workflow.\n\nThis model becomes even more powerful when exposed through MCP.\n\nInstead of exposing dozens of low-level tools, the workflow exposes its current state and the transitions that are currently available.\n\nAn AI agent can discover:\n\nThe workflow becomes self-describing. Changing the business process means updating the workflow model. Not rewriting prompts. The AI automatically receives the new constraints as part of its context.\n\nLarge language models are probabilistic. Business processes should not be. A finite state machine does not make the AI smarter. It makes the overall system safer.\n\nBy limiting the AI to explicitly defined transitions, we drastically reduce the operational risks of AI-driven workflow automation.\n\nInvalid transitions become impossible.\n\nEvery state change is verifiable.\n\nEvery decision is auditable.\n\nRollback becomes part of the workflow instead of an afterthought.\n\nCompliance rules become explicit instead of implicit.\n\nMost importantly, the AI no longer decides what is possible. It decides how to navigate a process whose boundaries have already been defined.\n\nThis is the same principle I discussed in my previous article.\n\nExplicit schemas help AI understand data.\n\nExplicit contracts help AI understand APIs.\n\nExplicit types help AI understand code.\n\nExplicit workflows help AI understand business processes.\n\nThe value does not come from adding more constraints. It comes from making the right constraints explicit.\n\nAs AI becomes increasingly responsible for business operations, I believe we will rely less on autonomous agents trying to infer business processes and more on explicit workflow models that define those processes in a way that both humans and AI can understand.\n\nThe future of AI workflow automation is not unlimited autonomy. It is controlled autonomy. AI provides intelligence. Explicit, verifiable workflow models provide correctness. The role of AI is not to own the workflow. Its role is to navigate it intelligently.\n\nAnd that is where constraints stop being friction and start becoming business value.", "url": "https://wpnews.pro/news/your-ai-agents-need-finite-state-machines-fsms", "canonical_source": "https://dev.to/remojansen/your-ai-agents-need-finite-state-machines-fsms-2i9j", "published_at": "2026-07-28 23:40:17+00:00", "updated_at": "2026-07-29 00:01:03.066620+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "developer-tools"], "entities": [], "alternates": {"html": "https://wpnews.pro/news/your-ai-agents-need-finite-state-machines-fsms", "markdown": "https://wpnews.pro/news/your-ai-agents-need-finite-state-machines-fsms.md", "text": "https://wpnews.pro/news/your-ai-agents-need-finite-state-machines-fsms.txt", "jsonld": "https://wpnews.pro/news/your-ai-agents-need-finite-state-machines-fsms.jsonld"}}