u/cascade: track per-worker failures, annotate status, exit non-zero
This commit is contained in:
parent
87fb50f207
commit
c29cf7dcdc
|
|
@ -79,7 +79,7 @@ for i in $(seq 0 $((count - 1))); do
|
|||
"$B" -name "$sid" -backend "$WB" -model "$WM" -keep \
|
||||
"You are a worker agent. Execute the following task exactly. Output only the result.
|
||||
|
||||
$instruction" > "${tmpdir}/${sid}.out" 2>&1
|
||||
$instruction" > "${tmpdir}/${sid}.out" 2>&1 && touch "${tmpdir}/${sid}.ok"
|
||||
) &
|
||||
pids+=($!)
|
||||
done
|
||||
|
|
@ -87,12 +87,19 @@ done
|
|||
# Step 3: Wait for all workers.
|
||||
for pid in "${pids[@]}"; do wait "$pid" || true; done
|
||||
|
||||
# Step 4: Gather results.
|
||||
# Step 4: Gather results with status annotations.
|
||||
results=""
|
||||
failures=0
|
||||
for sid in "${workers[@]}"; do
|
||||
if [ -f "${tmpdir}/${sid}.ok" ]; then
|
||||
status="done"
|
||||
else
|
||||
status="failed"
|
||||
failures=$((failures + 1))
|
||||
fi
|
||||
out=$(cat "${tmpdir}/${sid}.out" 2>/dev/null || echo "(no output)")
|
||||
results="${results}
|
||||
--- ${sid} ---
|
||||
--- ${sid} [STATUS: ${status}] ---
|
||||
${out}
|
||||
"
|
||||
done
|
||||
|
|
@ -100,13 +107,15 @@ done
|
|||
# Step 5: Synthesize or just print results.
|
||||
if [ "$synthesize" -eq 0 ]; then
|
||||
printf '%s\n' "$results"
|
||||
[ "$failures" -gt 0 ] && exit 1
|
||||
else
|
||||
"$B" -backend "$PB" -model "$PM" \
|
||||
"Synthesize these worker results into a final, coherent answer to the original task.
|
||||
"Synthesize these worker results into a final, coherent answer to the original task. Note: workers marked [STATUS: failed] did not complete successfully — account for this in your synthesis.
|
||||
|
||||
ORIGINAL TASK:
|
||||
$task
|
||||
|
||||
WORKER RESULTS:
|
||||
$results"
|
||||
[ "$failures" -gt 0 ] && exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue