Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/pre-release/bootstrap-pre-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ agent_turn() {
# FRESH turn is worse, because the agent then has to rediscover all of that.
SETUP_RESUME_NUDGE='Your previous turn ended before setup finished. Do NOT restart anything that is already running. Check on the install you launched: if it is still in progress, keep monitoring it and only answer once it has finished. Once it has finished successfully, complete any remaining setup steps and then reply with exactly the completion line the setup instructions asked for. If it has failed, report the failure.'

DEMO_RESUME_NUDGE='Your previous turn ended without leaving a running optimize behind, and nothing has been written under the workspace since, so the work is not progressing. Do NOT fabricate a result. Finish the launch in THIS turn: complete the install if it is still needed, start optimize detached with setsid nohup so it survives the end of this turn, then confirm the nested session run dir and its state.json exist and report their paths.'
DEMO_RESUME_NUDGE='Your previous turn ended without leaving a running optimize behind, and nothing has been written under the workspace since, so the work is not progressing. Do NOT fabricate a result. Finish the launch in THIS turn: complete the install if it is still needed, start optimize detached the way the skill prescribes (run_in_background=true when CLAW_SESSION_ID is set and your bash tool offers that parameter, otherwise setsid nohup) so it survives the end of this turn, then confirm the nested session run dir and its state.json exist and report their paths.'

# Clean terminal stop_reason values (hyperloom.inference_optimizer.breakdown.stop_reasons.SUCCESS_STOP_REASONS).
is_clean_stop_reason() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ killed the moment the turn ends. So:
progress note such as "install started", "waiting on the pull", or "waiting on the
monitor" — that kills the work you just started and the leg ends up with nothing
running at all.
2. Start `optimize` **detached** with `setsid nohup` (as the demo skill does) so it
2. Start `optimize` **detached** the way the demo skill does — `run_in_background=true` when `$CLAW_SESSION_ID` is set and the bash tool offers it, `setsid nohup` otherwise — so it
survives the end of this turn.
3. Before you finish, confirm the run is really live and report the paths: the nested
session run dir exists, `state.json` is present in it, and the optimizer PID is alive.
Expand Down
2 changes: 1 addition & 1 deletion .github/pre-release/prompts/pre-release/demo-12h.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ killed the moment the turn ends. So:
progress note such as "install started", "waiting on the pull", or "waiting on the
monitor" — that kills the work you just started and the leg ends up with nothing
running at all.
2. Start `optimize` **detached** with `setsid nohup` (as the demo skill does) so it
2. Start `optimize` **detached** the way the demo skill does — `run_in_background=true` when `$CLAW_SESSION_ID` is set and the bash tool offers it, `setsid nohup` otherwise — so it
survives the end of this turn.
3. Before you finish, confirm the run is really live and report the paths: the nested
session run dir exists, `state.json` is present in it, and the optimizer PID is alive.
Expand Down
2 changes: 1 addition & 1 deletion .github/pre-release/prompts/pre-release/demo-3h.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ killed the moment the turn ends. So:
progress note such as "install started", "waiting on the pull", or "waiting on the
monitor" — that kills the work you just started and the leg ends up with nothing
running at all.
2. Start `optimize` **detached** with `setsid nohup` (as the demo skill does) so it
2. Start `optimize` **detached** the way the demo skill does — `run_in_background=true` when `$CLAW_SESSION_ID` is set and the bash tool offers it, `setsid nohup` otherwise — so it
survives the end of this turn.
3. Before you finish, confirm the run is really live and report the paths: the nested
session run dir exists, `state.json` is present in it, and the optimizer PID is alive.
Expand Down
62 changes: 55 additions & 7 deletions examples/hyperloom-custom-advanced/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ export RUN_LOG="$RUN_DIR/run_${RUN_TAG}.log"
export PID_FILE="$RUN_DIR/run_${RUN_TAG}.pid"
export LAUNCH_INFO_FILE="$RUN_DIR/launch_${RUN_TAG}.json"
mkdir -p "$RUN_DIR"
# $RUN_TAG is timestamped and cannot be recomputed, and under Claw the launch
# and the health check are separate tool calls with separate shells. Persist the
# run-scoped vars so the health-check block can source them. Session-scoped
# filename, for the same WekaFS reason setup_env.sh must never be shared: set
# $RUN_ENV yourself before launching if two non-Claw runs share a host, or the
# second launch overwrites the first one's run vars and the health checks
# reconcile the wrong pidfile.
export RUN_ENV="$RUN_DIR/run_env_${CLAW_SESSION_ID:-$(hostname)}.sh"
printf 'export RUN_TAG=%q RUN_DIR=%q RUN_LOG=%q PID_FILE=%q LAUNCH_INFO_FILE=%q\n' \
"$RUN_TAG" "$RUN_DIR" "$RUN_LOG" "$PID_FILE" "$LAUNCH_INFO_FILE" > "$RUN_ENV"

export FRAMEWORK="${FRAMEWORK:-sglang}"
export TP="${TP:-1}"
Expand Down Expand Up @@ -336,17 +346,55 @@ OPT_FLAGS=(
[ "${NO_CONC_SWEEP:-0}" = "1" ] && OPT_FLAGS+=(--no-enable-conc-sweep)
[ "${NO_ROOFLINE:-0}" = "1" ] && OPT_FLAGS+=(--no-enable-roofline)

setsid nohup python3 -m hyperloom.inference_optimizer.cli --verbose optimize \
# Detach per the rule above: run_in_background=true when both conditions hold, or prefix
# `setsid nohup` and append ` &` elsewhere. Either way $PID_FILE is reconciled
# from the launch-info JSON in the health-check block below -- the tool returns
# a shell_id, and $! is the setsid wrapper.
python3 -m hyperloom.inference_optimizer.cli --verbose optimize \
"${OPT_FLAGS[@]}" \
> "$RUN_LOG" 2>&1 < /dev/null &
echo $! > "$PID_FILE"
> "$RUN_LOG" 2>&1 < /dev/null
```

The health check is a **separate** block on purpose, and under Claw it must be a
separate foreground tool call. Appending it to the launch block would put the
`sleep 30` and every line it prints into the background too, where you would not
see them without polling `bash_output`. The harness branch above therefore
applies to the launch command only:

```bash
sleep 30
# Separate shell under Claw, so re-source what the launch block exported.
RUN_ENV="${RUN_ENV:-${USER_DATA_PATH:?USER_DATA_PATH missing}/optimizer_runs/run_env_${CLAW_SESSION_ID:-$(hostname)}.sh}"
. "$RUN_ENV"
read_json() { python3 -c "import json,sys;print(json.load(open(sys.argv[1])).get(sys.argv[2],''))" "$1" "$2" 2>/dev/null; }
REAL_PID="$(read_json "$LAUNCH_INFO_FILE" pid)"
[ -z "$REAL_PID" ] && REAL_PID="$(pgrep -f 'hyperloom.inference_optimizer.cli .*optimize' | head -1)"
[ -n "$REAL_PID" ] && echo "$REAL_PID" > "$PID_FILE"
test -d "/proc/$REAL_PID" && echo "optimizer_alive=true pid=$REAL_PID"
if [ -z "$REAL_PID" ]; then
# Best-effort only, and UNSAFE with concurrent sessions on this host: the
# pattern matches every optimizer running here and nothing ties a hit to this
# run. Take it only when unambiguous rather than `head -1`-ing a list, which
# would adopt another session's pid.
MATCHES="$(pgrep -f 'hyperloom.inference_optimizer.cli .*optimize' || true)"
N_MATCHES="$(printf '%s\n' "$MATCHES" | grep -c . || true)"
if [ "$N_MATCHES" = "1" ]; then
REAL_PID="$MATCHES"
else
echo "ERROR: no .pid in $LAUNCH_INFO_FILE and pgrep is ambiguous" \
"($N_MATCHES matches); refusing to guess. Inspect $RUN_LOG." >&2
fi
fi
if [ -n "$REAL_PID" ]; then
echo "$REAL_PID" > "$PID_FILE"
else
# Never leave the dead setsid `$!` wrapper pid in the file -- the monitor
# would read it and fire a spurious resume. Absent means "unknown", which
# sends the monitor to the lock/heartbeat/lease signals instead.
rm -f "$PID_FILE"
echo "WARN: removed $PID_FILE (no authoritative pid)." >&2
fi
# Not `test -d /proc/$pid`: a zombie keeps its /proc entry and sandbox PID 1
# does not reap, so that reports a dead optimizer as alive indefinitely.
ps -o stat= -p "$REAL_PID" 2>/dev/null | grep -qv '^Z' \
&& echo "optimizer_alive=true pid=$REAL_PID"

SESSION_DIR="$(read_json "$LAUNCH_INFO_FILE" session_dir)"
if [ -z "$SESSION_DIR" ]; then
Expand Down Expand Up @@ -412,7 +460,7 @@ and the stop reason. Never print API keys, tokens, or custom header values.
2. Keep `PYTHONPATH="$REPO_ROOT:${PYTHONPATH:-}"` in the launch shell so
robustness and critic subprocesses can import `hyperloom.agents` after
changing cwd.
3. Run in background with `setsid nohup`.
3. Run it detached the way the harness understands: if `$CLAW_SESSION_ID` is set and your bash tool takes a `run_in_background` parameter, hand the command to it with `run_in_background=true`; otherwise use `setsid nohup ... &`. See the Launch section of the packaged `hyperloom/inference_optimizer/SKILL.md` for why — a hand-detached run is invisible to Claw and its sandbox is reclaimed about fifteen minutes after the turn ends.
4. Pass all required workload flags in the
`python -m hyperloom.inference_optimizer.cli optimize` command. Do not rely
on `.env` alone for `TP`, `CONC`, `ISL`, `OSL`, or `PRECISION`.
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperloom-qwen3-14b-fp8-12h-atom/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ and the stop reason. Never print API keys, tokens, or custom header values.
`KERNEL_OPT_BACKEND_ORDER` unset so the ATOM default applies.
3. Keep `PYTHONPATH="$REPO_ROOT:${PYTHONPATH:-}"` in the launch shell so robustness
and critic subprocesses can import `hyperloom.agents` after changing cwd.
4. Run in background with `setsid nohup`.
4. Run it detached the way the harness understands: if `$CLAW_SESSION_ID` is set and your bash tool takes a `run_in_background` parameter, hand the command to it with `run_in_background=true`; otherwise use `setsid nohup ... &`. See the Launch section of the packaged `hyperloom/inference_optimizer/SKILL.md` for why — a hand-detached run is invisible to Claw and its sandbox is reclaimed about fifteen minutes after the turn ends.
5. Pass all required optimize CLI flags in the `python -m hyperloom.inference_optimizer.cli optimize` command. Do not rely on `.env` alone for `TP`, `CONC`, `ISL`, `OSL`, or `PRECISION`; CLI defaults can otherwise override the intended workload.
6. Include `--max-minutes-framework-pct 0.43` and `--max-minutes-kernel-pct 0.42`
in the optimize command. Do **not** pass `--no-framework-agent` or `--no-kernel` —
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperloom-qwen3-14b-fp8-12h-forge/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ and the stop reason. Never print API keys, tokens, or custom header values.
docker mode, set it inside the same `docker exec` that runs `optimize`.
3. Keep `PYTHONPATH="$REPO_ROOT:${PYTHONPATH:-}"` in the launch shell so robustness
and critic subprocesses can import `hyperloom.agents` after changing cwd.
4. Run in background with `setsid nohup`.
4. Run it detached the way the harness understands: if `$CLAW_SESSION_ID` is set and your bash tool takes a `run_in_background` parameter, hand the command to it with `run_in_background=true`; otherwise use `setsid nohup ... &`. See the Launch section of the packaged `hyperloom/inference_optimizer/SKILL.md` for why — a hand-detached run is invisible to Claw and its sandbox is reclaimed about fifteen minutes after the turn ends.
5. Pass all required optimize CLI flags in the `python -m hyperloom.inference_optimizer.cli optimize` command. Do not rely on `.env` alone for `TP`, `CONC`, `ISL`, `OSL`, or `PRECISION`; CLI defaults can otherwise override the intended workload.
6. Include `--max-minutes-framework-pct 0.43` and `--max-minutes-kernel-pct 0.42`
in the optimize command. Do **not** pass `--no-framework-agent` or `--no-kernel` —
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperloom-qwen3-14b-fp8-12h/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ and the stop reason. Never print API keys, tokens, or custom header values.
`$USER_DATA_PATH/runtime/kernel-agent.env.sh` before launching.
2. Keep `PYTHONPATH="$REPO_ROOT:${PYTHONPATH:-}"` in the launch shell so robustness
and critic subprocesses can import `hyperloom.agents` after changing cwd.
3. Run in background with `setsid nohup`.
3. Run it detached the way the harness understands: if `$CLAW_SESSION_ID` is set and your bash tool takes a `run_in_background` parameter, hand the command to it with `run_in_background=true`; otherwise use `setsid nohup ... &`. See the Launch section of the packaged `hyperloom/inference_optimizer/SKILL.md` for why — a hand-detached run is invisible to Claw and its sandbox is reclaimed about fifteen minutes after the turn ends.
4. Pass all required optimize CLI flags in the `python -m hyperloom.inference_optimizer.cli optimize` command. Do not rely on `.env` alone for `TP`, `CONC`, `ISL`, `OSL`, or `PRECISION`; CLI defaults can otherwise override the intended workload.
5. Include `--max-minutes-framework-pct 0.43` and `--max-minutes-kernel-pct 0.42`
in the optimize command. Do **not** pass `--no-framework-agent` or `--no-kernel` —
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperloom-qwen3-8b-3h/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ and the stop reason. Never print API keys, tokens, or custom header values.
`$USER_DATA_PATH/runtime/kernel-agent.env.sh` before launching.
2. Keep `PYTHONPATH="$REPO_ROOT:${PYTHONPATH:-}"` in the launch shell so robustness
and critic subprocesses can import `hyperloom.agents` after changing cwd.
3. Run in background with `setsid nohup`.
3. Run it detached the way the harness understands: if `$CLAW_SESSION_ID` is set and your bash tool takes a `run_in_background` parameter, hand the command to it with `run_in_background=true`; otherwise use `setsid nohup ... &`. See the Launch section of the packaged `hyperloom/inference_optimizer/SKILL.md` for why — a hand-detached run is invisible to Claw and its sandbox is reclaimed about fifteen minutes after the turn ends.
4. Pass all required optimize CLI flags in the `python -m hyperloom.inference_optimizer.cli optimize` command. Do not rely on `.env` alone for `TP`, `CONC`, `ISL`, `OSL`, or `PRECISION`; CLI defaults can otherwise override the intended workload.
5. Include `--max-minutes-framework-pct 0.50` and `--max-minutes-sweep-pct 0.01`
in the optimize command. These are the value *before* redistribution: with
Expand Down
Loading
Loading