Skip to main content
An EDSL Agent describes the perspective from which a model should answer: for example, a first-time user, an experienced researcher, or a reviewer applying a codebook. Its traits supply background information and its instructions say how to respond. The Model generates the answers; the Agent supplies the role or profile. Use agents to compare responses across defined perspectives or to give a consistent reviewing instruction across questions. You can omit a custom agent when the task only needs a question and source material. An EDSL Agent is distinct from a coding assistant or the Research Agent.

Define and vary profiles

The example combines two experience levels with two roles to create four profiles. Each evaluates both a short message and a more explicit message, answering the same clarity question:
Four profiles times two messages gives eight interviews per model and iteration. The results retain agent.experience and agent.role, so you can compare message ratings within each profile. Experimental conditions shows how to run and analyze this design. These are responses generated from the specified profiles, rather than observations collected from people with those characteristics.

Traits, instructions, and names

traits contains profile data. instruction describes how the agent should respond. An optional name identifies the agent in results; it does not automatically become a demographic trait. Use Prompts to see what is actually sent to the model. For data imported from a CSV or DataFrame, see Importing data. Inspect field names, missing values, and category definitions before using those rows as profiles.

Advanced: dynamic traits

A dynamic traits function supplies traits based on the question being asked. This is useful when different questions should receive different parts of a profile, rather than sending the whole profile every time. The example below keeps a reviewer role and adds the current question’s name:
Inspect prompts for every affected question and preserve the function with the study.

Common methods

Using the profiles above, select new users before adding them to a job:

Revise profiles and choose a subset

Trait transformations return new Agents, so assign the result:
update_trait() requires the trait to exist; add_trait() can introduce a new trait. agent.rename({"role": "occupation"}) changes trait names, and agent.translate_traits({"experience": {"new": "new user"}}) recodes values. agent.select(...) and agent.drop(...) keep or remove traits. agent.prompt() shows the traits presentation text; use job.prompts() to inspect the complete model prompt. AgentList.from_list("role", values) creates one agent per value. AgentList.from_results(results, question_names=["role"]) turns selected answers into traits for a subsequent study; Agent.from_result(result) does this for one interview.

Supply deterministic answers

For a simulation with a known response rule, attach a Python function to an Agent:
The function supplies the answer without an LLM response. Its return value must suit the question type. Preserve the function with your study so the rule can be inspected and reproduced.