TapeAgents: a Holistic Framework for Agent Development and Optimization

Dzmitry Bahdanau, Nicolas Gontier, Gabriel Huang, Ehsan Kamalloo, Rafael Pardinas, Alexandre Piché, Torsten Scholak, Oleh Shliazhko, Jordan Prince Tremblay, Karam Ghanem, Soham Parikh, Mitul Tiwari, Quaizar VohraarXiv 2024 · DOI · arXiv

TL;DR

This paper introduces TapeAgents, a novel framework for developing and optimizing Large Language Model (LLM) agents. By centralizing agent interactions and state within a structured "tape" (a detailed log), TapeAgents offers a unified approach for the entire agent development lifecycle, from debugging to optimization.

What Problem Does This Paper Address?

The increasing complexity and widespread deployment of LLM agents present significant challenges for AI practitioners. These agents operate in dynamic environments, exhibit non-deterministic behavior, and can be fragile in following instructions. Existing frameworks often focus on either rapid development (low-code) or advanced optimization (data-driven), but rarely bridge the gap between them. This leaves a need for a holistic framework that supports both the practical needs of agent developers (persistence, debugging) and the sophisticated requirements of optimization (auditing, fine-tuning, prompt-tuning).

Methods

TapeAgents is built around a core concept: the "tape." This tape is a granular, structured, and semantic-level log of an agent's session, serving as both its replayable state and a rich source of metadata.

  • Tape-Centric Design: Agents reason by processing the tape and LLM outputs, appending new "thought" and "action" steps to the tape. The environment, in turn, appends "observation" steps. This creates a continuous, replayable history.
  • Holistic Lifecycle Support:
    • Development: Tapes enable session persistence, agent auditing, and step-by-step debugging.
  • Optimization: Tapes facilitate evaluation, fine-tuning, and prompt-tuning. They allow for reusing and adapting tapes from other agents or historical sessions.
  • Modular Architecture: Agents are composed of "nodes," which are basic reasoning units. This modularity allows for flexible agent construction and fine-grained control flow.
  • Structured Metadata: The tape and agent configurations are rich in metadata, crucial for building developer tools and optimization algorithms.
  • Orchestration: A central orchestrator manages the alternating execution of agents and environments, ensuring smooth interaction and enabling resumption from any intermediate tape state.

Datasets

  • Synthetic Data Generation: The paper describes generating synthetic environments (companies and request forms) using Llama-3-70B-Instruct for training and evaluating form-filling agents.
  • GAIA Benchmark: Used for evaluating question-answering agents.
  • WorkArena Benchmark: Used for evaluating web-browsing agents.
  • HotpotQA: Used for prompt-tuning experiments.
  • Form-filling dialogues: A dataset of approximately 13k training and 13k test agent continuations per synthetic company was generated for training and evaluating the form-filling assistant.

Key Insights and Ideas

  • The "Tape" as a Unified Abstraction: The tape is the central innovation, acting as a universal log, state, and communication channel. This single abstraction simplifies debugging, replay, and optimization.
  • Bridging Development and Optimization: TapeAgents uniquely addresses the need for both developer-friendly tools (like session persistence) and advanced optimization capabilities (like data-driven prompt tuning) within a single framework.
  • Reusability of Tapes: The ability to reuse and adapt tapes across different agents or sessions is a powerful mechanism for accelerating development and improving agent performance.
  • Structured Logs Enable Optimization: The rich metadata within tapes and agent configurations makes it significantly easier to implement and apply data-driven optimization algorithms.
  • Cost-Effective Optimization: The case study demonstrates that by distilling a large, expensive "teacher" agent into a smaller, fine-tuned "student" agent using tapes, significant cost savings can be achieved with comparable performance.

Key Results

  • Form-Filling Assistant: A cost-effective form-filling assistant was developed using TapeAgents, achieving a GREADTH score of 76.6% with a single-node, fine-tuned Llama-3.1-8B agent. This student agent cost only $85/1M turns, a 300x saving compared to the teacher agent ($28,157/1M turns).
  • GAIA Benchmark: A TapeAgent achieved 33.2% test accuracy with GPT-40, competitive with other frameworks.
  • WorkArena Benchmark: A TapeAgent achieved 44.2% accuracy with GPT-40, competitive with other agents.
  • Prompt-Tuning Gains: Prompt-tuning using TapeAgents components led to significant gains in retrieval and answer accuracy on HotpotQA.
  • Finetuning Effectiveness: Finetuning a smaller model (Llama-3.1-8B) on teacher tapes significantly closed the performance gap with larger models, demonstrating the value of distillation.

Limitations and Future Work

  • Concurrent LLM Calls: TapeAgents currently lacks native support for concurrent LLM calls within an agent. The authors plan to address this by implementing coroutine support for agent loops and agent-environment orchestration.
  • Early Development Stage: TapeAgents is described as being in early development, with ongoing work on online RL trainers and text-based feedback propagation algorithms.
  • Agent vs. Workflow Distinction: The authors suggest that parts of a system intended for data-driven optimization should be treated as LLM Agents within TapeAgents, while other parts can be standard software.
  • Synthetic Data Generation: The paper envisions TapeAgents playing a role in generating synthetic data for training and evaluating complex agentic systems.

Summary updated

Abstract

We present TapeAgents, an agent framework built around a granular, structured log tape of the agent session that also plays the role of the session's resumable state. In TapeAgents we leverage tapes to facilitate all stages of the LLM Agent development lifecycle. The agent reasons by processing the tape and the LLM output to produce new thought and action steps and append them to the tape. The environment then reacts to the agent's actions by likewise appending observation steps to the tape. By virtue of this tape-centred design, TapeAgents can provide AI practitioners with holistic end-to-end support. At the development stage, tapes facilitate session persistence, agent auditing, and step-by-step debugging. Post-deployment, one can reuse tapes for evaluation, fine-tuning, and prompt-tuning; crucially, one can adapt tapes from other agents or use revised historical tapes. In this report, we explain the TapeAgents design in detail. We demonstrate possible applications of TapeAgents with several concrete examples of building monolithic agents and multi-agent teams, of optimizing agent prompts and finetuning the agent's LLM. We present tooling prototypes and report a case study where we use TapeAgents to finetune a Llama-3.1-8B form-filling assistant to perform as well as GPT-4o while being orders of magnitude cheaper. Lastly, our comparative analysis shows that TapeAgents's advantages over prior frameworks stem from our novel design of the LLM agent as a resumable, modular state machine with a structured configuration, that generates granular, structured logs and that can transform these logs into training text -- a unique combination of features absent in previous work.
BibTeX
@misc{bahdanau2024tapeagents,
  author = {Dzmitry Bahdanau and Nicolas Gontier and Gabriel Huang and Ehsan Kamalloo and Rafael Pardinas and Alexandre Piché and Torsten Scholak and Oleh Shliazhko and Jordan Prince Tremblay and Karam Ghanem and Soham Parikh and Mitul Tiwari and Quaizar Vohra},
  title = {{TapeAgents: a Holistic Framework for Agent Development and Optimization}},
  year = {2024},
  eprint = {2412.08445},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.08445},
}

Loading related content...

Figure