Skip to content
pi-c Artifact [4734f37234]
Login

Artifact [4734f37234]

Artifact 4734f372348831eb23225005df6ab73c38206627726cb6ec9e7fab8f6c2b8cbd:


Loops

A loop sends a conversation the same prompt on a clock: "check the deploy every 5 minutes and tell me if it is unhealthy". pic saves it in the journal, so a loop outlives the terminal it was 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

A loop ends on its own 7 days after it started; its last run says so. Paused loops are kept until you stop them.

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.