> ## Documentation Index
> Fetch the complete documentation index at: https://agent-compass.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Custom Components

Load your own Benchmark, Harness, Environment, Recipe, or Analyzer into AgentCompass without changing its source code. List the Python files, packages, or modules that register your components, and AgentCompass imports them before it looks up component IDs.

## Before You Start

This page explains how to load components that you have already written. To write one, start with the matching developer guide:

| To add your own | Read |
| - | - |
| Benchmark | [Benchmark Integration](https://agent-compass.mintlify.site/en/developer_guide/extensions/benchmark/overview.md) |
| Harness | [Harness Integration](https://agent-compass.mintlify.site/en/developer_guide/extensions/harness/overview.md) |
| Environment | [Environment Integration](https://agent-compass.mintlify.site/en/developer_guide/extensions/environment/overview.md) |
| Recipe | [Recipe Integration](https://agent-compass.mintlify.site/en/developer_guide/extensions/recipe_integration.md) |
| Analyzer | [Analyzer Integration](https://agent-compass.mintlify.site/en/developer_guide/extensions/analyzer_integration.md) |

Those guides are written for contributors, so some steps, such as placing files under `src/agentcompass/`, apply only to components that you submit to the repository. For a private component, follow the same component contract (base class, registration decorator, and parameters), keep your code in your own project, and load it with the steps on this page.

## Quick Start

Write a module that registers your component. This example registers an Analyzer that flags empty final answers:

```python theme={"system"}
# components.py
from agentcompass.runtime import (
    ANALYZERS,
    AnalysisResult,
    AnalyzerCategory,
    BaseAnalyzer,
    RunResult,
)


@ANALYZERS.register()
class EmptyAnswerAnalyzer(BaseAnalyzer):
    id = "EmptyAnswerAnalyzer"
    description = "Flag tasks whose final answer is empty."
    category = AnalyzerCategory.BEHAVIOR
    datasets = []
    data_requirements = []

    async def analysis(self, task, prepared, result: RunResult, req, plan) -> AnalysisResult:
        _ = prepared, req, plan
        empty = not str(result.final_answer or "").strip()
        return AnalysisResult(task_id=task.task_id, is_badcase=empty, details={"empty_answer": empty})
```

Declare the file in a configuration file. A relative path here is resolved from the folder that contains the configuration file:

```yaml theme={"system"}
# config.yaml
runtime:
  custom_imports:
    - ./components.py
```

Confirm that AgentCompass finds the component:

```bash theme={"system"}
agentcompass list analyzer --config ./config.yaml
```

The output includes `EmptyAnswerAnalyzer`. You can also skip the configuration file and pass the file directly with `--custom-import ./components.py`.

## Choose What to Import

Every entry in `custom_imports` is a plain string. AgentCompass checks it in the following order to decide how to load it:

| If the entry is | AgentCompass loads it as | Example |
| - | - | - |
| An existing file | One Python file | `./components.py` |
| An existing directory | A Python package; the directory must contain `__init__.py` | `./component_package` |
| A dotted name made of valid Python identifiers | An installed module, the same as `import company_eval.components` | `company_eval.components` |

Any other value is an error.

### Single File

Use a file for a small, self-contained component. AgentCompass does not add the file's folder to the module search path, so the file cannot import its neighbors by name, and relative imports such as `from . import helpers` do not work. Standard-library and installed packages import normally. If your component needs several files, use a package.

### Package Directory

Use a package when your component spans several files. AgentCompass runs only the package's `__init__.py` and does not scan the directory, so import every module that registers a component there:

```python theme={"system"}
# component_package/__init__.py
from .benchmark import CustomBenchmark
from .harness import CustomHarness
```

Use relative imports inside the package, as shown above. Importing the package by its folder name, such as `import component_package`, does not give you the package that AgentCompass loaded. If two packages need to refer to each other, put them under one parent package and import only the parent.

### Installed Module

Use a module name when your components ship as an installed Python package, for example from your team's private package index. The module must be importable in the Python environment that runs AgentCompass.

## Declare Imports

You can declare imports in four places. Use whichever fits how you run AgentCompass, or combine them.

| Where | How | Relative paths start from |
| - | - | - |
| Configuration file | List entries under `runtime.custom_imports` | The folder that contains that file |
| Orchestration file for `launch` | List entries under a top-level `runtime.custom_imports` | The folder that contains the orchestration file |
| Command line | Repeat `--custom-import <entry>` | The current working directory |
| Python SDK | Call `load_custom_imports()` or pass `custom_imports` | The current working directory |

The SDK options are described in [Python SDK](https://agent-compass.mintlify.site/en/user_guide/using_agentcompass/python_api.md#import-custom-components).

Configuration files come from the same three sources as every other setting: the user-level `config.yaml`, the nearest project `config.yaml`, and each `--config` file. See [Override Order](https://agent-compass.mintlify.site/en/user_guide/using_agentcompass/cli/config.md#override-order) for where AgentCompass looks for them.

### Load Order

AgentCompass loads imports in this order:

1. All built-in components, so a custom component cannot reuse a built-in ID.
2. Imports from configuration files: the user-level file, the project-level file, then each `--config` file in the order given.
3. Imports from the orchestration file (`launch` only).
4. Imports from `--custom-import`, in the order given.

Entries that resolve to the same file, directory, or module name run only once. Most list settings in configuration files are replaced by the higher-priority file, but `custom_imports` is an exception: entries from every layer are added together.

If an import fails or a component ID is already taken, the command stops with an error instead of skipping the entry.

## Use the Options in Commands

These commands accept repeatable `--config <path>` and `--custom-import <entry>` options:

* `run` and `launch`
* `summary` and `analysis`
* every `list` subcommand, including `list dump`
* `config show` and `config docs`
* `env close`

For example, check that a Benchmark from an installed module is registered:

```bash theme={"system"}
agentcompass list benchmark --config ./config.yaml --custom-import company_eval.components
```

`list` and `config docs` read only `runtime.custom_imports` from your configuration files and ignore their other settings. A YAML syntax error, an invalid entry, or an import that fails still stops the command. When no custom imports are configured, these commands load only the built-in components of the kind you asked about.

## Recipes

A Recipe class decorated with `@RECIPES.register()` in an imported module joins the Recipe registry for every run that loads the import. AgentCompass then applies it to each task where its `matches()` method returns `True`. To limit which Recipes can apply, pass `--recipe <id>`, which works as an allowlist.

To load a Recipe for selected runs only, use `--recipe-dir` instead. It takes a package that lists its classes in `RECIPE_CLASSES` and does not use the decorator. See [Recipes](https://agent-compass.mintlify.site/en/user_guide/other_features/recipes.md#trusted-external-recipes).

## Summarize or Analyze Existing Results

Every run records the imports it used in `run_info.json`, so you can see where its components came from. `summary` and `analysis` do not import those records again. They use only the imports from your current configuration and command line, so opening a results folder never runs code that is saved inside it.

If the results use a custom component, declare it again in the command:

```bash theme={"system"}
agentcompass summary ./results/example --config ./config.yaml --custom-import ./component_package
agentcompass analysis --input ./results/example --custom-import ./components.py
```

Without the import, the command stops with an unknown-component error. The same applies to `summary --dry-run`.

With the default `analyzers: null`, `analysis` considers only the Analyzers registered at that moment. To use a custom Analyzer, import it as shown above. Naming its ID in `analysis_params.analyzers` does not load its source code.

## Import Only Code You Trust

An import runs the Python code in that file, package, or module with your permissions. This is true for every command that accepts the options, including `list`, `config docs`, and `summary --dry-run`. Add only sources you trust, and watch for changes to the import lists in shared configuration files.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.