Overview
TheSpreadSheetSwarm processes tasks concurrently across multiple agents and automatically saves execution metadata to CSV files. It supports loading agent configurations from CSV files and running tasks either from configuration or on-demand.
SpreadSheetSwarm emits OpenTelemetry spans: one when it is constructed, and one for each run() and run_from_config() call. See Telemetry to turn tracing off.Installation
Attributes
str
default:"Spreadsheet-Swarm"
The name of the swarm
str
default:"A swarm that processes tasks concurrently..."
The description of the swarm
List[Agent]
default:"None"
The agents participating in the swarm. Required — the constructor runs a reliability check before any CSV loading happens, so a non-empty
agents list must be supplied even if load_path is also setbool
default:"True"
Whether to save results. When
True, each run appends rows to the CSV at save_file_path and writes a JSON metadata file to the swarm’s workspace directory. When False, nothing is written to diskstr
default:"None"
The CSV file path. When
None, it defaults to spreadsheet_swarm_run_id_<hex>.csv inside the swarm’s workspace directory ($WORKSPACE_DIR/swarms/SpreadSheetSwarm/<name>-<timestamp>/), falling back to WORKSPACE_DIR or the current directory when autosave is off. An explicit path is kept as givenint
default:"1"
The number of times to repeat the swarm tasks. Loops run one after another; within a loop every agent runs once, concurrently with the others. Each agent’s conversation is reset before every loop, so loops are independent samples rather than refinements of the previous loop
str
default:"None"
Path to a CSV file of agent configurations. Call
load_from_csv() explicitly after construction to build agents and per-agent tasks from it before calling run_from_config()bool
default:"False"
Enable verbose logging
Methods
run()
Run the swarm with the specified task.task(str): The task every agent runs. IfNoneand tasks were loaded withload_from_csv(), it callsrun_from_config()instead
run_from_config()
Run each agent that has a configured task, concurrently. Agents whoseagent_name has no entry in the loaded tasks are skipped.
load_from_csv()
Load agent configurations from the CSV atload_path. For each row it builds a new Agent, appends it to agents, and records the row’s task under its agent_name.
agent_name, description, system_prompt and task are required. The description column must be present but is not applied to the agent’s agent_description. model_name defaults to "openai/gpt-4o" when the column is missing, and max_loops defaults to 1. Optional user_name and stopping_token columns are also read. Errors while loading are logged, not raised.
export_to_json()
Export the swarm outputs to JSON.data_to_json_file()
Save the swarm outputs (viaexport_to_json()) to a JSON file in the workspace directory. Called automatically after each run when autosave=True.
Usage Examples
Basic Usage with Agents
Load from CSV Configuration
Create a CSV file (agents_config.csv) mapping each agent name to a task:
Multiple Loops
max_loops=3 a run takes about three times as long as a single loop, and outputs holds one row per agent per loop.
Custom Save Path
Export Results
Output Format
Therun() method returns a dictionary:
start_time, end_time and each output’s timestamp are ISO 8601 strings recorded when the run starts, when it ends, and when each result is tracked.
outputs and tasks_completed are not reset between run() calls on the same instance. A second run returns the first run’s outputs too, and the CSV save writes every accumulated output again. Create a new SpreadSheetSwarm when you want a clean result set.CSV Output Format
Results are automatically saved to CSV with these columns:Features
- Concurrent Execution: All agents run in parallel within each loop, and no agent is ever run by two threads at once
- Automatic CSV Logging: All executions are logged to CSV files automatically
- CSV Configuration: Load agent configurations from CSV files
- Multiple Loops: Run each agent multiple times with
max_loops - Workspace Integration: Automatically uses workspace directory from environment
- JSON Export: Export results to JSON format
- Metadata Tracking: Tracks timestamps, run IDs, and execution metadata
- Telemetry: Emits OpenTelemetry spans for construction and each run