How to Work with Tables
The Table class provides a structured to store and manage tabular data. It is particularly useful to store intermediate results from your LLM-powered agents. When building complex agents, you often need to track various outputs like agent responses across multiple steps. The Table class offers a simple interface to store this structured data with features like unique indexing, dynamic column addition, and multiple export formats (CSV, Markdown, etc.).
Table Basics
Creating Tables
Every table requires an index column that acts as a unique identifier for rows:
from zav.agents_sdk import Table
# Create an empty table
table = Table(index_column="id")
# Create a table with initial data
data = [
{"id": "1", "name": "First Row", "value": "100"},
{"id": "2", "name": "Second Row", "value": "200"}
]
table = Table(data=data, index_column="id")
Core Operations
Adding Columns
# Add a new column (all existing rows will get the default value)
table.add_column("status", default_value="pending")
Adding Rows
# Add a new row (must include the index column, other columns will get default values if not provided)
table.add_row({
"id": "3",
"name": "Third Row",
"value": "300",
"status": "active"
})
Updating Values
# Update a specific cell
table.update_cell(row_index="1", column_name="status", value="completed")