Skip to content

abc_runner.task

WARNING

This documentation is almost entirely "vibe coded"; while a helpful resource for humans and agents to understand this codebase, it should not be considered a source of ground truth in the way documentation normally is, and the user is responsible for verifying that all instructions given here are safe.

abc_runner.task

Task management for ABC Runner.

Provides the Task class for loading and validating grouped benchmark task definitions. Tasks live inside task groups, which are discovered and resolved by :class:abc_runner.groups.GroupResolver (see :mod:abc_runner.groups).

TaskGroup dataclass

TaskGroup(group_id: str, group_dir: Path, metadata: dict)

Represents a benchmark task group.

canonical_name property

canonical_name: str

Return the group identifier used in task paths.

Task

Task(task_name: str, resolver: GroupResolver, task_group: str | None = None)

Represents a ABC Runner task.

A task belongs to a task group and defines a benchmark problem with a workspace for the agent, a prompt describing the problem, and hidden verification tests.

Attributes:

Name Type Description
task_id str

Short task identifier (directory name under a task group)

group_id str

Task group identifier

task_ref str

Canonical group/task task reference

group_dir Path

Full path to the (resolved) task group directory

task_dir Path

Full path to task directory

group_metadata dict

Parsed group metadata from group.yaml

Examples:

>>> task = Task("smoke_test/hello-world-python", resolver)
>>> task.task_ref
'smoke_test/hello-world-python'

Initialize a task.

Parameters:

Name Type Description Default
task_name str

Task identifier. Accepts either task-id or group/task-id.

required
resolver GroupResolver

Resolver used to locate task groups.

required
task_group str

Explicit task group to use when task_name is not canonical.

None

Raises:

Type Description
FileNotFoundError

If the task directory is not found

ValueError

If the task name is ambiguous or group metadata is invalid

Source code in abc_runner/task.py
def __init__(
    self,
    task_name: str,
    resolver: GroupResolver,
    task_group: str | None = None,
):
    """Initialize a task.

    Parameters
    ----------
    task_name : str
        Task identifier. Accepts either ``task-id`` or ``group/task-id``.
    resolver : GroupResolver
        Resolver used to locate task groups.
    task_group : str, optional
        Explicit task group to use when ``task_name`` is not canonical.

    Raises
    ------
    FileNotFoundError
        If the task directory is not found
    ValueError
        If the task name is ambiguous or group metadata is invalid
    """
    self.resolver = resolver

    self.group_id, self.task_id, self.group_dir, self.task_dir = self._resolve_task(
        task_name,
        task_group,
    )
    self.task_ref = f"{self.group_id}/{self.task_id}"
    self.group_metadata = self._load_group_metadata(self.group_id, self.group_dir)

build_env_script property

build_env_script: Path

Path to build_env.sh script.

prompt_file property

prompt_file: Path

Path to prompt.md file.

group_prompt_file property

group_prompt_file: Path | None

Path to the task group's shared group_prompt.md, if present.

This optional file lets a task group inject shared, group-wide guidance (for example, how to build and test the group's software stack) into the agent's prompt between the harness system instructions and the per-task prompt. Returns None when the group does not define one, so the prompt layer is fully backward-compatible.

workspace_dir property

workspace_dir: Path

Path to workspace directory.

verification_dir property

verification_dir: Path

Path to verification directory.

verify_script property

verify_script: Path

Path to verify_solution.sh script.

group property

group: TaskGroup

Return the task group wrapper.

validate

validate() -> list[str]

Validate that all required task components exist.

Source code in abc_runner/task.py
def validate(self) -> list[str]:
    """Validate that all required task components exist."""
    return self._task_dir_errors(self.task_dir)

list_task_groups staticmethod

list_task_groups(resolver: GroupResolver) -> list[str]

List all available task groups across the resolver's search roots.

Source code in abc_runner/task.py
@staticmethod
def list_task_groups(resolver: GroupResolver) -> list[str]:
    """List all available task groups across the resolver's search roots."""
    return resolver.list_group_ids()

list_tasks staticmethod

list_tasks(resolver: GroupResolver) -> list[str]

List all available task references as group/task.

Source code in abc_runner/task.py
@staticmethod
def list_tasks(resolver: GroupResolver) -> list[str]:
    """List all available task references as ``group/task``."""
    task_refs: list[str] = []
    for group_id in resolver.list_group_ids():
        try:
            group_dir = resolver.resolve_group_dir(group_id)
        except FileNotFoundError:
            continue
        for task_dir in sorted(group_dir.iterdir()):
            if not task_dir.is_dir() or task_dir.name.startswith("."):
                continue
            if task_dir.name == "__pycache__":
                continue
            if Task._task_dir_errors(task_dir):
                continue
            task_refs.append(f"{group_id}/{task_dir.name}")
    return task_refs

list_tasks_by_group staticmethod

list_tasks_by_group(resolver: GroupResolver) -> dict[str, list[str]]

Return available task ids keyed by task group.

Source code in abc_runner/task.py
@staticmethod
def list_tasks_by_group(resolver: GroupResolver) -> dict[str, list[str]]:
    """Return available task ids keyed by task group."""
    tasks: dict[str, list[str]] = {}
    for task_ref in Task.list_tasks(resolver):
        group_id, task_id = task_ref.split("/", 1)
        tasks.setdefault(group_id, []).append(task_id)
    return {group_id: sorted(task_ids) for group_id, task_ids in sorted(tasks.items())}

match_task_refs staticmethod

match_task_refs(patterns: list[str], resolver: GroupResolver) -> tuple[list[str], list[str]]

Match canonical group/task refs against glob patterns.

Returns (matched_task_refs, unmatched_patterns) where task refs are sorted and deduplicated. Matching is performed only against canonical refs returned by :meth:list_tasks.

Source code in abc_runner/task.py
@staticmethod
def match_task_refs(
    patterns: list[str],
    resolver: GroupResolver,
) -> tuple[list[str], list[str]]:
    """Match canonical ``group/task`` refs against glob patterns.

    Returns ``(matched_task_refs, unmatched_patterns)`` where task refs are
    sorted and deduplicated. Matching is performed only against canonical
    refs returned by :meth:`list_tasks`.
    """
    if not patterns:
        return [], []

    task_refs = Task.list_tasks(resolver)
    matches: set[str] = set()
    unmatched_patterns: list[str] = []

    for pattern in patterns:
        pattern_matches = [task_ref for task_ref in task_refs if fnmatchcase(task_ref, pattern)]
        if pattern_matches:
            matches.update(pattern_matches)
        else:
            unmatched_patterns.append(pattern)

    return sorted(matches), unmatched_patterns