FoundationAgents/OpenManus · error · Exception

No such file or directory: {item[path_str]}

Error message

No such file or directory: {item[path_str]}

What it means

The chart-visualization tool checks every path an LLM produced in its JSON plan: each item[path_str] must exist either as given or joined onto directory/config.workspace_root. If neither resolves, a bare Exception is raised with the missing path. Because the paths come from model output, the usual cause is a hallucinated or mis-joined relative path, not a filesystem fault.

Source

Thrown at app/tool/chart_visualization/data_visualization.py:79

        self,
        json_info: list[dict[str, str]],
        path_str: str,
        directory: str = None,
    ) -> list[str]:
        res = []
        for item in json_info:
            if os.path.exists(item[path_str]):
                res.append(item[path_str])
            elif os.path.exists(
                os.path.join(f"{directory or config.workspace_root}", item[path_str])
            ):
                res.append(
                    os.path.join(
                        f"{directory or config.workspace_root}", item[path_str]
                    )
                )
            else:
                raise Exception(f"No such file or directory: {item[path_str]}")
        return res

    def success_output_template(self, result: list[dict[str, str]]) -> str:
        content = ""
        if len(result) == 0:
            return "Is EMPTY!"
        for item in result:
            content += f"""## {item['title']}\nChart saved in: {item['chart_path']}"""
            if "insight_path" in item and item["insight_path"] and "insight_md" in item:
                content += "\n" + item["insight_md"]
            else:
                content += "\n"
        return f"Chart Generated Successful!\n{content}"

    async def data_visualization(
        self, json_info: list[dict[str, str]], output_type: str, language: str
    ) -> str:
        data_list = []

View on GitHub (pinned to 52a13f2a57)

Solutions

  1. Verify the referenced data files exist before invoking the chart tool, and pass the directory they actually live in.
  2. Re-prompt the LLM with the tool's error message plus an 'ls' of the directory so its next plan uses real paths.
  3. Make upstream steps fail loudly (fail-fast on data generation) so the chart step never runs with missing inputs.
  4. In code, replace this catch-all with ToolError and include both candidate paths (raw and joined) in the message for debuggability.

Example fix

# before
result = await viz_tool.execute(command="...json from LLM...", directory=None)

# after
data_dir = config.workspace_root / "data"
assert (data_dir / "sales.csv").exists(), "sales.csv missing; regenerate it first"
result = await viz_tool.execute(command=llm_json, directory=str(data_dir))
Defensive patterns

Strategy: validation

Validate before calling

import os
base = directory or str(config.workspace_root)
for item in json_info:
    p = item[path_str]
    if not (os.path.exists(p) or os.path.exists(os.path.join(base, p))):
        raise FileNotFoundError(f'{p} not found in cwd or {base}')

Type guard

def all_paths_resolvable(json_info: list[dict], base: str) -> bool:
    return all(
        os.path.exists(it[path_str]) or os.path.exists(os.path.join(base, it[path_str]))
        for it in json_info
    )

Try / catch

try:
    result = await viz_tool.execute(command=llm_json, directory=base)
except Exception as e:
    if 'No such file or directory' in str(e):
        listing = await shell.run(f'ls {base}')
        llm_json = replan_with_listing(llm_json, listing)  # re-prompt with real files
        result = await viz_tool.execute(command=llm_json, directory=base)
    else:
        raise

Prevention

When it happens

Trigger: LLM outputs a path like './data/sales.csv' that only exists relative to some other base; the file was never generated by a preceding step; the directory parameter was omitted so workspace_root was used but the file lives elsewhere; case mismatch on case-sensitive filesystems.

Common situations: Multi-step agent pipelines where a data-generation step failed silently before charting; running the tool with the wrong directory argument; LLM inventing plausible-looking filenames.

Related errors


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