{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/stateflow-enhancing-llm-task-solving-through","title":"StateFlow: Enhancing LLM Task-Solving through State-Driven Workflows","arxiv_id":"2403.11322","date":"2024-03-17","proceeding":null,"authors":["Yiran Wu","Tianwei Yue","Shaokun Zhang","Chi Wang","Qingyun Wu"],"abstract":"It is a notable trend to use Large Language Models (LLMs) to tackle complex tasks, e.g., tasks that require a sequence of actions and dynamic interaction with tools and external environments. In this paper, we propose StateFlow, a novel LLM-based task-solving paradigm that conceptualizes complex task-solving processes as state machines. In StateFlow, we distinguish between \"process grounding\" (via state and state transitions) and \"sub-task solving\" (through actions within a state), enhancing control and interpretability of the task-solving procedure. A state represents the status of a running process. The transitions between states are controlled by heuristic rules or decisions made by the LLM, allowing for a dynamic and adaptive progression. Upon entering a state, a series of actions is executed, involving not only calling LLMs guided by different prompts, but also the utilization of external tools as needed. Our results show that StateFlow significantly enhances LLMs' efficiency. For instance, StateFlow achieves 13% and 28% higher success rates compared to ReAct in InterCode SQL and ALFWorld benchmark, with 5x and 3x less cost respectively. We also show that StateFlow can be combined with iterative refining methods like Reflexion to further improve performance.","url_abs":"https://arxiv.org/abs/2403.11322v5","url_pdf":"https://arxiv.org/pdf/2403.11322v5.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"stateflow-enhancing-llm-task-solving-through","repo_url":"https://github.com/kevin666aa/stateflow","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}},{"paper_slug":"stateflow-enhancing-llm-task-solving-through","repo_url":"https://github.com/yiranwu0/stateflow","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"none","reach":{"status":"ok"}}],"tasks":[{"task_slug":"management","task_name":"Management"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2403.11322","atlas_url":"https://app.syntology.ai/?focus=2403.11322","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.11322"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/yiranwu0/stateflow","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/kevin666aa/stateflow","reach":{"status":"ok"}}],"summary":{"ran":6,"ran_draft_wrong":1},"by_repo_kind":{"official":{"samples":7,"ran":7,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":7,"samples":[{"code_sha256_prefix":"88c3f0a98558ec2f","entry":"bleu_score","repo":"kevin666aa/stateflow","repo_kind":"official","path":"ALFWorld/src/chat_utils.py","file_url":"https://github.com/kevin666aa/stateflow/blob/HEAD/ALFWorld/src/chat_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"88c3f0a98558ec2f"}},{"code_sha256_prefix":"ca6caf87b63d4398","entry":"check_success","repo":"kevin666aa/stateflow","repo_kind":"official","path":"InterCode/experiments/flow_bash.py","file_url":"https://github.com/kevin666aa/stateflow/blob/HEAD/InterCode/experiments/flow_bash.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ca6caf87b63d4398"}},{"code_sha256_prefix":"0f432ceb9a38285e","entry":"get_summary","repo":"kevin666aa/stateflow","repo_kind":"official","path":"InterCode/experiments/analysis.py","file_url":"https://github.com/kevin666aa/stateflow/blob/HEAD/InterCode/experiments/analysis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0f432ceb9a38285e"}},{"code_sha256_prefix":"91f9ad6e6584206b","entry":"load_base_prompts","repo":"kevin666aa/stateflow","repo_kind":"official","path":"ALFWorld/src/chat_utils.py","file_url":"https://github.com/kevin666aa/stateflow/blob/HEAD/ALFWorld/src/chat_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"91f9ad6e6584206b"}},{"code_sha256_prefix":"ad7277e0c33fc9aa","entry":"load_prompts","repo":"kevin666aa/stateflow","repo_kind":"official","path":"ALFWorld/src/chat_utils.py","file_url":"https://github.com/kevin666aa/stateflow/blob/HEAD/ALFWorld/src/chat_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ad7277e0c33fc9aa"}},{"code_sha256_prefix":"97c0a864b7200ede","entry":"preprocess_sql","repo":"kevin666aa/stateflow","repo_kind":"official","path":"InterCode/experiments/eval_stateflow_bash.py","file_url":"https://github.com/kevin666aa/stateflow/blob/HEAD/InterCode/experiments/eval_stateflow_bash.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"97c0a864b7200ede"}},{"code_sha256_prefix":"fbd0a1980baa43a1","entry":"state_transition","repo":"kevin666aa/stateflow","repo_kind":"official","path":"InterCode/experiments/flow_bash.py","file_url":"https://github.com/kevin666aa/stateflow/blob/HEAD/InterCode/experiments/flow_bash.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"fbd0a1980baa43a1"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}