u/cascade: add session name to results; sync schema with actual fields

This commit is contained in:
Levi Neely 2026-05-17 13:36:59 +02:00
parent 204e0e7a9d
commit e31d1abd1e
1 changed files with 5 additions and 3 deletions

View File

@ -110,6 +110,7 @@ $instruction" > "${tmpdir}/${sid}.out" 2>&1 && touch "${tmpdir}/${sid}.ok" && br
sleep "$((attempt * 2))"
done
echo "$attempt" > "${tmpdir}/${sid}.attempts"
echo "$name" > "${tmpdir}/${sid}.session"
) &
pids+=($!)
done
@ -131,13 +132,14 @@ for sid in "${workers[@]}"; do
fi
out=$(cat "${tmpdir}/${sid}.out" 2>/dev/null || echo "(no output)")
attempts=$(cat "${tmpdir}/${sid}.attempts" 2>/dev/null || echo 1)
session_name=$(cat "${tmpdir}/${sid}.session" 2>/dev/null || echo "$sid")
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" --argjson attempts "$attempts" \
'{id: $id, status: $status, attempts: $attempts, output: $output}')"
results_json="${results_json}$(jq -n --arg id "$sid" --arg status "$status" --arg output "$out" --argjson attempts "$attempts" --arg session "$session_name" \
'{id: $id, status: $status, attempts: $attempts, session: $session, output: $output}')"
done
results_json="${results_json}]"
@ -154,7 +156,7 @@ else
synth_flags+=(-json)
synth_prompt="Synthesize these worker results into a structured JSON response for the original task. Note: workers with status \"failed\" did not complete successfully — include them in errors.
Output schema: {\"summary\": \"<one-line summary>\", \"answer\": \"<full synthesized answer>\", \"worker_results\": [{\"id\": \"<worker-id>\", \"status\": \"done|failed\", \"output\": \"<worker output>\"}], \"errors\": [\"<description of any failures>\"]}
Output schema: {\"summary\": \"<one-line summary>\", \"answer\": \"<full synthesized answer>\", \"worker_results\": [{\"id\": \"<worker-id>\", \"status\": \"done|failed\", \"attempts\": <int>, \"session\": \"<session-name>\", \"output\": \"<worker output>\"}], \"errors\": [\"<description of any failures>\"]}
ORIGINAL TASK:
$task