Stopping pi agent tasks | Generated by AI

Home 2026.07

Question: When using pi agent for a long-running task, how do you stop it?

Answer:

For a CLI agent like pi agent, stopping a long-running task is usually the same as stopping a foreground terminal process:

Ctrl + C

This sends SIGINT to the running agent. Most well-behaved agents catch it and stop gracefully.

If it ignores Ctrl+C:

1. Find the process

ps aux | grep pi

or:

pgrep -af pi

Example:

lzw   12345  ... pi-agent ...

2. Send termination signal

kill 12345

If still stuck:

kill -9 12345

kill -9 is the hard stop (SIGKILL), no cleanup.


If pi agent spawned child processes

Sometimes the agent launches:

You may need to kill the process tree:

pstree -p $(pgrep -f pi)

or:

pkill -P <parent_pid>

For tmux / remote sessions

If you run agents inside tmux:

tmux attach

then:

Ctrl+C

or kill the whole session:

tmux kill-session -t <session_name>

Agent-native workflow tip

For long autonomous runs, I usually run agents in a separate session:

tmux new -s agent
pi

Then you can detach:

Ctrl+B D

and later:

tmux attach -t agent

This avoids accidentally killing the agent by closing the terminal.

For “yolo mode” agents (skip confirmations), tmux + Ctrl+C is basically the standard control loop: let it run, inspect occasionally, interrupt when the trajectory is wrong.


Generated by AI. Curating and sharing still takes effort. If you find it useful, feel free to donate. WeChat: @lzwjavaWeChat QR · X: @lzwjava · Say hi 👋

Back Donate