| name | create-agent-list |
| description | Create AgentLists from web searches, descriptions, local files, or programmatic generation |
| allowed-tools | Read, Glob, Bash(python:*), WebSearch, WebFetch, AskUserQuestion |
| user-invocable | true |
| arguments | agent_list_description |
Creating AgentLists
Generating Agents
Agents can be generated from descriptions or external sources:
from edsl import Agent, AgentList
agents = AgentList([
Agent(name="Person A", traits={"role": "CEO", "age": 45, "company": "Acme"}),
Agent(name="Person B", traits={"role": "CTO", "age": 38, "company": "Acme"}),
])
From a List of Agents
from edsl import Agent, AgentList
agent1 = Agent(traits={"age": 25, "occupation": "teacher"})
agent2 = Agent(traits={"age": 35, "occupation": "doctor"})
agents = AgentList([agent1, agent2])
Agents can take a separate name parameter e.g.,
a = Agent(name = 'John', traits={"age": 25, "occupation": "teacher"})
From External Data Sources
The from_source() method auto-detects the source type:
from edsl import AgentList
agents = AgentList.from_source("people.csv")
agents = AgentList.from_source("data.xlsx", sheet_name="Participants")
agents = AgentList.from_source({
"age": [25, 30, 35],
"name": ["Alice", "Bob", "Charlie"],
"occupation": ["teacher", "doctor", "engineer"]
})
import pandas as pd
df = pd.DataFrame({"age": [25, 30], "city": ["NYC", "LA"]})
agents = AgentList.from_source(df)
With Instructions and Codebook
agents = AgentList.from_source(
"people.csv",
instructions="Answer as if you were this person",
codebook={"age": "Age in years", "income": "Annual income in USD"},
name_field="respondent_name"
)
agents = AgentList.from_source(
"people.csv",
codebook="codebook.csv"
)
Programmatically with Combinations
from edsl import Agent, AgentList
from itertools import product
ages = [25, 35, 45]
occupations = ["teacher", "doctor", "engineer"]
agents = AgentList([
Agent(traits={"age": age, "occupation": occ})
for age, occ in product(ages, occupations)
])
Quick Reference
| Source | Example |
|---|
| List of Agents | AgentList([agent1, agent2]) |
| CSV file | AgentList.from_source("file.csv") |
| Excel file | AgentList.from_source("file.xlsx", sheet_name="Sheet1") |
| Dictionary | AgentList.from_source({"col": [1, 2, 3]}) |
| DataFrame | AgentList.from_source(df) |
Saving / Persistence
You will create a Python file with a descriptive name e.g., 'occupation_agent_list.py'
Whatever the name of your agent list, you will also save it as local JSON file:
agent.save('occupation_agent_list')
Sharing
Ask the user if they want to push that agent list to coop (Expected Parrot's servers).
Use AskUserQuestion to ask the user:
- "Should we push this agent list to Expected Parrot?"
- Options: Yes / No
If they answer 'Yes' ask them for the visibility setting with AskUserQuestion:
- "What visibility setting?
- Options: "public", "private", "unlisted"
Only proceed after receiving a response.
The description should be a short paragraph you write.
The alias should be a valid URL slug e.g., 'exit-interview'
agent_list.push(
visibility = "unlisted",
description = "<paragraph description of the survey>",
alias = "<valid url slug>"
)
After pushing, you should print the results so the user can see them.
If there is any error in pushing from your parameters, update the names.