@rakshazi/nosleep0.1.0
Block bash sleeps longer than 30 seconds in the main context
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
nosleep: stop a long sleep from parking the turn
Install with pi install npm:@rakshazi/nosleep.
A bash call whose command waits past 30 seconds through sleep is blocked before it runs. The reason says the wait is counterproductive and that a model with nothing left to do should end its turn instead of watching the clock.
The gate watches the main context only: subagents keep their long sleeps, since waiting on a build is part of their job.
What counts
The command string is scanned for the word sleep, and the operands that follow it are summed the way coreutils sums them, with the s, m, h and d suffixes:
| Command | Verdict |
|---|---|
sleep 30 |
allowed, the cap is exclusive |
sleep 30.5 |
blocked, 30.5s |
sleep 1m |
blocked, 60s |
sleep 1m 30s |
blocked, 90s |
make build && sleep 60 && make check |
blocked, and nothing runs, so the build is split off |
timeout 120 sleep 40 |
blocked, 40s |
for i in $(seq 1 20); do curl -sf localhost:8080/health && break; sleep 2; done |
allowed, every sleep is short |
rg -n sleep src/ |
allowed, no operand |
The block reason names the offending snippet and its total, explains why the wait costs more than it buys, and offers the alternatives: run the useful half of the chain now, poll in a bounded loop of short sleeps, or finish the turn and let the user call the model back.
Main context only
A session is treated as a subagent's when its header carries parentSession, or when it has no session file at all (SessionManager.inMemory). Those are the two shapes @tintinweb/pi-subagents creates for a child: a stamped persisted session, and an in-memory one for the nested spawns.
The test is cheap and session-wide, so it comes with two false positives:
/forkand/clonesessions copy the header field, so a forked conversation is exempt.- A main session started with
--no-sessionhas no file, so it is exempt too.
The marker
A wait that is genuinely needed gets a bypass. The model posts this as its own assistant message, sends it, and re-issues the command on the next turn:
i deliberately park my own turn for over 30 seconds because: <reason>
One marker clears one blocked call, the same shape as comment-gate's. A marker that was already in the transcript when the session loaded counts as history and clears nothing. The phrase is awkward on purpose: a model that cannot write the reason down probably did not need the sleep.
Limits
- The scan is a plain regex over the raw command.
echo "sleep 60", a heredoc and a trailing comment all count as a sleep. - A computed duration has no literal operand, so
sleep $DELAYpasses. - Only
bashis watched. Thepowershelltool is not. - It fails open: an error inside the extension shows a warning and lets the command through.