summaryrefslogtreecommitdiff
path: root/pi/agent/extensions/loop-scheduler
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-11 22:23:43 +0300
committerPaul Buetow <paul@buetow.org>2026-04-11 22:23:43 +0300
commite7fa3d644d388db2891d2ec1d3f432e29579a641 (patch)
treec3734b3a6ab819acdef831d2d909ce952b448d85 /pi/agent/extensions/loop-scheduler
parent5f63e9139ec0b4a4ae30651f5a7a2f77c66a689c (diff)
update
Diffstat (limited to 'pi/agent/extensions/loop-scheduler')
-rw-r--r--pi/agent/extensions/loop-scheduler/README.md6
-rw-r--r--pi/agent/extensions/loop-scheduler/index.ts14
-rw-r--r--pi/agent/extensions/loop-scheduler/loop-presets.md4
3 files changed, 18 insertions, 6 deletions
diff --git a/pi/agent/extensions/loop-scheduler/README.md b/pi/agent/extensions/loop-scheduler/README.md
index 2f7a7cc..3e7ef37 100644
--- a/pi/agent/extensions/loop-scheduler/README.md
+++ b/pi/agent/extensions/loop-scheduler/README.md
@@ -5,6 +5,7 @@ Session-scoped recurring and reactive prompts for Pi.
This extension adds two commands for interactive Pi sessions:
- `/loop` re-sends a prompt on an interval while the current Pi process stays open.
+ The first run fires right after you create the loop; later runs use the interval.
- `/watch` posts a predefined prompt when the agent becomes idle or when an assistant response contains a substring.
## Commands
@@ -66,8 +67,8 @@ Start Pi in the repo, then run:
/loop 10m check whether the deployment finished and summarize what changed
```
-Pi will keep re-injecting that prompt every 10 minutes while the session stays
-open.
+The first run happens almost immediately (then every 10 minutes) while the
+session stays open.
### Flow 2: Loop another command
@@ -140,6 +141,7 @@ Preset lines use:
Loop jobs do not spam turns while Pi is busy.
+- for **Gemma 4** models, loop/watch prompts use `deliverAs: "followUp"` so Pi queues them if the runtime is still finishing a turn (avoids “Agent is already processing” after long streams)
- if a job becomes due while the agent is running, it is marked pending
- when the current work finishes, the next pending loop fires once
- missed intervals do not stack into a catch-up storm
diff --git a/pi/agent/extensions/loop-scheduler/index.ts b/pi/agent/extensions/loop-scheduler/index.ts
index b6ed621..af6b003 100644
--- a/pi/agent/extensions/loop-scheduler/index.ts
+++ b/pi/agent/extensions/loop-scheduler/index.ts
@@ -377,6 +377,13 @@ export default function loopSchedulerExtension(pi: ExtensionAPI): void {
lastCtx = ctx;
}
+ /** Gemma 4 sessions often hit a short "still processing" window after a turn; Pi requires deliverAs then. */
+ function sendScheduledUserMessage(prompt: string): void {
+ const id = lastCtx?.model?.id ?? "";
+ const gemma4 = /gemma[-_]?4|gemma4/i.test(id);
+ pi.sendUserMessage(prompt, gemma4 ? { deliverAs: "followUp" } : undefined);
+ }
+
async function openPresetFile(ctx: ExtensionContext, filePath: string, template: string, errorPrefix: string): Promise<void> {
if (!existsSync(filePath)) {
try {
@@ -537,7 +544,7 @@ export default function loopSchedulerExtension(pi: ExtensionAPI): void {
updateUi();
try {
- pi.sendUserMessage(job.prompt);
+ sendScheduledUserMessage(job.prompt);
notify(`Loop ${job.id} fired (${reason}).`, "info");
} catch (error) {
agentBusy = false;
@@ -600,7 +607,7 @@ export default function loopSchedulerExtension(pi: ExtensionAPI): void {
updateUi();
try {
- pi.sendUserMessage(job.prompt);
+ sendScheduledUserMessage(job.prompt);
notify(`Watch ${job.id} fired (${reason}).`, "info");
} catch (error) {
agentBusy = false;
@@ -656,7 +663,8 @@ export default function loopSchedulerExtension(pi: ExtensionAPI): void {
intervalMs,
intervalLabel,
createdAt: Date.now(),
- nextRunAt: Date.now() + intervalMs,
+ // First fire is ASAP; handleJobDue then sets nextRunAt to now + intervalMs for the repeating cadence.
+ nextRunAt: Date.now(),
pending: false,
paused: allPaused, // inherit the current global pause state so new jobs added while paused start paused
runs: 0,
diff --git a/pi/agent/extensions/loop-scheduler/loop-presets.md b/pi/agent/extensions/loop-scheduler/loop-presets.md
index 8d141fe..f90cad3 100644
--- a/pi/agent/extensions/loop-scheduler/loop-presets.md
+++ b/pi/agent/extensions/loop-scheduler/loop-presets.md
@@ -8,4 +8,6 @@
# * monitor: 10m check if there are any errors in the logs
* tasks: 1m automatically start with the next task with fresh context if the current task completed following the agent-task-management skill.
-* proceed: 1m proceed
+* proceed: 1m proceed with the next task following agent-task-management if the previous or currently tasks being worked on is completed and committed to git.
+* review: 1m review all code changes since the last review and add code review comments using agent-task-management skill. use go-bestpractices and SOLID skills.
+* scifi: 1m write a scifi story about the current project or continue writing the story into STORY.md.