HKUDS/Vibe-Trading · error · FileNotFoundError

Run directory not found: {rd.name}

Error message

Run directory not found: {rd.name}

What it means

update_run resolves the run directory via run_dir(run.id) and raises FileNotFoundError when it does not exist on disk — i.e. the run was never created (create_run not called) or its directory was deleted/moved.

Source

Thrown at agent/src/swarm/store.py:216

            except (OSError, ValueError) as exc:
                last = exc
                if attempt < len(_REPLACE_BACKOFF):
                    time.sleep(_REPLACE_BACKOFF[attempt])
        assert last is not None  # loop body sets `last` or returns
        raise type(last)(redact_internal_paths(str(last))) from None

    def update_run(self, run: SwarmRun) -> None:
        """Atomically update run state.

        Args:
            run: Updated SwarmRun instance.

        Raises:
            FileNotFoundError: If the run directory does not exist.
        """
        rd = self.run_dir(run.id)
        if not rd.exists():
            raise FileNotFoundError(f"Run directory not found: {rd.name}")
        self._atomic_write(rd / "run.json", run.model_dump_json(indent=2))

    def list_runs(self, limit: int = 50) -> list[SwarmRun]:
        """List all runs sorted by created_at descending.

        Args:
            limit: Maximum number of runs to return.

        Returns:
            List of SwarmRun instances.
        """
        if not self.base_dir.exists():
            return []

        runs: list[SwarmRun] = []
        for entry in self.base_dir.iterdir():
            if not entry.is_dir():
                continue

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Call create_run(run) before any update_run/append_event
  2. Verify the store's base_dir matches where runs were created
  3. If the directory was deleted intentionally, start a new run instead of updating

Example fix

# before
store.update_run(run)  # run never created
# after
path = store.create_run(run)
store.update_run(run)
Defensive patterns

Strategy: validation

Validate before calling

if not store.run_dir(run.id).exists():
    store.create_run(run)
store.update_run(run)

Try / catch

try:
    store.update_run(run)
except FileNotFoundError as e:
    if 'Run directory not found' in str(e):
        store.create_run(run); store.update_run(run)
    else: raise

Prevention

When it happens

Trigger: Calling update_run on a SwarmRun constructed in memory without create_run; resuming after someone wiped the runs directory; a run id from a different base_dir.

Common situations: Resume/recovery flows after manual cleanup or a different SWARM store root; tests that build run objects without persisting them first.

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/5aaec851c2fe4756. Report an issue: GitHub.