arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2607.01640cs.SEcs.CR
收藏

AgentFlow:构建用于智能体程序静态分析的智能体依赖图

AgentFlow: Building Agent Dependency Graphs for Static Analysis of Agent Programs

Huazhong University of Science and Technology(华中科技大学);Macquarie University(麦考瑞大学)

Shenao Wang, Xinyi Hou, Yanjie Zhao, Xiao Cheng, Haoyu Wang

AI总结:

提出AgentFlow,首个从智能体程序中恢复和分析智能体依赖的静态分析框架,通过构建框架无关的智能体依赖图(ADG)支持智能体治理和安全分析,在5399个真实程序中验证了其有效性。

摘要:

LLM智能体越来越多地作为基于智能体框架构建的源代码应用程序进行开发。这些智能体程序将传统宿主语言代码与框架定义的语义(用于模型、提示、工具、记忆和多智能体编排逻辑)相结合。因此,它们的行为不仅依赖于传统的控制流和数据流,还依赖于一类新的智能体依赖。这些依赖通常以框架诱导的语义形式表达,例如智能体构造函数、工具装饰器和智能体交接声明,这使得现有的静态分析或依赖跟踪工具难以恢复它们。在本文中,我们提出了AgentFlow,这是第一个用于从智能体程序中恢复和分析智能体依赖的静态分析框架。AgentFlow构建了智能体依赖图(ADG),这是一种框架无关的图表示,将智能体、提示、模型、能力、记忆状态和控制策略表示为类型化节点,并将它们的组件依赖、控制流和数据流依赖捕获为类型化边。基于ADG,AgentFlow支持一系列用于智能体治理和安全性的分析,包括智能体物料清单(BOM)生成和提示到工具的风险检测。我们为五个代表性智能体框架实现了AgentFlow,并在AgentZoo(一个包含5,399个真实世界智能体程序的语料库)上进行了评估。我们的评估表明,AgentFlow比现有的基于AST的智能体静态分析工具恢复了更丰富的智能体实体和依赖,生成了更具依赖感知能力的智能体BOM,并在真实世界智能体程序中发现了238个污点风格的提示到工具风险。这些结果表明,ADG为理解、治理和保护新兴的智能体软件提供了实用基础。

英文摘要:

LLM agents are increasingly developed as source-code applications built on agent frameworks. These agent programs combine conventional host-language code with framework-defined semantics for models, prompts, tools, memory, and multi-agent orchestration logic. As a result, their behavior depends not only on traditional control and data flows, but also on a new class of agent dependencies. Such dependencies are often expressed as framework-induced semantics, such as agent constructors, tool decorators, and agent handoff declarations, making them difficult to recover with existing static analysis or dependency tracking tools. In this paper, we present AgentFlow, the first static analysis framework for recovering and analyzing agent dependencies from agent programs. AgentFlow constructs an Agent Dependency Graph (ADG), a framework-agnostic graph representation that represents agents, prompts, models, capabilities, memory states, and control policies as typed nodes, and captures their component-dependency, control-flow, and data-flow dependencies as typed edges. Built on ADGs, AgentFlow supports a range of analyses for agent governance and security, including Agent Bill of Materials (BOM) generation and prompt-to-tool risk detection. We implement AgentFlow for five representative agent frameworks and evaluate it on AgentZoo, a corpus of 5,399 real-world agent programs. Our evaluation shows that AgentFlow recovers richer agent entities and dependencies than existing AST-based agent static analysis tools, generates more dependency-aware Agent BOMs, and uncovers 238 taint-style prompt-to-tool risks in real-world agent programs. These results show that ADG provides a practical foundation for understanding, governing, and securing emerging agent software.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑