Skip to main content

Overview

The AgentLoader 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. 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"
Default for concurrent loading when multiple files are passed. Individual load_* methods accept their own concurrent override.

Methods

auto()

Dispatch to the right loader based on file extension. The simplest entry point.
Parameters:
  • file_path (str): Path to .md, .yaml, or .csv file.
  • *args, **kwargs: Forwarded to the underlying loader.
Returns: List[Agent] Raises: ValueError if the file extension is not .md, .yaml, or .csv.

load_single_agent()

Alias for auto() — loads a single file by dispatching on extension.

load_multiple_agents()

Apply auto() to a list of files. Each file may be a different format.
Parameters:
  • file_paths (List[str]): Paths to agent definition files.
Returns: List of agent lists, one per input file.

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]]
Single path or list of paths to Markdown agent files.
bool
default:"True"
Load files in parallel.
float
default:"10.0"
Files above this size are skipped.

load_agents_from_yaml()

Load agents from a single YAML file.
str
Path to the YAML definitions file.
ReturnTypes
default:"\"auto\""
Controls the return shape from the underlying YAML loader.

load_many_agents_from_yaml()

Load agents from a list of YAML files with per-file return type control.

load_agents_from_csv()

Load agents from a CSV file via CSVAgentLoader.

parse_markdown_file()

Lower-level: parse a Markdown file via MarkdownAgentLoader directly, using the host’s CPU count as worker count.

Usage Examples

Auto-Dispatch on Extension

The shortest path — let auto() figure out the format.

Load Many Files in One Call

Markdown with Concurrency Control

Compose with a Swarm

Source Code

View the source on GitHub.