Overview
TheAgentLoader class provides a unified interface for instantiating Agent objects from on-disk definitions. It supports three file formats and dispatches automatically based on the file extension.
Extensions are matched exactly:
auto() does not accept .yml or upper-case extensions.
Use this when you want agent definitions to live as data — checked into git, edited by humans, generated by tools — rather than hard-coded in Python.
Installation
Constructor
bool
default:"True"
Stored as
loader.concurrent. No method reads it; pass concurrent to load_agents_from_markdown() to control parallel loading.Methods
auto()
Dispatch to the right loader based on file extension. The simplest entry point.file_path(str): Path to.md,.yaml, or.csvfile.*args,**kwargs: Forwarded to the underlying loader.
List[Agent] for Markdown and CSV, and the shape described under load_agents_from_yaml() for YAML.
Raises: ValueError if the file extension is not .md, .yaml, or .csv.
load_single_agent()
Alias forauto() — loads a single file by dispatching on extension, and returns the same shape.
load_multiple_agents()
Applyauto() to a list of files. Each file may be a different format.
file_paths(List[str]): Paths to agent definition files.
auto() result per input file, in order.
load_agent_from_markdown()
Load a single agent from a Markdown file.load_agents_from_markdown()
Load multiple agents from one or more Markdown files.Union[str, List[str]]
A single file, a directory (every
*.md file in it), or a list of file paths.bool
default:"True"
Load files in parallel when there is more than one. Agents are then returned in completion order.
float
default:"10.0"
Files above this size are skipped.
Any
Override the parsed configuration for every agent, for example
model_name="gpt-5.4".name, description, model_name (or model), temperature, max_loops, mcp_url, and streaming_on. Markdown agents default to temperature=0.1 when the frontmatter sets none.
load_agents_from_yaml()
Load agents from a single YAML file throughcreate_agents_from_yaml.
str
Path to the YAML definitions file. It needs an
agents list and may have a swarm_architecture section.ReturnTypes
default:"\"auto\""
Controls the return shape. One of
"auto", "agents", "both", "swarm", "run_swarm", "tasks".load_many_agents_from_yaml()
Load agents from a list of YAML files with per-file return type control.load_agents_from_yaml() result per file. return_types needs one entry per file; the default ["auto"] covers a single file and raises IndexError for more.
load_agents_from_csv()
Load agents from a CSV file viaCSVAgentLoader.
**kwargs are accepted but ignored. Each row becomes one agent, built on up to 10 threads, so agents come back in completion order. Rows that fail validation are printed and skipped.
Boolean cells count as true only when they read
true (any case).
parse_markdown_file()
Lower-level: parse a Markdown file viaMarkdownAgentLoader without building an agent.
FileNotFoundError when the file is missing and ValueError when it has no frontmatter or fails validation.
Usage Examples
Auto-Dispatch on Extension
The shortest path — letauto() figure out the format.