AgentKit: Flow Engineering with Graphs, not Coding

Yue Wu, Yewen Fan, So Yeon Min, Shrimai Prabhumoye, Stephen McAleer, Yonatan Bisk, Ruslan Salakhutdinov, Yuanzhi Li, Tom M. Mitchell

Abstract

We propose an intuitive LLM prompting framework (AgentKit) for multifunctional agents. AgentKit offers a unified framework for explicitly constructing a complex "thought process" from simple natural language prompts. The basic building block in AgentKit is a node, containing a natural language prompt for a specific subtask. The user then puts together chains of nodes, like stacking LEGO pieces. The chains of nodes can be designed to explicitly enforce a naturally structured "thought process". For example, for the task of writing a paper, one may start with the thought process of 1) identify a core message, 2) identify prior research gaps, etc. The nodes in AgentKit can be designed and combined in different ways to implement multiple advanced capabilities including on-the-fly hierarchical planning, reflection, and learning from interactions. In addition, due to the modular nature and the intuitive design to simulate explicit human thought process, a basic agent could be implemented as simple as a list of prompts for the subtasks and therefore could be designed and tuned by someone without any programming experience. Quantitatively, we show that agents designed through AgentKit achieve SOTA performance on WebShop and Crafter. These advances underscore AgentKit's potential in making LLM agents effective and accessible for a wider range of applications.

Introduction

Large Language Models (LLMs) are remarkably capable, but they often struggle when a task requires following a strict, multi-step procedure over a long period. If an LLM makes one small error early in a complex reasoning chain, that error tends to snowball, leading to total failure. To solve this, researchers have typically turned to "code-based" agents, but these require significant programming expertise and are often brittle.

AgentKit, presented at COLM 2024, offers a middle ground. It allows users to "program" complex agent behavior using structured graphs of natural language prompts rather than thousands of lines of code. By treating individual subtasks as "nodes" that can be stacked like LEGO pieces, it enables the creation of sophisticated agents that can plan, reflect, and learn.

The AgentKit Framework

The core of AgentKit is the Node. Each node represents a specific subtask (e.g., "Identify the intentions of nearby pedestrians" or "Check inventory for wood"). Unlike traditional prompting, which often relies on long, monolithic instructions or many-shot examples, AgentKit breaks the problem down into a directed acyclic graph (DAG) of manageable thoughts.

Figure 2: AgentKit workflow vs. traditional prompting. AgentKit uses a graph-based process design to structure LLM execution.

The Workflow of a Node

  1. Compose: The node gathers inputs from its "dependency" nodes (previous steps) and a central database to create a single prompt.
  2. Query: The LLM processes the prompt.
  3. After-query: An optional step where the output is parsed (e.g., into JSON) or used to update the database.

Dynamic Graphs and "Coding" with Prompts

What makes AgentKit "dynamic" is its ability to modify its own structure at inference time. Using an API, an LLM can decide to add temporary nodes or implement conditional branching (e.g., "If the plan is still valid, skip the planning nodes to save tokens"). The system uses Kahn’s Algorithm to ensure all nodes are evaluated in the correct topological order, ensuring that no subtask is performed before its prerequisites are met.

Because the logic is contained within natural language prompts rather than complex code, a basic agent can be implemented with minimal programming knowledge. The graph structure provides modular interpretability: if an agent fails, a user can identify the specific node that produced the error and fix it by simply editing the prompt.

Figure 1: Python implementation of an AgentKit graph. Subtasks are defined as natural language strings and linked via simple graph edges.

Evaluation and Key Results

The researchers evaluated AgentKit on two challenging environments: Crafter (an open-world survival game) and WebShop (a simulated e-commerce platform).

  • Crafter SOTA: AgentKit achieved a reward score of 12.8, surpassing previous LLM-based leaders like SPRING (12.3). Notably, it was 45% cheaper to run than the GPT-4 version of SPRING while being significantly more consistent.
  • WebShop Success: On the WebShop benchmark, a simple 6-node AgentKit agent achieved a score of 70.2%, outperforming the previous state-of-the-art (ReAct) by roughly 5%.
  • Efficiency through Gating: In the Crafter agent, a "gate" node checks if the current plan is still valid. If it is, the agent skips expensive planning and reflection nodes, reducing token usage by over 30%.

Conclusion

AgentKit moves away from the "black box" nature of long-form prompting by explicitly mapping out a "thought process" as a graph. It allows users to "code" an agent's logic using intuitive instructions, making advanced agent design accessible to non-programmers. While challenges remain regarding query costs and manual graph design, AgentKit demonstrates that structured flow engineering is a powerful path toward more reliable and interpretable AI agents.

Summary updated

BibTeX
@inproceedings{wu2024agentkit,
  author = {Yue Wu and Yewen Fan and So Yeon Min and Shrimai Prabhumoye and Stephen McAleer and Yonatan Bisk and Ruslan Salakhutdinov and Yuanzhi Li and Tom M. Mitchell},
  title = {{AgentKit: Flow Engineering with Graphs, not Coding}},
  booktitle = {COLM},
  year = {2024},
  url = {https://openreview.net/forum?id=PKfAq8N4fK},
}
Figure