Skip to content

[Feature] Support custom_imports to register custom components. - #492

Merged
mzr1996 merged 1 commit into
open-compass:mainfrom
mzr1996:custom_imports
Dec 4, 2026
Merged

mzr1996 merged 1 commit into
open-compass:mainfrom
mzr1996:custom_imports

Conversation

@mzr1996

@mzr1996 mzr1996 commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds custom_imports so users can register their own Benchmarks, Harnesses, Environments, Recipes, and Analyzers without editing AgentCompass source.

  • One entry format, inferred type: an existing file is imported as a single module, an existing directory as a package (must contain __init__.py), otherwise a dotted module name via importlib.import_module(). Anything else fails fast.
  • Every entry point: runtime.custom_imports in config and orchestration files; repeatable --custom-import on run, launch, summary, analysis, list *, config show, config docs, and env close; SDK load_custom_imports(), RuntimeOptions(custom_imports=...), and custom_imports= on the request/run/summary/analysis helpers.
  • Deterministic layering: user → project → explicit config → orchestration → CLI. Entries are appended, de-duplicated by resolved path or module name, and each executes at most once per process. Relative paths resolve against the declaring file (CLI: current working directory).
  • Safe registry semantics: built-ins load first, so custom components cannot shadow existing IDs; import failures and ID collisions abort startup instead of being skipped.
  • Provenance only: effective imports are recorded in run_info.json metadata, but summary/analysis never replay them — they use the current registry and require the current config/CLI to declare what they need. analysis now validates analyzer IDs and reports unknown analyzers explicitly.
  • Inspection commands read only runtime.custom_imports, so list/config docs can discover custom components without validating unrelated parameters.
  • Docs updated in EN and ZH.

How to use

Config file:

runtime:
  custom_imports:
    - ./components.py
    - ./component_package
    - company_eval.components

CLI:

agentcompass list benchmark --custom-import ./component_package
agentcompass run my_bench my_harness my_model --custom-import company_eval.components
agentcompass summary ./results/example --config ./config.yaml

SDK:

from agentcompass import RuntimeOptions, load_custom_imports

load_custom_imports(["./component_package"])
runtime_options = RuntimeOptions(custom_imports=["company_eval.components"])

Packages are not scanned recursively — import the registering modules from __init__.py:

# component_package/__init__.py
from .benchmark import CustomBenchmark
from .harness import CustomHarness

Custom imports execute arbitrary Python, including during inspection commands and --dry-run; pass only trusted sources.

@mintlify

mintlify Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 218ef2b.

Approve preview

@mzr1996
mzr1996 merged commit 751412b into open-compass:main Dec 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant