# An Agentic Flow for Finite State Machine Extraction using Prompt Chaining

arXiv: https://arxiv.org/abs/2507.11222 · HTML: https://mlsanity.com/paper/2507.11222/

## Key facts

- No citing papers in the map yet (data through 14 Oct 2026).
- Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use.
- Builds on 21 of its 37 references that are in the map.
- First posted on arXiv 15 Jul 2025.

## Placed in

- LLM agents and tool use / [Agent threats, guardrails and governance](https://mlsanity.com/agents/agent-threats-guardrails-and-governance/)

## Builds on (most cited first, 21 of 21)

- [Attention Is All You Need](https://mlsanity.com/paper/1706.03762/) (2017)
- [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://mlsanity.com/paper/2005.11401/) (2020)
- [ReAct: Synergizing Reasoning and Acting in Language Models](https://mlsanity.com/paper/2210.03629/) (2022)
- [Evaluating Large Language Models Trained on Code](https://mlsanity.com/paper/2107.03374/) (2021)
- [DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning](https://mlsanity.com/paper/2501.12948/) (2025)
- [Language Models can Solve Computer Tasks](https://mlsanity.com/paper/2303.17491/) (2023)
- [AI Chains: Transparent and Controllable Human-AI Interaction by Chaining Large Language Model Prompts](https://mlsanity.com/paper/2110.01691/) (2021)
- [PentestAgent: Incorporating LLM Agents to Automated Penetration Testing](https://mlsanity.com/paper/2411.05185/) (2024)
- [Augmenting Greybox Fuzzing with Generative AI](https://mlsanity.com/paper/2306.06782/) (2023)
- [Automated Attack Synthesis by Extracting Finite State Machines from Protocol Specification Documents](https://mlsanity.com/paper/2202.09470/) (2022)
- [Harnessing Large Language Models for Seed Generation in Greybox Fuzzing](https://mlsanity.com/paper/2411.18143/) (2024)
- [LLM-DaaS: LLM-driven Drone-as-a-Service Operations from Text User Requests](https://mlsanity.com/paper/2412.11672/) (2024)
- [FSM: A Finite State Machine Based Zero-Shot Prompting Paradigm for Multi-Hop Question Answering](https://mlsanity.com/paper/2407.02964/) (2024)
- [LMRPA: Large Language Model-Driven Efficient Robotic Process Automation for OCR](https://mlsanity.com/paper/2412.18063/) (2024)
- [ERPA: Efficient RPA Model Integrating OCR and LLMs for Intelligent Document Processing](https://mlsanity.com/paper/2412.19840/) (2024)
- [Can Large Language Models Help Developers with Robotic Finite State Machine Modification?](https://mlsanity.com/paper/2412.05625/) (2024)
- [LMV-RPA: Large Model Voting-based Robotic Process Automation](https://mlsanity.com/paper/2412.17965/) (2024)
- [Hermes: Unlocking Security Analysis of Cellular Network Protocols by Synthesizing Finite State Machines from Natural Language Specifications](https://mlsanity.com/paper/2310.04381/) (2023)
- [Retrieval Augmented Generation Based LLM Evaluation For Protocol State Machine Inference With Chain-of-Thought Reasoning](https://mlsanity.com/paper/2502.15727/) (2025)
- [State Selection Algorithms and Their Impact on The Performance of Stateful Network Protocol Fuzzing](https://mlsanity.com/paper/2112.15498/) (2021)
- [Extracting Protocol Format as State Machine via Controlled Static Loop Analysis](https://mlsanity.com/paper/2305.13483/) (2023)

## Abstract (arXiv)

Finite-State Machines (FSMs) are critical for modeling the operational logic of network protocols, enabling verification, analysis, and vulnerability discovery. However, existing FSM extraction techniques face limitations such as scalability, incomplete coverage, and ambiguity in natural language specifications. In this paper, we propose FlowFSM, a novel agentic framework that leverages Large Language Models (LLMs) combined with prompt chaining and chain-of-thought reasoning to extract accurate FSMs from raw RFC documents. FlowFSM systematically processes protocol specifications, identifies state transitions, and constructs structured rule-books by chaining agent outputs. Experimental evaluation across FTP and RTSP protocols demonstrates that FlowFSM achieves high extraction precision while minimizing hallucinated transitions, showing promising results. Our findings highlight the potential of agent-based LLM systems in the advancement of protocol analysis and FSM inference for cybersecurity and reverse engineering applications.
