pi-afk-mode
Pi extension: /afk keeps the agent working until every remaining item is blocked on a human decision. Pauses while async pi-subagents run.
Package details
Install pi-afk-mode from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-afk-mode- Package
pi-afk-mode- Version
0.1.0- Published
- Sep 11, 2026
- Downloads
- 159/mo · 159/wk
- Author
- abberlaber
- License
- MIT
- Types
- extension
- Size
- 11.3 KB
- Dependencies
- 0 dependencies · 2 peers
Pi manifest JSON
{
"extensions": [
"./afk.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-afk-mode
A Pi extension for walking away. /afk keeps the agent working until every remaining item is genuinely blocked on a decision only you can make.
pi install npm:pi-afk-mode
How it works
/afk(or/afk on|off) toggles AFK mode. Switching it on while the agent is idle starts it working immediately.- Every time the agent finishes a turn and settles, it gets a nudge: finish open tasks, verify with tests/builds, review the diff, tidy up, pick up the next unblocked item.
- The agent is only left alone after it calls the
afk_blockedtool with a concrete list of{ work, decision }pairs. Nudging pauses; the status bar showsafk: blocked on you. - Typing anything resets that: you're back, or you just answered. Nudging resumes after your turn.
- The mode is stored in the session, so
/resumepicks it up./newstarts clean.
Guardrails
- Nudge cap: 25 nudges per
/afk on(status bar showsafk 7/25). Toggle/afkto reset. Costs are bounded even if the agent never declares itself blocked. - Abort / error: no nudge after an aborted turn (you pressed Escape, you're at the keyboard) or an errored turn (don't loop on failures).
- Async subagents: if pi-subagents has queued or running async children for this session, the agent is not nudged. Their completion wakes the session; the next settle nudges as usual. Detected by reading the same
status.jsonfiles pi-subagents uses for its own outstanding-work check, so no dependency and no configuration. Without pi-subagents installed the check is a no-op.
The nudge
The user is AFK. Continue productive work autonomously: finish open tasks, verify with tests/builds, review your own diff, tidy up, then pick up the next unblocked item.
Only when EVERY remaining item genuinely requires a human decision, call the
afk_blockedtool listing each blocker and the exact decision needed. Do not stop or ask questions otherwise — no one is reading.
It is sent as a visible custom message (customType: "afk-nudge"), so it shows in the transcript and the model can see it is not you.
Known limits
- A crashed subagent that leaves a stale
runningstatus behind suppresses nudges until pi-subagents reconciles it. - If the model stops without calling
afk_blockedand without making progress, you pay for up to 25 idle turns. LowerMAX_NUDGESinafk.tsif that bothers you.
Development
npm install
npm run typecheck
npm test # node --test, no framework
pi -e ./afk.ts # try it in a session
MIT