Fosowl/agenticSeek · error · PermissionError

Permission denied to read prompt file at path: {file_path}

Error message

Permission denied to read prompt file at path: {file_path}

What it means

load_prompt() converts PermissionError into a clear message when the prompt file exists but the current process lacks read permission. Like the FileNotFoundError branch, it is raised during load_prompt, typically from Agent.__init__. The chained cause is preserved as a new PermissionError with the path in the message.

Source

Thrown at sources/agents/agent.py:119

        return list(self.tools.keys())
    
    def get_tools_description(self) -> str:
        """
        Get the list of tools names and their description.
        """
        description = ""
        for name in self.get_tools_name():
            description += f"{name}: {self.tools[name].description}\n"
        return description
    
    def load_prompt(self, file_path: str) -> str:
        try:
            with open(file_path, 'r', encoding="utf-8") as f:
                return f.read()
        except FileNotFoundError:
            raise FileNotFoundError(f"Prompt file not found at path: {file_path}")
        except PermissionError:
            raise PermissionError(f"Permission denied to read prompt file at path: {file_path}")
        except Exception as e:
            raise e
    
    def request_stop(self) -> None:
        """
        Request the agent to stop.
        """
        self.stop = True
        self.status_message = "Stopped"
    
    @abstractmethod
    def process(self, prompt, speech_module) -> str:
        """
        abstract method, implementation in child class.
        Process the prompt and return the answer of the agent.
        """
        pass

View on GitHub (pinned to ae57a23577)

Solutions

  1. Fix permissions: chmod o+r (or appropriate group perms) on the prompt file and ensure the containing directories are traversable.
  2. Run the process as a user with read access, or chown the file to the service user.
  3. If in a container, confirm the mounted file is readable by the container's UID.
  4. Verify with `sudo -u <appuser> cat <file>` that the runtime user can read it.

Example fix

// before
-rw------- root root prompts/system.txt  # app user cannot read
// after
chmod 644 prompts/system.txt   # or chown appuser prompts/system.txt
Defensive patterns

Strategy: validation

Validate before calling

import os
def assert_readable(path: str) -> None:
    if not os.access(path, os.R_OK):
        raise PermissionError(
            f"Process user ({os.getuid()}) cannot read {path}; "
            "fix with chmod/chown before starting"
        )
assert_readable(prompt_path)
agent = Agent(prompt_path=prompt_path)

Try / catch

try:
    agent = Agent(prompt_path=path)
except PermissionError as e:
    logger.error("Cannot read prompt %s: run `chmod o+r %s` or chown to the service user", path, path)
    raise SystemExit(1) from e

Prevention

When it happens

Trigger: Calling load_prompt(file_path) (directly or via __init__) where open(file_path, 'r') raises PermissionError — e.g. file owned by another user, mode 000/0600, or a protected directory in the path.

Common situations: Prompt file created by root with restrictive permissions while the app runs as a service user; secrets-like permissions (chmod 600) applied to prompt files; running in a container as non-root against a host-mounted file; SELinux/AppArmor denials.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Fosowl/agenticSeek@ae57a23577 (2026-08-30). Data as JSON: /api/errors/2be48edf85d12028. Report an issue: GitHub.