Abstract
Agentic workflows have become the dominant paradigm for building complex AI systems, orchestrating specialized components, such as planning, reasoning, action execution, and reflection, to tackle sophisticated real-world tasks. However, systematically analyzing and optimizing these workflows remains challenging due to intricate component interdependencies and the lack of principled attribution methods. In this work, we introduce ShapleyFlow, the first framework that employs cooperative game theory to analyze and optimize agentic workflows. By applying the Shapley value to evaluate all possible component configurations, ShapleyFlow enables fine-grained attribution of each component's contribution and facilitates the identification of task-specific optimal configurations. Through a constructed dataset evaluated across 7 scenarios, such as navigation, math and OS, we demonstrate 3 key contributions: (1) Theoretical Framework: a principled game-theoretic approach for the attribution of contributions in agentic workflows. (2) Optimal Workflow Discovery: ShapleyFlow identifies task-specific component configurations that consistently outperform workflows relying on a single LLM across all tested tasks. (3) Comprehensive Analysis: we construct and analyze over 1,500 tasks, providing actionable insights and design guidelines for optimizing workflows across multiple domains.
Introduction: The Attribution Problem in AI Agents
Modern AI agents are rarely simple prompt-and-response loops. Instead, they utilize complex, multi-step workflows that orchestrate specialized components: a Planner breaks down tasks, a Reasoner handles logic, an Actor executes tools, and a Reflector analyzes mistakes. While these frameworks (e.g., ReAct, AutoGPT) are powerful, they are often treated as "black boxes."
When an agent succeeds or fails, it is difficult to attribute the outcome to a specific component. Traditional ablation studies—removing one part at a time—fail to account for synergistic effects. For example, a Reflection component might only be useful if the Action component provides high-quality feedback. Without a principled way to attribute success, developers struggle to optimize agents or allocate computational resources effectively.
ShapleyFlow: A Game-Theoretic Approach to Workflow Optimization
To solve this attribution problem, we introduce ShapleyFlow, a framework that applies cooperative game theory—specifically the Shapley value—to agentic workflows.
In this model, the workflow is treated as a cooperative game where the "players" are the individual components: Planning (P), Reasoning (R), Action (A), and Reflection (F). ShapleyFlow evaluates the workflow's performance across all $2^4 = 16$ possible component combinations (coalitions). By calculating the Shapley value, the framework isolates the marginal contribution of each component across all possible orderings, mathematically accounting for both individual impact and non-linear synergies.
CapaBench: Benchmarking Capability-Level Coordination
To support this granular evaluation, we developed CapaBench (Capability-level Assessment Benchmark). It contains over 1,500 tasks across seven domains: Shopping, Navigation, Ticket Ordering, Math, Automatic Theorem Proving (ATP), Operating Systems (OS), and Robot Cooperation.
Unlike traditional benchmarks that focus on end-to-end success, CapaBench is explicitly designed to require meaningful coordination between P, R, A, and F. This allows ShapleyFlow to disentangle their effects and identify which capabilities are most critical for specific types of tasks.
Key Insights: Specialization and Synergy
Our analysis using ShapleyFlow yielded several actionable insights for agent design:
- Task-Specific Specialization: There is no universal "best" workflow. Dynamic tasks like OS navigation rely heavily on Reasoning to adapt to environmental changes. In contrast, precision-critical tasks like Math are dominated by the Action component, requiring exact procedural execution.
- The "Reflection" Illusion: Surprisingly, Reflection consistently showed the lowest Shapley values. Identifying an error does not guarantee the ability to fix it; without a highly capable model guiding the reflection, it often fails to drive performance improvements.
- The Power of "Frankenstein" Workflows: By identifying which LLM (e.g., Llama 3, Claude 3.5 Sonnet, or GPT-4o) is best suited for which component via Shapley values, we can create composite workflows. These optimized "Frankenstein" systems consistently outperform single state-of-the-art models used for the entire pipeline.
Results and Future Directions
Optimized workflows achieved significant gains, such as 43.31% accuracy in e-commerce and 86.79% in formal verification. ShapleyFlow also revealed that upgrading a single component can have outsized effects; for instance, swapping a baseline for Claude-3.5-Sonnet in Ticket Ordering improved accuracy by +42.91%, driven primarily by its superior Reasoning and Action capabilities.
While calculating exact Shapley values is computationally expensive as the number of components grows, future work will explore approximation techniques like KernelSHAP. This will allow for the analysis of even more granular workflows with dozens of specialized micro-agents.
Summary updated