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

See Pi Agent Troubleshooting

Pi Agent Common Issues and Troubleshooting

Below are common issues and solutions encountered when using Pi Agent.

Decision tree for troubleshooting Pi Agent startup failures


Installation problems

This section covers typical errors and resolution paths during installation.

npm install fails

Symptom: the install command exits with an error midway; common errors fall into three categories: version, network, and permissions.

Possible cause Troubleshooting methods Solution
Node.js version too low; Pi Agent requires Node.js 22.19.0 or higher Run node --version to check the current version Use nvm to install and switch to 22 LTS or higher
Network issue; accessing the official npm registry from within China often times out Check whether the error contains network timeout messages such as ETIMEDOUT Run npm config set registry https://registry.npmmirror.com to switch to a mirror registry and reinstall
Permission issue; the global installation directory on macOS/Linux is not writable by the current user Check whether the error contains an EACCES permission error Use nvm to manage Node.js, or configure the npm prefix to a user directory to avoid using sudo

pi command not found after installation

Symptom: installation reports success, but entering pi shows command not found.

First check npm's global installation prefix:



$ npm prefix -g

/usr/local

Then confirm whether the bin directory under that prefix is in PATH:



$ echo $PATH | grep "$(npm prefix -g)/bin"

/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin

When the directory is not in PATH, this command produces no output:



$ echo $PATH | grep "$(npm prefix -g)/bin"

No output means the global bin directory is not in PATH, which is why the pi command can't be found.

Possible cause Troubleshooting methods Solution
Global bin directory not added to PATH Use the grep command above to check whether there is output Append $(npm prefix -g)/bin to PATH in ~/.zshrc or ~/.bashrc, then reopen the terminal for it to take effect
Switched Node versions and the old symlink became invalid Run ls $(npm prefix -g)/bin to check whether pi is still there Re-run a global installation under the current Node version

Authentication issues

This section covers resolution paths for /login login and API Key authentication failures.

/login login fails

Manifests as the browser failing to complete the redirect after entering /login, or the interface staying in a waiting-for-authorization state.

Possible cause Troubleshooting methods Solution
Subscription is not in a valid state Log in to the provider's official site to confirm whether the subscription has expired Renew the subscription, or switch to another provider to log in
Cannot access the provider's authentication server Open the provider's site in a browser to confirm network reachability Configure a proxy and retry; see the Proxy Settings section below for configuration details
Using /login over an SSH remote connection There is no browser on the remote machine, so the OAuth callback cannot be delivered Copy the authorization URL to a local browser, then manually paste the callback URL to complete login

API Key not taking effect

Symptom: the environment variable has been exported, but startup still reports unauthenticated, or old credentials continue to be used.

Check in the following order:

Possible cause Troubleshooting methods Solution
Environment variable not set correctly Run echo $ANTHROPIC_API_KEY to check the output If the output is empty, add the export to your shell config file, then re-source it
auth.json already contains a credential of the same name, which takes precedence over the environment variable Check whether ~/.pi/agent/auth.json already contains an entry for that provider Run /logout to clear old credentials, or directly edit auth.json to update the Key
API Key format is incorrect Check whether the copied content contains extra spaces or quotes Copy the entire Key again and then configure it

auth.json Credentials saved in it take precedence over environment variables.

When the API Key doesn't take effect, first check ~/.pi/agent/auth.json, don't just focus on the environment variable.

Model unavailable

Symptom: the expected model cannot be found in the model list, or a call reports no permission.

Possible cause Troubleshooting methods Solution
Local model catalog is outdated Run pi update --models to refresh the model catalog After refreshing, reopen the model selector
Unclear which models are currently available Run pi --list-models to view the list of available models Select a model available to the current account from the list
API Key does not have access to the corresponding model Confirm the Key's model authorization scope in the provider console Upgrade the plan, or switch to an authorized model
GitHub Copilot model shows "not supported" Confirm whether the model has been enabled in VS Code First enable the model in VS Code Copilot Chat, then return to Pi Agent to use it

Interface issues

This section covers three types of interface anomalies: terminal rendering, image display, and shortcut keys.

Abnormal interface display (wrong colors, misaligned layout)

Symptom: colors appear dim or distorted, and borders of tables and text boxes are misaligned.

Possible cause Troubleshooting methods Solution
Terminal does not support True Color Run echo $COLORTERM; output of truecolor or 24bit indicates support Switch to a terminal that supports True Color (iTerm2, Windows Terminal, etc.)
VS Code automatically adjusted the terminal contrast Check the setting terminal.integrated.minimumContrastRatio Set it to 1
The current terminal has poor rendering compatibility Try another terminal to confirm whether the issue reproduces Change terminals; iTerm2 or Windows Terminal is recommended

Images not displayed

Symptom: after sending or pasting an image, only a placeholder or blank space appears in the terminal.

Possible cause Troubleshooting methods Solution
Terminal does not support an image display protocol Confirm whether the terminal supports iTerm2's imgcat or Kitty's icat Switch to a terminal that supports image protocols
Image display is disabled in configuration Check whether terminal.showImages is true Set it to true and run /reload for the configuration to take effect

Shortcut keys not working

Symptom: pressing a shortcut key described in the documentation has no effect, or triggers the terminal's own function.

Possible cause Troubleshooting methods Solution
The terminal intercepted the shortcut key Check the shortcut key binding list in the terminal settings Modify or release the conflicting binding in the terminal
Misremembered the current shortcut key Run /hotkeys to view all current shortcut key bindings Operate according to the actual bindings in the list
Need to adjust according to personal preference Confirm whether the config file ~/.pi/agent/keybindings.json exists Edit that file to customize shortcut keys

Session issues

This section covers two types of issues: session file bloat and not finding historical sessions.

Session file too large

Symptom: context usage keeps rising, responses slow down, or compaction triggers prematurely.

Possible cause Troubleshooting methods Solution
Conversation history too long Run /session to view the message count and token usage Run /compact to compact the conversation history
Automatic compaction is not enabled Check whether compaction.enabled is true Set it to true and restart pi for it to take effect
A single session has accumulated for too long Use /session to observe session file size growth Periodically use /new to start a new session and split sessions by task

Can't find a previous session

Symptom: previous work records don't appear in the pi -r list.

Possible cause Troubleshooting methods Solution
Did not use the resume entry point Run pi -r or enter /resume in interactive mode to browse the session list Select the target session from the list to resume
The sessionDir setting was modified Check the current value of sessionDir in settings.json Change it back to the original directory, or migrate the files from the original directory to the new one
Session directory permission anomaly Run ls ~/.pi/agent/sessions/ to confirm read/write access Run chmod -R u+rw ~/.pi/agent/sessions to fix permissions

Performance Issues

This section covers two types of performance issues: slow responses and degraded performance under long contexts.

AI responses are very slow

Symptom: no first token output for a long time after submitting a request, or overall time is significantly higher than usual.

Possible cause Troubleshooting methods Solution
High network latency or an unreachable link Run ping api.anthropic.com to check latency and packet loss Switch networks, or configure a proxy as described in the Proxy Settings section below
Reasoning level too high, lengthening thinking time Check the current reasoning level in the status bar Press Shift+Tab to lower the reasoning level
Too much content in the system prompt or context files Check the size of context files such as AGENTS.md Shorten the system prompt and streamline the content of AGENTS.md
Token consumption per request is too large Run /session to view token usage and time distribution Run /compact or /new to shorten the context and try again

If using a proxy environment, test with curl -x $HTTP_PROXY https://api.anthropic.com instead.

A failed ping in a proxy environment doesn't mean the API is unavailable.

ping uses ICMP while the API uses HTTPS; in this case, use curl to verify the real link.

AI performance degrades after a large amount of context

Symptom: after more conversation turns, the AI starts forgetting earlier agreements or gives repetitive answers.

Possible cause Troubleshooting methods Solution
Context is near the window limit and early content was compacted away Run /session to view the current token usage Manually run /compact to compact the context
Many invalid attempts have mixed into the history messages Use /tree to view branches and invalid conversations Use /new to start a new session and write conclusions into AGENTS.md
Referenced file content is unrelated to the current task Check whether @ references and context files contain unrelated content Reduce unnecessary context file content, keeping only what the current task needs

Proxy Settings

This section explains how to let Pi Agent access the API normally in a restricted network environment.

Accessing the API from within China

Configure the HTTP proxy in settings.json:



{

  "httpProxy": "http://127.0.0.1:7890"

}

Or set environment variables and then start:



$ export HTTP_PROXY=http://127.0.0.1:7890

$ export HTTPS_PROXY=http://127.0.0.1:7890

$ pi