docs(prompts): wait on a PID instead of a self-matching pgrep -f loop
A wait loop like `while pgrep -f "pytest evals"` matches its own shell and runs until its timeout even after the job exits. Tell Claude and Codex owners to save the job PID and wait with kill -0, or use a [p]attern that cannot match itself, and to confirm the job finished afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,15 @@ Therefore:
|
|||||||
- If something genuinely cannot complete within one turn, do not pretend a notification is coming. Finish with a concrete status and explicitly ask the user to send a follow-up message to continue. For recurring polling of CI/scheduled work, use the `schedule_task` / `watch_ci` tools, which DO re-invoke you.
|
- If something genuinely cannot complete within one turn, do not pretend a notification is coming. Finish with a concrete status and explicitly ask the user to send a follow-up message to continue. For recurring polling of CI/scheduled work, use the `schedule_task` / `watch_ci` tools, which DO re-invoke you.
|
||||||
- Never leave an intermediate "I'll wait … I'll be notified" planning sentence as your final answer.
|
- Never leave an intermediate "I'll wait … I'll be notified" planning sentence as your final answer.
|
||||||
|
|
||||||
|
### Wait on a PID, not on `pgrep -f`
|
||||||
|
|
||||||
|
A wait loop like `while pgrep -f "pytest evals"; do sleep 10; done` matches its own shell, whose command line contains the same text. It never sees the job exit and runs until its timeout (2026-11-11: an eval finished at 16:47 but the loop only ended at 16:53, and every later wait lost minutes the same way).
|
||||||
|
|
||||||
|
- Save the PID when you start the job: `nohup <cmd> > "$HOME/.tmp/job.log" 2>&1 & echo $! > "$HOME/.tmp/job.pid"`
|
||||||
|
- Wait on that PID: `pid=$(cat "$HOME/.tmp/job.pid"); while kill -0 "$pid" 2>/dev/null; do sleep 10; done` (in the same shell, `wait "$pid"` is enough)
|
||||||
|
- If you can only match by name, use a pattern that cannot match itself: `pgrep -f "[p]ytest evals"`. This only works if the plain text (`pytest evals`) appears nowhere else in that same command, so do not launch and wait in one command this way
|
||||||
|
- When the loop ends, check the log tail or exit status to make sure the job finished and the loop did not just hit its timeout
|
||||||
|
|
||||||
## Media attachments
|
## Media attachments
|
||||||
|
|
||||||
When a locally generated image, screenshot, video, audio, or document should appear in Discord, include a `MEDIA:` directive on its own line with an absolute local path:
|
When a locally generated image, screenshot, video, audio, or document should appear in Discord, include a `MEDIA:` directive on its own line with an absolute local path:
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ Your output is sent directly to the Discord group.
|
|||||||
- Prefer reading the current workspace before making assumptions
|
- Prefer reading the current workspace before making assumptions
|
||||||
- Modify only what is needed for the task
|
- Modify only what is needed for the task
|
||||||
- Verify changes when you can instead of claiming they should work
|
- Verify changes when you can instead of claiming they should work
|
||||||
|
- When waiting for a long job, save its PID at launch and poll with `kill -0 "$pid"`. Do not poll with `pgrep -f "<text>"` from a shell whose own command line contains that text: it matches itself and only exits at its timeout. If you must match by name, use `pgrep -f "[p]ytest evals"`
|
||||||
- For CI/status/watch requests that require future follow-up, schedule `watch_ci`
|
- For CI/status/watch requests that require future follow-up, schedule `watch_ci`
|
||||||
- Do not use generic recurring task registration from Codex
|
- Do not use generic recurring task registration from Codex
|
||||||
- If the user wants a reminder or other non-CI recurring task, tell them to ask Claude/클코 to schedule it
|
- If the user wants a reminder or other non-CI recurring task, tell them to ask Claude/클코 to schedule it
|
||||||
|
|||||||
Reference in New Issue
Block a user