TapeAgents framework for building, tuning and evaluating LLM Agents
Project description
TapeAgents
TapeAgents is a framework that leverages a structured, replayable log (Tape) of the agent session to facilitate all stages of the LLM Agent development lifecycle. In TapeAgents, the agent reasons by processing the tape and the LLM output to produce new thoughts, actions, control flow steps and append them to the tape. The environment then reacts to the agent’s actions by likewise appending observation steps to the tape.
Why TapeAgents
Key features:
- Build your agent as a low-level state machine, as a high-level multi-agent team configuration, or as a mono-agent guided by multiple prompts
- Debug your agent with TapeAgent studio or TapeBrowser apps
- Serve your agent with response streaming
- Optimize your agent's configuration using successful tapes; finetune the LLM using revised tapes.
The Tape-centric design of TapeAgents will help you at all stages of your project:
- Build with ultimate flexibility of having access to tape for making prompts and generating next steps
- Change your prompts or team structure and resume the debug session as long as the new agent can continue from the older tape
- Fully control the Agent's tape and the Agent's acting when you use a TapeAgent in an app
- Optimize tapes and agents using the carefully crafted metadata structure that links together tapes, steps, llm calls and agent configurations
TapeAgents at a glance
Getting Started
Tutorial
Start with the introductory Jupyter notebook to quickly learn the core concepts of the framework.
Hello TapeAgents
The simplest agent just to show the basic structure of the agent:
from tapeagents.agent import Agent, Node
from tapeagents.core import Prompt
from tapeagents.dialog_tape import AssistantStep, UserStep, DialogTape
from tapeagents.llms import LLMStream, LiteLLM
from tapeagents.prompting import tape_to_messages
llm = LiteLLM(model_name="gpt-4o-mini")
class MainNode(Node):
def make_prompt(self, agent: Agent, tape: DialogTape) -> Prompt:
# Render the whole tape into the prompt, each step is converted to message
return Prompt(messages=tape_to_messages(tape))
def generate_steps(self, agent: Agent, tape: DialogTape, llm_stream: LLMStream):
# Generate single tape step from the LLM output messages stream.
yield AssistantStep(content=llm_stream.get_text())
agent = Agent[DialogTape].create(llm, nodes=[MainNode()])
start_tape = DialogTape(steps=[UserStep(content="Tell me about Montreal in 3 sentences")])
final_tape = agent.run(start_tape).get_final_tape() # agent will start executing the first node
print(f"Final tape: {final_tape.model_dump_json(indent=2)}")
TapeAgents Examples
The examples/ directory contains examples of how to use the TapeAgents framework for building, debugging, serving and improving agents. Each example is a self-contained Python script (or module) that demonstrates how to use the framework to build an agent for a specific task:
- How to build a single agent that does planning, searches the web and uses code interpreter to answer knowledge-grounded questions, solving the tasks from the GAIA benchmark.
- How to build a team of TapeAgents with AutoGen-style low-code programming paradigm
- How to finetune a TapeAgent with a small LLM to be better at math problem solving on GSM-8k dataset.
Other notable examples that demonstrate the main aspects of the framework:
- workarena - custom agent that solves WorkArena benchmark using BrowserGym environment.
- tape_improver.py - the agent that revisit and improves the tapes produced by another agent.
To run these examples, simply use:
uv run -m examples.<MODULE> <ARGS>
Installation
Install the latest release with its minimal dependencies:
pip install tapeagents
You can also install converters and finetune optional dependencies
pip install 'tapeagents[converters,finetune]'
Building from source
- Install uv to manage package:
Official documentation here
- Clone the repository:
git clone https://github.com/ServiceNow/TapeAgents.git
cd TapeAgents
- Create
venvenvironment and install dependencies:
make setup
# equivalent to `uv sync --all-extras`
Learn more
See our full TapeAgents documentation.
For an in-depth understanding of the design principles, architecture, and research behind TapeAgents, see our technical report.
Contacts
Feel free to reach out to the team:
- Dzmitry Bahdanau, dzmitry.bahdanau@servicenow.com
- Oleh Shliazhko, oleh.shliazhko@servicenow.com
- Jordan Prince Tremblay, jordanprince.t@servicenow.com
- Alexandre Piché, alexandre.piche@servicenow.com
Acknowledgements
We acknowledge the inspiration we took from prior frameworks, in particular LangGraph, AutoGen, AIWaves Agents and DSPy.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tapeagents-0.1.16.tar.gz.
File metadata
- Download URL: tapeagents-0.1.16.tar.gz
- Upload date:
- Size: 4.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3897cb2d3e0abb42c03e5e1bf682bf7f488f8195c3561abd1cf25494e9cfb67
|
|
| MD5 |
fe81756ad51cfab32fca68531047eb85
|
|
| BLAKE2b-256 |
786732ba1390fc93c5454bbd314d56f78be3e6a81f9481942479e75de2821b18
|
Provenance
The following attestation bundles were made for tapeagents-0.1.16.tar.gz:
Publisher:
pypi.yml on ServiceNow/TapeAgents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tapeagents-0.1.16.tar.gz -
Subject digest:
d3897cb2d3e0abb42c03e5e1bf682bf7f488f8195c3561abd1cf25494e9cfb67 - Sigstore transparency entry: 409644025
- Sigstore integration time:
-
Permalink:
ServiceNow/TapeAgents@33cf13318d5d14896be9ae366a3c96951456b2d6 -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/ServiceNow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@33cf13318d5d14896be9ae366a3c96951456b2d6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tapeagents-0.1.16-py3-none-any.whl.
File metadata
- Download URL: tapeagents-0.1.16-py3-none-any.whl
- Upload date:
- Size: 203.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82d79e5bd0b91b4de067ae97728d9876bd79a72c28145234bfb085d5de2616ca
|
|
| MD5 |
fd9e8cefe141d4f9583ecb700cdfcacd
|
|
| BLAKE2b-256 |
cb8cf83d958a6bb1787f02ff0dc3cf21dfc6edb73a5bbef00d04a8214f44ce3f
|
Provenance
The following attestation bundles were made for tapeagents-0.1.16-py3-none-any.whl:
Publisher:
pypi.yml on ServiceNow/TapeAgents
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tapeagents-0.1.16-py3-none-any.whl -
Subject digest:
82d79e5bd0b91b4de067ae97728d9876bd79a72c28145234bfb085d5de2616ca - Sigstore transparency entry: 409644045
- Sigstore integration time:
-
Permalink:
ServiceNow/TapeAgents@33cf13318d5d14896be9ae366a3c96951456b2d6 -
Branch / Tag:
refs/tags/v0.1.16 - Owner: https://github.com/ServiceNow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@33cf13318d5d14896be9ae366a3c96951456b2d6 -
Trigger Event:
push
-
Statement type: