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
This commit is contained in:
parent
42929b4c57
commit
7f8421691f
|
|
@ -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}')"
|
||||
|
|
|
|||
Loading…
Reference in New Issue