HKUDS/Vibe-Trading · error · FileNotFoundError

Task not found: {path.name}

Error message

Task not found: {path.name}

What it means

TaskStore.load_task reads <run_dir>/tasks/<task_id>.json and raises FileNotFoundError when the file is missing — the task id was never written (create/save not called) or belongs to a different run.

Source

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

        with self._lock:
            tmp_path.write_text(task.model_dump_json(indent=2), encoding="utf-8")
            tmp_path.replace(path)

    def load_task(self, task_id: str) -> SwarmTask:
        """Load a task by ID.

        Args:
            task_id: Task ID.

        Returns:
            SwarmTask instance.

        Raises:
            FileNotFoundError: If the task file does not exist.
        """
        path = self._task_path(task_id)
        if not path.exists():
            raise FileNotFoundError(f"Task not found: {path.name}")
        return SwarmTask.model_validate_json(path.read_text(encoding="utf-8"))

    def load_all(self) -> list[SwarmTask]:
        """Load all tasks for the current run.

        Returns:
            List of SwarmTask sorted by ID.
        """
        tasks: list[SwarmTask] = []
        for path in sorted(self._tasks_dir.glob("task-*.json")):
            tasks.append(
                SwarmTask.model_validate_json(path.read_text(encoding="utf-8"))
            )
        return tasks

    def update_status(
        self, task_id: str, status: TaskStatus, **kwargs: str | int | list[str] | None
    ) -> SwarmTask:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Create/save tasks via the store before loading them
  2. List existing ids with load_all() (or inspect the tasks dir) to confirm the id
  3. Verify the TaskStore was constructed for the correct run

Example fix

# before
task = store.load_task('t42')
# after
ids = {t.id for t in store.load_all()}
task = store.load_task('t42') if 't42' in ids else None
Defensive patterns

Strategy: validation

Validate before calling

known = {t.id for t in store.load_all()}
if task_id not in known:
    raise KeyError(f'task {task_id} not in run')
task = store.load_task(task_id)

Try / catch

try:
    task = store.load_task(task_id)
except FileNotFoundError as e:
    if 'Task not found' in str(e): skip/recreate the task
    else: raise

Prevention

When it happens

Trigger: load_task('t9') when only t1..t5 were persisted; calling load_task against a TaskStore bound to a different run directory; a worker reporting a task id that was never created.

Common situations: Retry/resume flows after partial task creation; typos in task ids; store instances pointing at the wrong base_dir.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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