Pi Agent Security and Project Trust
Pi Agent runs with your current user's permissions.
This chapter covers the project trust mechanism, security boundaries, and containerized running options.
Pi Agent's security model
Pi Agent is a local coding agent—it runs with the user permissions you started it with, and can read, write, edit files, and execute shell commands.
This means:
- It can access all files your user account can access
- The range of commands it can execute is exactly the same as what you can do manually in the terminal
- It has no built-in sandbox isolation mechanism
This is intentional—Pi Agent needs to invoke project toolchains, run tests, and install dependencies, which require real system permissions.
Pi Agent's design philosophy: don't provide a half-baked sandbox that "looks safe but is actually easy to misunderstand".
Real isolation should come from the OS level or a virtualization/container boundary.
Project trust mechanism
Project Trust controls whether Pi Agent loads a project's local configuration and extensions.
It's not a sandbox—it only controls what's loaded at startup and doesn't restrict what the model can do during a conversation.
When is a trust check triggered
A trust check is triggered when Pi Agent detects any of the following in a project directory:
- .pi/settings.json (project configuration file)
- .pi/extensions, .pi/skills, .pi/prompts, .pi/themes (project resource directories)
- .pi/SYSTEM.md or .pi/APPEND_SYSTEM.md (project system prompts)
- .agents/skills (project Skills directory)
An empty .pi directory alone doesn't trigger a trust check.
Trust decision flow
Pi Agent decides whether to load the current project's resources in a fixed order.
- Check whether trust.json has a saved decision (searching upward from the current directory)
- If so, use the saved decision
- If not, follow the behavior set by defaultProjectTrust (default: ask, i.e. prompt)
- After making a decision, the user can choose "Remember", which is written to trust.json
Trust decisions are stored by directory in the global ~/.pi/agent/trust.json.
When searching, it walks up the parent directories level by level to match this file; only when no saved decision can be found does it fall back to the defaultProjectTrust logic.
When you first enter an untrusted project, the interface displays the following prompt:
检测到项目本地配置 .pi/settings.json
是否信任此项目并加载其配置与扩展?(y/n/always/never)
The prompt wording and options may differ between versions; the actual interface takes precedence.
Project trust only controls the loading of protected resources such as extensions and skills.
Context files such as AGENTS.md and CLAUDE.md are loaded regardless of whether the project is trusted.
defaultProjectTrust setting
This setting determines Pi Agent's default choice when no one confirms; interactive and non-interactive modes behave differently.
| Value | Interactive mode behavior | Non-interactive mode behavior |
|---|---|---|
| "ask" (default) | Show a trust confirmation prompt | Do not load project resources (same behavior as "never") |
| "always" | Automatically trust | Automatically trust |
| "never" | Automatically reject | Automatically reject |
Configuration method:
Example
{
"defaultProjectTrust": "always"
}
You can also override the behavior for a single run via command-line arguments:
# Trust the project this time
$ pi --approve
$ pi -a
# This run does not trust the project
$ pi --no-approve
$ pi -na
Save decisions with the /trust command
In interactive mode, you can use the /trust command at any time to save the trust decision for the current project:
/trust
This command writes to ~/.pi/agent/trust.json, recording trust decisions saved by directory.
/trust saves the current decision but does not reload the current session.
If you change a trust decision, you need to restart Pi Agent for the change to take effect.
Security considerations in non-interactive mode
In Print mode (-p), JSON mode (--mode json), and RPC mode (--mode rpc), Pi Agent does not display trust prompts.
The behavior in these cases depends entirely on the defaultProjectTrust setting:
- Set to "ask" or "never": project resources are ignored
- Set to "always": project resources are loaded
You can temporarily override this behavior with --approve or --no-approve.
Running untrusted code
When you need to work with untrusted repositories or automated tasks, it is recommended to run Pi Agent in a container or sandbox:
- Container approach: run the entire pi process inside a Docker container or VM
- Gondolin approach: run pi on the host and route tool execution into a Gondolin micro-VM
- OpenShell approach: run the entire pi process inside an NVIDIA policy-controlled sandbox, created through a gateway
- Mount control: only mount the working directories the agent needs to access
- Credential management: avoid mounting the host's ~/.pi/agent/ directory; pass in a temporary API Key with minimal permissions
- Network isolation: if the task does not need network access, restrict the container's network access
- Result review: review the diff and modified content before copying output back to a trusted system
Gondolin is a standalone open-source micro-VM project (a local Linux micro-VM requiring QEMU); Pi routes built-in tool execution into it via a sample extension.
OpenShell creates a sandbox with openshell sandbox create --from pi; you must first register and select a gateway.
Remote gateway mode does not bind-mount local directories; use upload/download commands to transfer files in and out of the sandbox, and model credentials can stay outside the sandbox.
If you bind-mount the host working directory into the container with read-write access, writes inside the container still affect host files.
For stricter protection, use read-only mounts or copy files in and out of the sandbox.
Security tips
Below are security recommendations for common usage scenarios; check them before you start.
| Scenario | Recommendation |
|---|---|
| Reviewing third-party code | Run in a container with a read-only mount |
| Automated CI/CD | Use temporary credentials and restrict the tool allowlist |
| Team-shared configuration | Use the project's .pi/settings.json, but do not put sensitive information in it |
| Installing third-party extension packages | Review the source before installing; extensions can execute arbitrary code |
| Installing third-party Skills | Review the SKILL.md content; Skills can instruct the model to perform arbitrary actions |