{"record":{"id":"b18516381b7e269f","repo":"Fosowl/agenticSeek","slug":"prompt-file-not-found-at-path-file-path","errorCode":null,"errorMessage":"Prompt file not found at path: {file_path}","messagePattern":"Prompt file not found at path: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"sources/agents/agent.py","lineNumber":117,"sourceCode":"        Get the list of tools names.\n        \"\"\"\n        return list(self.tools.keys())\n    \n    def get_tools_description(self) -> str:\n        \"\"\"\n        Get the list of tools names and their description.\n        \"\"\"\n        description = \"\"\n        for name in self.get_tools_name():\n            description += f\"{name}: {self.tools[name].description}\\n\"\n        return description\n    \n    def load_prompt(self, file_path: str) -> str:\n        try:\n            with open(file_path, 'r', encoding=\"utf-8\") as f:\n                return f.read()\n        except FileNotFoundError:\n            raise FileNotFoundError(f\"Prompt file not found at path: {file_path}\")\n        except PermissionError:\n            raise PermissionError(f\"Permission denied to read prompt file at path: {file_path}\")\n        except Exception as e:\n            raise e\n    \n    def request_stop(self) -> None:\n        \"\"\"\n        Request the agent to stop.\n        \"\"\"\n        self.stop = True\n        self.status_message = \"Stopped\"\n    \n    @abstractmethod\n    def process(self, prompt, speech_module) -> str:\n        \"\"\"\n        abstract method, implementation in child class.\n        Process the prompt and return the answer of the agent.\n        \"\"\"","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/Fosowl/agenticSeek/blob/ae57a2357745a9706cb12d0fd76d954c84d166fa/sources/agents/agent.py#L99-L135","documentation":"load_prompt() reads a prompt template from disk and re-raises FileNotFoundError with the offending path when open() fails because the file does not exist. Agents load their prompt during __init__, so this aborts construction. It exists to give a clearer, path-bearing message than the bare OS error.","triggerScenarios":"Calling agent.load_prompt(file_path) — directly or via __init__ — when file_path points to a nonexistent file (typo, wrong working directory, file not shipped/created yet).","commonSituations":"Relative path resolved against a different CWD than expected (running from repo root vs. package dir); prompt file excluded from package/docker build; renamed or moved prompts directory; OS case-sensitivity mismatch (Linux vs. Windows filenames).","solutions":["Correct the path — use an absolute path (e.g. Path(__file__).parent / \"prompts\" / \"system.txt\") instead of a CWD-relative one.","Verify the file exists: os.path.isfile(file_path) or `ls` the directory before constructing the agent.","If packaged/deployed, ensure prompt files are included in the build (package data, Docker COPY).","Check filename spelling and case against the actual file on disk."],"exampleFix":"// before\nagent = Agent(prompt_path=\"prompts/system.txt\")  # FileNotFoundError if CWD differs\n// after\nfrom pathlib import Path\nprompt = Path(__file__).parent / \"prompts\" / \"system.txt\"\nagent = Agent(prompt_path=str(prompt))","handlingStrategy":"validation","validationCode":"from pathlib import Path\ndef resolve_prompt(name: str) -> str:\n    p = Path(__file__).parent / \"prompts\" / name\n    if not p.is_file():\n        raise FileNotFoundError(f\"Prompt missing before Agent init: {p}\")\n    return str(p)\nagent = Agent(prompt_path=resolve_prompt(\"system.txt\"))","typeGuard":null,"tryCatchPattern":"try:\n    agent = Agent(prompt_path=path)\nexcept FileNotFoundError as e:\n    if \"Prompt file not found\" in str(e):\n        logger.error(\"Prompt file missing: %s — check CWD and packaging\", path)\n        fallback = Path(__file__).parent / \"prompts\" / \"default.txt\"\n        agent = Agent(prompt_path=str(fallback))\n    else:\n        raise","preventionTips":["Build prompt paths with Path(__file__).parent, never bare relative paths dependent on CWD.","Check os.path.isfile() before constructing the agent and fail with a clear startup error.","Include prompt files in package data / Docker COPY so deployments ship them.","Verify filename case matches exactly — Linux filesystems are case-sensitive."],"tags":["python","file-not-found","configuration","paths"],"backgroundTag":"file-not-found","analyzedSha":"ae57a2357745a9706cb12d0fd76d954c84d166fa","analyzedAt":"2026-08-30T02:49:05.834Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}