Long Wait
Delegate terminal ownership to a fresh, clean-context monitor. Keep ordinary terminal polling inside that monitor and wake the main thread only for scheduled checkpoints or terminal completion.
Input contract
Determine these values before spawning:
command: exact non-interactive command to execute once.
workdir: command working directory.
success_condition: expected exit status or completion artifact.
report_target: parent agent's canonical task path.
result_paths: optional exact paths to report at completion.
log_path: optional detailed log path.
deadline: optional duration; default to 24 hours.
checkpoint_interval_seconds: optional; default to 3600 seconds.
expected_duration_seconds: optional performance budget. Crossing it requests diagnosis but never stops the command.
progress_probe: optional exact read-only shell command. It must finish within 30 seconds and may emit one compact JSON object with status, phase, completed, total, eta_seconds, and message.
Do not start the command until a fresh monitor slot is available.
Prepare a slot
- Inspect available capacity with
list_agents once when exposed; otherwise attempt the fresh spawn and handle a capacity response through event waiting.
- If capacity is available, spawn the monitor immediately.
- Never interrupt a working agent to obtain a slot.
- If capacity is full, wait for an agent event. A non-terminal checkpoint does not release a slot; consume it and return to event waiting without dense status polling.
- When a terminal event releases capacity, attempt the fresh monitor spawn. Never reuse an existing thread.
Setup and select a monitor
For installation or a missing role, read setup. The role
configuration is bundled at assets/long-wait-monitor.toml,
including its execution instructions. Installing the skill folder alone does not
register a custom agent in the host.
Inspect the actual tool schema and available models; choose a supported path:
- Registered role (preferred): select
long_wait_monitor through the host's
role selector, for example agent_type="long_wait_monitor". The field name may
differ. Let the role supply its model and reasoning settings when they are locked.
- Explicit configuration: when custom-role selection is unavailable, create a
fresh child using the host's explicit model and reasoning parameters. Prefer
model="gpt-5.6-terra", reasoning_effort="low"; use another available lightweight
model or supported effort when needed. Read the bundled TOML and include its
developer_instructions text, the input contract, and the protocol below in the
child's self-contained message. This is a configured monitor, not a registered
role; report the selected path and settings accurately.
Both paths require a fresh context: use fork_turns="none" or the host's documented
fresh-context equivalent, a unique task name, terminal ownership, and event/message
reporting to the parent. A nickname never proves role selection. Do not silently
inherit the parent's full history or model when explicit configuration is needed.
Honor stronger project or host requirements; this skill does not override them.
If neither path can provide a fresh configured child with terminal and reporting
capabilities, explain the missing capability before launch. Offer the concrete
setup steps or a supported local client; do not pretend installation changes the
current tool schema. Ordinary parent-owned execution is a different workflow.
Send only the input contract and monitor instructions, not the parent conversation.
Once the monitor starts the command, never rerun it. A failed monitor may be replaced
only through read-only recovery when an independent launcher owns the live task.
Monitor execution protocol
Instruct the monitor to:
Shell-quote the original command and launch it exactly once inside one outer Bash wrapper. Immediately before timeout --signal=TERM --kill-after=30s <deadline> bash -lc <shell-quoted-command>, capture the Bash SECONDS value. After timeout returns, capture $?, compute the total elapsed seconds, print one LONG_WAIT_RESULT exit_code=<code> duration_seconds=<seconds> sentinel, and exit with the captured code. Use 24 hours when deadline is omitted. Apply the timeout to the entire foreground command chain. With a detached launcher, this bounds monitoring only; bind an exact read-only launcher status command and task identity before launch.
Start one terminal session with yield_time_ms=1000 and max_output_tokens=2000, retain its session_id, and poll only that session until the process exits. When terminal tools are nested under functions.exec, reuse the same terminal session and use functions.wait only to resume a yielded exec cell.
Poll with empty input and max_output_tokens=2000. Set yield_time_ms to the smaller of 300000, the host's permitted wait limit, and the milliseconds remaining before the next checkpoint. Keep normal polls inside the monitor; do not wake the parent.
At each checkpoint interval, run progress_probe once when supplied, with a 30-second timeout. Sample only exact log_path and result_paths metadata. Do not recursively scan directories, read source files, or read full logs. Treat probe errors or invalid output as unknown until the next scheduled checkpoint.
Classify checkpoints as:
progressing when structured progress advances, the phase changes, or an exact result artifact changes;
unknown for the first interval without enough evidence;
attention with attention_kind="task_attention" when a successful structured probe explicitly reports task failure, expected_duration_seconds is exceeded, or two consecutive checkpoints show no observable change.
Use attention_kind=null for progressing and unknown. Only the parent may emit monitor_attention for a missing checkpoint or failed monitor.
Use a probe-provided ETA when available. Otherwise estimate it only from two advancing completed/total checkpoints. Report eta_seconds=null when neither is available. Never infer completion from CPU use, liveness, terminal output, or log growth.
Send one compact checkpoint to report_target:
{
"type": "long_wait_checkpoint",
"task": "task_name",
"elapsed_seconds": 7200,
"state": "progressing|unknown|attention",
"attention_kind": null,
"phase": null,
"completed": null,
"total": null,
"eta_seconds": null,
"reason": "short explanation"
}
Continue owning the same terminal after every checkpoint. Send at most one scheduled checkpoint per interval, including when the evidence is unchanged.
Treat exit code 124 as foreground timed_out. For a detached launcher, query the bound status command once with a 30-second timeout and report task_status and task_exit_code separately, using unknown if identity cannot be verified. Monitoring timeout does not prove the worker stopped. Never restart the command. On failure, read at most the final 50 lines of the exact log path when supplied.
Read the real exit code and total duration from LONG_WAIT_RESULT. Never substitute one poll's wall_time_seconds for total command duration.
On terminal completion, immediately return only status, exit_code, duration, result_paths, and a short failure tail when applicable. Finish so the terminal event wakes the parent.
Parent waiting protocol
- After the valid spawn, wait for an agent event (for example
wait_agent(timeout_ms=3600000)). Respect the host's supported wait limits and higher-priority responsiveness requirements; use the longest permitted event wait.
- On
progressing or first-interval unknown, return to event waiting. Surface routine progress only when requested; always surface meaningful changes, completion, failure, or required user action.
- On
task_attention, perform one bounded read-only diagnosis using the supplied status command, exact process state, exact artifact/log timestamps, and at most 50 log lines. Do not repeat it while the reason and evidence are unchanged. Never stop, restart, or change the task without user authorization.
- If a full checkpoint interval elapses without a checkpoint or terminal event, inspect the agent once (using
list_agents when available) and classify this as monitor_attention. A shorter host-limited wait timeout alone is not a missed checkpoint. This measures the monitoring channel, not task progress. Inspect the monitor once and return to event waiting without short polls.
- Return early for user steering or an approval requirement. Otherwise consume the real terminal result and report the compact outcome.
- If the monitor fails after launch, report
monitor_attention, inspect the independent project launcher once, and apply the monitor-only recovery protocol below. Never rerun the command automatically.
Monitor-only recovery
Recover only the monitoring channel; never recover by restarting computation.
- After an observed monitor failure, call
list_agents once and inspect the
independent project launcher once.
- Reattach only when the launcher explicitly identifies the same canonical
task as running and no valid monitor still owns it.
- Use a fresh monitor through either supported setup path above. Its
only command must be the project-owned read-only blocking wait entry point;
never repeat
start or the original command. Treat its first successful
progress probe as a new baseline.
- Monitor-only recovery has no fixed retry limit while those conditions remain
true. Communication-layer failures such as a response-stream disconnect may
therefore be recovered repeatedly without user intervention.
- Recovery remains event-driven: perform at most one reattachment for each
observed monitor failure and never spawn in a tight retry loop.
- Stop and request user direction when launcher state or task identity is
ambiguous, the canonical task is no longer running, recovery would mutate
task state, or a locally fixable helper/probe defect has not been corrected.
Invariants
- Execute the command at most once.
- Use a fresh configured monitor with no inherited conversation history.
- Each monitor keeps one terminal session for its lifetime. A replacement
monitor may own only the project launcher's read-only blocking wait command.
- Keep ordinary polls inside the clean-context monitor and limit each poll to 300 seconds.
- Attempt one checkpoint per configured interval; default to 3600 seconds.
- Report completion and failure immediately with the real exit code.
- Never stop, restart, mutate, or rerun the task automatically. Repeated
monitor-only reattachment is allowed only under the recovery checks above.
1---2name: long-wait3description: Run and monitor non-interactive local commands expected to take more than five minutes with a fresh low-effort subagent, hourly progress checkpoints, and immediate real exit-code reporting while minimizing main-thread token use. Use for long experiments, builds, analyses, training, exports, or whenever the user explicitly requests long-wait or monitor-agent execution.4---56# Long Wait78Delegate terminal ownership to a fresh, clean-context monitor. Keep ordinary terminal polling inside that monitor and wake the main thread only for scheduled checkpoints or terminal completion.910## Input contract1112Determine these values before spawning:1314- `command`: exact non-interactive command to execute once.15- `workdir`: command working directory.16- `success_condition`: expected exit status or completion artifact.17- `report_target`: parent agent's canonical task path.18- `result_paths`: optional exact paths to report at completion.19- `log_path`: optional detailed log path.20- `deadline`: optional duration; default to 24 hours.21- `checkpoint_interval_seconds`: optional; default to 3600 seconds.22- `expected_duration_seconds`: optional performance budget. Crossing it requests diagnosis but never stops the command.23- `progress_probe`: optional exact read-only shell command. It must finish within 30 seconds and may emit one compact JSON object with `status`, `phase`, `completed`, `total`, `eta_seconds`, and `message`.2425Do not start the command until a fresh monitor slot is available.2627## Prepare a slot28291. Inspect available capacity with `list_agents` once when exposed; otherwise attempt the fresh spawn and handle a capacity response through event waiting.302. If capacity is available, spawn the monitor immediately.313. Never interrupt a working agent to obtain a slot.324. If capacity is full, wait for an agent event. A non-terminal checkpoint does not release a slot; consume it and return to event waiting without dense status polling.335. When a terminal event releases capacity, attempt the fresh monitor spawn. Never reuse an existing thread.3435## Setup and select a monitor3637For installation or a missing role, read [setup](references/setup.md). The role38configuration is bundled at [assets/long-wait-monitor.toml](assets/long-wait-monitor.toml),39including its execution instructions. Installing the skill folder alone does not40register a custom agent in the host.4142Inspect the actual tool schema and available models; choose a supported path:4344- **Registered role (preferred):** select `long_wait_monitor` through the host's45 role selector, for example `agent_type="long_wait_monitor"`. The field name may46 differ. Let the role supply its model and reasoning settings when they are locked.47- **Explicit configuration:** when custom-role selection is unavailable, create a48 fresh child using the host's explicit model and reasoning parameters. Prefer49 `model="gpt-5.6-terra"`, `reasoning_effort="low"`; use another available lightweight50 model or supported effort when needed. Read the bundled TOML and include its51 `developer_instructions` text, the input contract, and the protocol below in the52 child's self-contained message. This is a configured monitor, not a registered53 role; report the selected path and settings accurately.5455Both paths require a fresh context: use `fork_turns="none"` or the host's documented56fresh-context equivalent, a unique task name, terminal ownership, and event/message57reporting to the parent. A nickname never proves role selection. Do not silently58inherit the parent's full history or model when explicit configuration is needed.59Honor stronger project or host requirements; this skill does not override them.6061If neither path can provide a fresh configured child with terminal and reporting62capabilities, explain the missing capability before launch. Offer the concrete63setup steps or a supported local client; do not pretend installation changes the64current tool schema. Ordinary parent-owned execution is a different workflow.6566Send only the input contract and monitor instructions, not the parent conversation.67Once the monitor starts the command, never rerun it. A failed monitor may be replaced68only through read-only recovery when an independent launcher owns the live task.6970## Monitor execution protocol7172Instruct the monitor to:73741. Shell-quote the original command and launch it exactly once inside one outer Bash wrapper. Immediately before `timeout --signal=TERM --kill-after=30s <deadline> bash -lc <shell-quoted-command>`, capture the Bash `SECONDS` value. After `timeout` returns, capture `$?`, compute the total elapsed seconds, print one `LONG_WAIT_RESULT exit_code=<code> duration_seconds=<seconds>` sentinel, and exit with the captured code. Use 24 hours when `deadline` is omitted. Apply the timeout to the entire foreground command chain. With a detached launcher, this bounds monitoring only; bind an exact read-only launcher status command and task identity before launch.752. Start one terminal session with `yield_time_ms=1000` and `max_output_tokens=2000`, retain its `session_id`, and poll only that session until the process exits. When terminal tools are nested under `functions.exec`, reuse the same terminal session and use `functions.wait` only to resume a yielded exec cell.763. Poll with empty input and `max_output_tokens=2000`. Set `yield_time_ms` to the smaller of 300000, the host's permitted wait limit, and the milliseconds remaining before the next checkpoint. Keep normal polls inside the monitor; do not wake the parent.774. At each checkpoint interval, run `progress_probe` once when supplied, with a 30-second timeout. Sample only exact `log_path` and `result_paths` metadata. Do not recursively scan directories, read source files, or read full logs. Treat probe errors or invalid output as `unknown` until the next scheduled checkpoint.785. Classify checkpoints as:79 - `progressing` when structured progress advances, the phase changes, or an exact result artifact changes;80 - `unknown` for the first interval without enough evidence;81 - `attention` with `attention_kind="task_attention"` when a successful structured probe explicitly reports task failure, `expected_duration_seconds` is exceeded, or two consecutive checkpoints show no observable change.82 Use `attention_kind=null` for `progressing` and `unknown`. Only the parent may emit `monitor_attention` for a missing checkpoint or failed monitor.836. Use a probe-provided ETA when available. Otherwise estimate it only from two advancing `completed`/`total` checkpoints. Report `eta_seconds=null` when neither is available. Never infer completion from CPU use, liveness, terminal output, or log growth.847. Send one compact checkpoint to `report_target`:8586 ```json87 {88 "type": "long_wait_checkpoint",89 "task": "task_name",90 "elapsed_seconds": 7200,91 "state": "progressing|unknown|attention",92 "attention_kind": null,93 "phase": null,94 "completed": null,95 "total": null,96 "eta_seconds": null,97 "reason": "short explanation"98 }99 ```1001018. Continue owning the same terminal after every checkpoint. Send at most one scheduled checkpoint per interval, including when the evidence is unchanged.1029. Treat exit code `124` as foreground `timed_out`. For a detached launcher, query the bound status command once with a 30-second timeout and report `task_status` and `task_exit_code` separately, using unknown if identity cannot be verified. Monitoring timeout does not prove the worker stopped. Never restart the command. On failure, read at most the final 50 lines of the exact log path when supplied.10310. Read the real exit code and total duration from `LONG_WAIT_RESULT`. Never substitute one poll's `wall_time_seconds` for total command duration.10411. On terminal completion, immediately return only `status`, `exit_code`, `duration`, `result_paths`, and a short failure tail when applicable. Finish so the terminal event wakes the parent.105106## Parent waiting protocol1071081. After the valid spawn, wait for an agent event (for example `wait_agent(timeout_ms=3600000)`). Respect the host's supported wait limits and higher-priority responsiveness requirements; use the longest permitted event wait.1092. On `progressing` or first-interval `unknown`, return to event waiting. Surface routine progress only when requested; always surface meaningful changes, completion, failure, or required user action.1103. On `task_attention`, perform one bounded read-only diagnosis using the supplied status command, exact process state, exact artifact/log timestamps, and at most 50 log lines. Do not repeat it while the reason and evidence are unchanged. Never stop, restart, or change the task without user authorization.1114. If a full checkpoint interval elapses without a checkpoint or terminal event, inspect the agent once (using `list_agents` when available) and classify this as `monitor_attention`. A shorter host-limited wait timeout alone is not a missed checkpoint. This measures the monitoring channel, not task progress. Inspect the monitor once and return to event waiting without short polls.1125. Return early for user steering or an approval requirement. Otherwise consume the real terminal result and report the compact outcome.1136. If the monitor fails after launch, report `monitor_attention`, inspect the independent project launcher once, and apply the monitor-only recovery protocol below. Never rerun the command automatically.114115## Monitor-only recovery116117Recover only the monitoring channel; never recover by restarting computation.1181191. After an observed monitor failure, call `list_agents` once and inspect the120 independent project launcher once.1212. Reattach only when the launcher explicitly identifies the same canonical122 task as running and no valid monitor still owns it.1233. Use a fresh monitor through either supported setup path above. Its124 only command must be the project-owned read-only blocking wait entry point;125 never repeat `start` or the original command. Treat its first successful126 progress probe as a new baseline.1274. Monitor-only recovery has no fixed retry limit while those conditions remain128 true. Communication-layer failures such as a response-stream disconnect may129 therefore be recovered repeatedly without user intervention.1305. Recovery remains event-driven: perform at most one reattachment for each131 observed monitor failure and never spawn in a tight retry loop.1326. Stop and request user direction when launcher state or task identity is133 ambiguous, the canonical task is no longer running, recovery would mutate134 task state, or a locally fixable helper/probe defect has not been corrected.135136## Invariants137138- Execute the command at most once.139- Use a fresh configured monitor with no inherited conversation history.140- Each monitor keeps one terminal session for its lifetime. A replacement141 monitor may own only the project launcher's read-only blocking wait command.142- Keep ordinary polls inside the clean-context monitor and limit each poll to 300 seconds.143- Attempt one checkpoint per configured interval; default to 3600 seconds.144- Report completion and failure immediately with the real exit code.145- Never stop, restart, mutate, or rerun the task automatically. Repeated146 monitor-only reattachment is allowed only under the recovery checks above.