Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Pi Agent Security and Project Trust

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:

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:

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.

  1. Check whether trust.json has a saved decision (searching upward from the current directory)
  2. If so, use the saved decision
  3. If not, follow the behavior set by defaultProjectTrust (default: ask, i.e. prompt)
  4. 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:

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:

Pi Agent security layering: process permissions, project trust, container isolation, and Gondolin micro VM

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