Skip to main content
A SpreadSheetSwarm runs its agents at the same time and records each agent’s answer as a row: agent name, task, result and timestamp. You can give every agent the same task, or load agents from a CSV file where each row has its own task. With autosave=True, the rows are appended to a CSV file you can open in any spreadsheet tool. Reference: SpreadSheetSwarm.

1. Run every agent on one task

Three analysts look at the same launch plan, each from its own angle:
This prints 3 of 3 agents finished, then one answer per analyst. The agents run in parallel, so the run takes about as long as the slowest agent. autosave is False by default, so this run writes nothing to disk.

2. Read the summary

run() returns a dict. Continuing from step 1:
Every run() starts a fresh run_id, outputs and tasks_completed, so a second run returns only its own rows. export_to_json() returns the latest run as a JSON string with the same keys, minus the two timestamps.

3. Save rows to a CSV file

With autosave=True, each run appends its rows to the CSV at save_file_path and writes a JSON copy of the summary to the swarm’s workspace folder. max_loops=2 runs every agent twice, one loop after the other, so this run makes four rows:
Output from one run, shortened:
  • The header row is written only when the file is new. Later runs append below it, each with its own Run ID.
  • The swarm does not create the CSV’s folder. Create it first, as above.
  • Without save_file_path, the CSV is named spreadsheet_swarm_run_id_<hex>.csv and goes in the workspace folder.
  • Each agent starts every loop on a fresh conversation, so loops are independent samples, not revisions.

4. Give each agent its own task from a CSV

A CSV with agent_name and task columns defines both the agents and their work. Pass it as load_path and call run() with no task. The other columns set the agent’s settings; description becomes the agent’s agent_description.
Output:
How the CSV is used:
  • With no agents passed, the first run() builds one agent per row with AgentLoader. run() with no task then calls run_from_config(), which runs each agent on its own row’s task.
  • A blank cell leaves that setting at the Agent default. Agents built from the CSV print their replies, since print_on defaults to True.
  • An agent whose name has no task in the CSV is skipped by run_from_config().
  • If you pass agents as well, call swarm.load_from_csv() yourself to add the CSV’s agents and tasks.

5. Spot a failed agent

One agent’s failure does not stop the others. Its row still appears, with result set to "Error: " plus the error message, and it is not counted in tasks_completed:
Output, after the error is logged:
With autosave=True, the failed row is saved to the CSV too, so check the Result column for Error: when you read the file back.

Tips

  • Give every agent a distinct agent_name. Rows show only the name, and CSV tasks are matched to agents by name.
  • Set print_on=False on agents you build yourself when you only want the rows.
  • Read token usage with swarm.usage, which adds up every agent’s provider usage.
  • Pass at least agents or load_path. With neither, the constructor raises ValueError("No agents are provided.").

Next steps