FoundationAgents/OpenManus · error · FileNotFoundError

File not found: {path}

Error message

File not found: {path}

What it means

Raised as FileNotFoundError by DockerSandbox.read_file (app/sandbox/core/sandbox.py:194) when the Docker get_archive call for the resolved path raises docker.errors.NotFound — the path simply does not exist inside the container (relative paths are resolved under config.work_dir via _safe_resolve_path). It is the container-side equivalent of a missing file, not a host path problem.

Source

Thrown at app/sandbox/core/sandbox.py:194

            FileNotFoundError: If file does not exist.
            RuntimeError: If read operation fails.
        """
        if not self.container:
            raise RuntimeError("Sandbox not initialized")

        try:
            # Get file archive
            resolved_path = self._safe_resolve_path(path)
            tar_stream, _ = await asyncio.to_thread(
                self.container.get_archive, resolved_path
            )

            # Read file content from tar stream
            content = await self._read_from_tar(tar_stream)
            return content.decode("utf-8")

        except NotFound:
            raise FileNotFoundError(f"File not found: {path}")
        except Exception as e:
            raise RuntimeError(f"Failed to read file: {e}")

    async def write_file(self, path: str, content: str) -> None:
        """Writes content to a file in the container.

        Args:
            path: Target path.
            content: File content.

        Raises:
            RuntimeError: If write operation fails.
        """
        if not self.container:
            raise RuntimeError("Sandbox not initialized")

        try:
            resolved_path = self._safe_resolve_path(path)

View on GitHub (pinned to 52a13f2a57)

Solutions

  1. Verify existence first: await sandbox.run_command(f"test -e {path} && echo OK").
  2. Check the resolved location — relative paths join to config.work_dir; use the absolute container path you wrote to.
  3. Ensure the producing command succeeded (check its exit status/output) before reading its output file.
  4. List the directory (run_command('ls -la <dir>')) to confirm names.

Example fix

# before
content = await sandbox.read_file("result.txt")

# after
if (await sandbox.run_command("test -e result.txt && echo yes")).strip() == "yes":
    content = await sandbox.read_file("result.txt")
else:
    ...  # producer never wrote the file
Defensive patterns

Strategy: try-catch

Validate before calling

exists = (await sandbox.run_command(f"test -e {shlex.quote(path)} && echo 1")).strip() == "1"

Try / catch

try:
    content = await sandbox.read_file(path)
except FileNotFoundError:
    content = None  # producer has not written it yet — schedule retry

Prevention

When it happens

Trigger: Reading an output file before the command that produces it has run; typo in the filename; path resolved against work_dir when the file actually lives elsewhere in the container; the creating process failed silently so the file was never written.

Common situations: Agent loop reads `/app/result.json` right after a command that errored before writing it; relative path 'out.txt' expected at CWD but resolved to work_dir; file written by a different user inside the container (rare) or deleted by a cleanup step.

Related errors


AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15). Data as JSON: /api/errors/0da6907646593cf4. Report an issue: GitHub.