FlowAgent: Achieving Compliance and Flexibility for Workflow Agents

Yuchen Shi, Siqi Cai, Zihan Xu, Yuei Qin, Gang Li, Hang Shao, Jiawei Chen, Deqing Yang, Ke Li, Xing SunarXiv 2025

Abstract

The integration of workflows with large language models (LLMs) enables LLM-based agents to execute predefined procedures, enhancing automation in real-world applications. Traditional rule-based methods tend to limit the inherent flexibility of LLMs, as their predefined execution paths restrict the models' action space, particularly when unexpected, out-of-workflow (OOW) queries are encountered. Conversely, prompt-based methods allow LLMs to fully control the flow, which can lead to diminished enforcement of procedural compliance. To address these challenges, we introduce FlowAgent, a novel agent framework designed to maintain both compliance and flexibility. We propose the Procedure Description Language (PDL), which combines the adaptability of natural language with the precision of code to formulate workflows. Building on PDL, we develop a comprehensive framework that empowers LLMs to manage OOW queries effectively, while keeping the execution path under the supervision of a set of controllers. Additionally, we present a new evaluation methodology to rigorously assess an LLM agent's ability to handle OOW scenarios, going beyond routine flow compliance tested in existing benchmarks. Experiments on three datasets demonstrate that FlowAgent not only adheres to workflows but also effectively manages OOW queries, highlighting its dual strengths in compliance and flexibility.

Introduction

In the development of AI agents, a persistent challenge is balancing compliance with flexibility. Traditional rule-based systems, such as deterministic state machines, ensure high compliance but are often brittle when faced with unexpected user inputs or "out-of-workflow" (OOW) queries. Conversely, prompt-based systems offer high flexibility but frequently fail to enforce procedural constraints, leading to "hallucinated" progress where agents claim to have completed tasks without executing the necessary underlying actions.

Methodology: The FlowAgent Framework

To resolve this tension, we propose FlowAgent, an architecture that combines a structured representation of workflows with dynamic execution controllers.

Procedure Description Language (PDL)

The core of FlowAgent is the Procedure Description Language (PDL). PDL is a hybrid syntax designed to bridge the gap between the rigidity of code and the ambiguity of natural language. It uses Pythonic structures (loops, conditionals, error handling) to define core logic while allowing semantic descriptions for individual nodes. A key feature of PDL is the inclusion of Precondition Specifications, which explicitly define dependencies—for example, preventing an agent from attempting to book an appointment before verifying the hospital's availability.

Comparison of workflow representations: (a) rule-based, (b) prompt-based, and (c) the proposed PDL workflow.

Dual-Controller Architecture

FlowAgent employs a two-stage control mechanism to supervise the LLM:

  1. Pre-decision Controllers: These analyze the current conversation state against the PDL and provide "soft" feedback to the LLM, identifying reachable nodes and guiding its reasoning.
  2. Post-decision Controllers: These act as "hard" constraints. If the LLM proposes an action that violates the workflow (e.g., skipping a prerequisite), the controller blocks the action and provides corrective feedback, forcing the model to realign with the defined procedure.

Experimental Evaluation

We evaluated FlowAgent across three datasets: SGD (Schema-Guided Dialogue), STAR, and a custom In-house Dataset featuring complex business workflows. To rigorously test flexibility, we introduced Out-of-Workflow (OOW) queries, categorized into intent switching, procedure jumping, and irrelevant user questions.

Results and Discussion

Experimental results demonstrate that FlowAgent consistently outperforms standard ReAct baselines across all tested dimensions.

Performance comparison across multiple datasets and OOW scenarios, showing FlowAgent's superior balance of compliance and flexibility.

On the In-house dataset, FlowAgent achieved a Success Rate of 67.72% (using GPT-4o), significantly higher than the 62.50% achieved by the best baseline. The advantage was most pronounced in OOW scenarios; in the In-house OOW test, FlowAgent maintained a 32.01% Success Rate, while baselines dropped to approximately 18%. These results indicate that FlowAgent effectively maintains task progress and compliance even when users deviate from the standard path.

Conclusion

FlowAgent addresses the critical trade-off between procedural adherence and conversational fluidity. By utilizing PDL and a dual-controller architecture, it provides a robust framework for deploying reliable AI agents in complex, real-world environments. Future work will focus on automating the generation of PDL from natural language descriptions and testing the system against real-world human interactions.

Summary updated

BibTeX
@misc{shi2025flowagent,
  author = {Yuchen Shi and Siqi Cai and Zihan Xu and Yuei Qin and Gang Li and Hang Shao and Jiawei Chen and Deqing Yang and Ke Li and Xing Sun},
  title = {{FlowAgent: Achieving Compliance and Flexibility for Workflow Agents}},
  year = {2025},
  eprint = {2502.14345},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2502.14345},
}
Figure