HKUDS/Vibe-Trading · error · ValueError

Task '{task.id}' depends on unknown task '{dep}'

Error message

Task '{task.id}' depends on unknown task '{dep}'

What it means

validate_dag checks every task's depends_on entries against the set of known task ids; an unknown dependency raises ValueError. This catches typos and forward references to tasks that were never defined in the preset/run.

Source

Thrown at agent/src/swarm/task_store.py:165

    return newly_unblocked


def validate_dag(tasks: list[SwarmTask]) -> None:
    """DFS cycle detection to ensure the task DAG is acyclic.

    Args:
        tasks: List of SwarmTask.

    Raises:
        ValueError: If a cycle is detected; message includes the cycle path.
    """
    graph: dict[str, list[str]] = {t.id: list(t.depends_on) for t in tasks}
    all_ids = {t.id for t in tasks}

    for task in tasks:
        for dep in task.depends_on:
            if dep not in all_ids:
                raise ValueError(
                    f"Task '{task.id}' depends on unknown task '{dep}'"
                )

    WHITE, GRAY, BLACK = 0, 1, 2
    color: dict[str, int] = {tid: WHITE for tid in all_ids}
    path: list[str] = []

    def dfs(node: str) -> None:
        """DFS traversal to detect back edges.

        Args:
            node: Current node ID.

        Raises:
            ValueError: If a cycle is detected.
        """
        color[node] = GRAY
        path.append(node)

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Fix the dependency id to match an existing task id exactly
  2. If the producer was removed/renamed, update or remove the depends_on entry accordingly
  3. Run validate_dag (or inspect_preset) immediately after editing preset YAML

Example fix

# before
tasks=[SwarmTask(id='analyze', depends_on=['fetch-mkt-data']), ...]
# after
tasks=[SwarmTask(id='analyze', depends_on=['fetch_market_data']), SwarmTask(id='fetch_market_data', depends_on=[])]
Defensive patterns

Strategy: validation

Validate before calling

all_ids = {t.id for t in tasks}
bad = [(t.id, d) for t in tasks for d in t.depends_on if d not in all_ids]
if bad: raise ValueError(f'unknown deps: {bad}')
validate_dag(tasks)

Type guard

def deps_resolve(tasks) -> bool:
    ids = {t.id for t in tasks}
    return all(d in ids for t in tasks for d in t.depends_on)

Try / catch

try:
    validate_dag(tasks)
except ValueError as e:
    if 'unknown task' in str(e): fix or drop the depends_on entry, re-validate
    else: raise

Prevention

When it happens

Trigger: A preset task with depends_on: ['fetch-mkt-data'] when the producing task is actually named 'fetch_market_data'; dependency on a task that a conditional branch excluded.

Common situations: Renaming tasks in a preset without updating dependents; conditionally skipping a producer task while its consumers still run.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/f4d9f7c3d2bc66d0. Report an issue: GitHub.