From 7f8421691f0afd436dced37688a390d40a6c0d1e Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sun, 17 May 2026 13:33:25 +0200 Subject: [PATCH] u/cascade: validate -max-workers; truncate large worker outputs - Reject non-positive-integer -max-workers early - Per-worker output capped at OLLIE_CASCADE_MAX_OUTPUT (default 8000 chars) to prevent synthesis prompt blowup --- scripts/u/cascade | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/u/cascade b/scripts/u/cascade index 30b0d74..7d2ad16 100755 --- a/scripts/u/cascade +++ b/scripts/u/cascade @@ -56,6 +56,10 @@ else fi [ -z "$task" ] && die "empty prompt" +case "$max_workers" in + ''|*[!0-9]*|0) die "-max-workers must be a positive integer" ;; +esac + # Step 1: Ask the planner to decompose into subtasks (JSON array). plan=$("$B" -backend "$PB" -model "$PM" -json \ "Decompose this task into independent, mechanical subtasks that a weak model can execute without judgment. Each subtask must be fully self-contained (include all needed context). Output a JSON array of objects with \"id\" (short string) and \"instruction\" (complete task description). Keep it minimal — only decompose what benefits from parallelism. @@ -100,6 +104,7 @@ done for pid in "${pids[@]}"; do wait "$pid" || true; done # Step 4: Gather results as structured JSON array. +MAX_OUTPUT=${OLLIE_CASCADE_MAX_OUTPUT:-8000} # max chars per worker output failures=0 results_json="[" first=1 @@ -111,6 +116,10 @@ for sid in "${workers[@]}"; do failures=$((failures + 1)) fi out=$(cat "${tmpdir}/${sid}.out" 2>/dev/null || echo "(no output)") + if [ "${#out}" -gt "$MAX_OUTPUT" ]; then + out="${out:0:$MAX_OUTPUT} +...(truncated, ${#out} chars total)" + fi [ "$first" -eq 1 ] && first=0 || results_json="${results_json}," results_json="${results_json}$(jq -n --arg id "$sid" --arg status "$status" --arg output "$out" \ '{id: $id, status: $status, output: $output}')"