A loop sends a conversation the same prompt on a clock: "check the deploy every 5 minutes and tell me if it is unhealthy". A monitor wakes it when a command prints something: "tell me when an error shows up in the log", or "tell me when the build finishes". A goal keeps it working, round after round, until something is true: "every suite in make test-pic passes". pic saves them in the journal, so they outlive the terminal they were started in and a crash never sends a run twice.
Starting one
In the terminal, /loop 5m check the deploy and tell me if it is unhealthy. The interval is a
number with s, m, h or d (90s, 5m, 1h30m, 1d); the shortest is one minute, and a
loop given none runs every 10 minutes. The first run starts now. pic answers with what it made:
● loop L1 every 5m · first run now · about 41k tokens a run · ends in 7 days
fires while pic is open here or pic remote runs · Esc during its run pauses it · /loop lists it
From a shell, pic loop --session ID 5m PROMPT does the same (without --session, in a new
conversation). A conversation can have eight loops at once.
While it runs
Each run is a request of its own, with a last line saying a loop sent it, so the model knows you
did not just type it. If a request is running when a loop comes due, the loop's run waits and goes
next, as a follow-up does. A loop never stacks up: while one run waits, the loop does not fire
again. The footer names the next loop and when it runs (loop L1 in 3:12), and what loops have
spent once they have spent anything.
pic has no timer of its own. A loop fires while a pic is open in its workspace (the terminal
interface, or a request running there), or while pic remote runs, which keeps loops going with
the terminal closed and lets a paired phone pause, resume and stop them (remote
control). When none is, nothing fires:
the list says "not firing", and the first pic to open the journal fires it once, however many runs
it missed; that run says how many came due.
Stopping one
- Esc during a loop's run stops the run and pauses the loop.
/loop resume L1starts it again. /stoppauses every loop and monitor of the conversation and shows the list./loopshows the list:ppauses the chosen loop,rresumes it,sstops it for good,apauses them all./loop pause L1,/loop resume L1,/loop stop L1; from a shell,pic loop pause L1and the rest.
A loop ends on its own 7 days after it started; its last run says so. Paused loops are kept until you stop them.
Monitors
/monitor tail -f log/app.log | grep --line-buffered ERROR runs the command in the workspace, apart
from pic, and each new line it prints wakes the conversation with that line. Lines that come while
a run is going are sent together with the next one, at most 8 KB of the newest, with a count of
what was left out and where the whole output is kept. A line still being written waits until it
ends. /monitor --done make test wakes the conversation once, when the command exits, with its
exit status and the last of what it printed: "tell me when the build finishes".
The command outlives the terminal and pic itself; a pic that starts later reads on from where the
last one stopped, so no line is sent twice. When the command exits, the monitor sends what was
left and ends. If it was killed without exiting (the computer restarted), the monitor ends saying
so, unless you started it with --restart, which says the command is safe to run again: then pic
starts it again. Stopping the monitor (/loop stop M2, or s in the list) stops the command;
pausing it leaves the command running and holds its output until you resume. From a shell, pic
monitor --session ID [--done] [--restart] COMMAND.
Use a command that flushes each line (grep --line-buffered, not plain grep), or its lines
arrive in bursts.
Goals
/goal every suite in make test-pic passes --check "make test-pic" starts round 1 now. When a round
(a request) ends, pic runs the check; exit 0 ends the goal as met. Otherwise the next round starts,
telling the model how the check exited and the end of what it printed. Without --check, the goal
ends when the model says it is met, and the list says "declared done, not checked", so nobody takes
it for a pass. One goal at a time per conversation.
A goal stops and waits for you after 50 rounds (--rounds N from a shell), after 3 rounds in a row
that made no progress (changed no file, ran no command, or left the check saying what it said the
round before), or when the model says it cannot be met. /goal resume goes on, with 10 more
rounds if it reached its limit; /goal pause and /goal clear pause and end it. If pic stops while
the check runs, the check is not run again: that round counts as one with no progress. From a
shell, pic goal --session ID [--check CMD] [--rounds N] CONDITION.
When the model starts one
The model can start these too, with its wake tool: a monitor whenever it helps ("tell me when the
build finishes" in plain words works). A loop or a goal it asks for waits, firing nothing, until
you answer: the terminal asks in one line, The model wants to start loop L2: every 10m 'check
CI'., where y starts it and n refuses it (Esc leaves it waiting; /loop approve L2 or /loop
decline L2 answers later, and y or n in the /loop list). A paired phone shows it with Start
and No and sends a notification. Either way the model is told your answer. It can also pace a loop you started without an interval (each run it chooses
when the next comes, from a minute to an hour; otherwise every 10 minutes) and say a goal is done
or blocked. Whoever started them, they show in the footer and in /loop, and stop the same way.
pic settings loops.tool false takes the tool away from new conversations.
What a loop costs
There is no spending cap: each run is a full request with the conversation's context, so a loop
every 5 minutes for a day is about 290 requests. pic loop lists each loop with its runs and what
they cost, and pic usage --by-wake adds tokens. pic ps lists the workspace's loops after its
processes.
For hooks and scripts
A loop's run arrives through the inbox with sender wake:ID, so a UserPromptSubmit hook sees
that origin and can refuse it. pic loop fire fires what is due now and starts the requests, as the
terminal does on its own; pic loop --json prints the list as JSON.