Skip to content

Commit 85804a4

Browse files
ambiorix2099claude
andcommitted
Fall back to gtimeout, or no timeout, when GNU timeout is absent
run_examples.sh calls `timeout`, which is GNU coreutils. macOS ships neither `timeout` nor `gtimeout` unless coreutils is installed, so every example failed there with "timeout: command not found". This is not new — `timeout` is on main — but it was unreachable until the glob fix in this PR. While the script collected zero examples it always exited 0 without invoking anything, so the dependency never fired. Now that it collects 142, a default run on a Mac fails every one of them for a reason that has nothing to do with the examples. Prefer `timeout`, fall back to `gtimeout`, and run unbounded with a warning if neither exists, rather than failing everything. The banner reports which of the two applies instead of always claiming a limit. Verified both branches against Conductor OSS 3.32.0, with 74 as the example: with no timeout binary, the warning prints and 74 passes in 6s; with coreutils installed, the banner reports the 300s limit and 74 passes in 5s. The skip list is honoured either way -- `run_examples.sh 60` reports "No examples to run." rather than touching the GitHub examples. Note the script also needs bash 4+ for `declare -A`, which stock macOS bash 3.2 does not provide. That is left alone here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent d383fcd commit 85804a4

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

scripts/run_examples.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ TIMEOUT="${EXAMPLE_TIMEOUT:-300}"
2121
# Cross-platform python: honour PYTHON env var, then try python3, then python.
2222
PYTHON="${PYTHON:-$(command -v python3 2>/dev/null || command -v python 2>/dev/null || echo python3)}"
2323

24+
# Cross-platform timeout: GNU coreutils provides `timeout`; macOS ships it as
25+
# `gtimeout`, and only when coreutils is installed. Without either, run the
26+
# examples unbounded rather than failing every one of them.
27+
TIMEOUT_BIN="$(command -v timeout 2>/dev/null || command -v gtimeout 2>/dev/null || true)"
28+
if [[ -z "$TIMEOUT_BIN" ]]; then
29+
echo "Warning: neither 'timeout' nor 'gtimeout' found; examples will run" >&2
30+
echo " without a time limit. On macOS: brew install coreutils" >&2
31+
fi
32+
2433
# Cross-platform temp dir: honour TMPDIR (set on macOS/Linux), fall back to /tmp.
2534
TMP_BASE="${TMPDIR:-${TEMP:-/tmp}}"
2635

@@ -139,7 +148,11 @@ echo " Running ${#EXAMPLES[@]} examples"
139148
if [[ ${#SKIPPED[@]} -gt 0 ]]; then
140149
echo " Skipping ${#SKIPPED[@]}: ${SKIPPED[*]}"
141150
fi
142-
echo " Timeout: ${TIMEOUT}s per example"
151+
if [[ -n "$TIMEOUT_BIN" ]]; then
152+
echo " Timeout: ${TIMEOUT}s per example"
153+
else
154+
echo " Timeout: none (no timeout binary found)"
155+
fi
143156
echo "=========================================="
144157
echo ""
145158

@@ -163,9 +176,9 @@ for example in "${EXAMPLES[@]}"; do
163176
if [[ -n "$STDIN_RESPONSE" ]]; then
164177
# Use `yes` to provide unlimited identical responses — handles
165178
# cases where the LLM calls an approval tool multiple times.
166-
RUN_CMD="yes '$STDIN_RESPONSE' | timeout $TIMEOUT $PYTHON $example"
179+
RUN_CMD="yes '$STDIN_RESPONSE' | ${TIMEOUT_BIN:+$TIMEOUT_BIN $TIMEOUT }$PYTHON $example"
167180
else
168-
RUN_CMD="timeout $TIMEOUT $PYTHON $example"
181+
RUN_CMD="${TIMEOUT_BIN:+$TIMEOUT_BIN $TIMEOUT }$PYTHON $example"
169182
fi
170183

171184
if eval "$RUN_CMD" > "$LOG_FILE" 2>&1; then

0 commit comments

Comments
 (0)