u/cascade: add -json-output flag for structured synthesis output
Schema: {summary, answer, worker_results[], errors[]}
This commit is contained in:
parent
8d78c6a7bc
commit
77efded76d
|
|
@ -12,6 +12,8 @@
|
|||
# -pm MODEL planner model (default: $OLLIE_CASCADE_PLAN_MODEL or claude-sonnet-4-20250514)
|
||||
# -wb BACKEND worker backend (default: $OLLIE_CASCADE_BACKEND or ollama)
|
||||
# -no-synthesize skip the final planner synthesis step; just print worker results
|
||||
# -json-output request structured JSON from the synthesis step
|
||||
# schema: {summary, answer, worker_results[], errors[]}
|
||||
set -euo pipefail
|
||||
|
||||
OLLIE="${OLLIE:-$HOME/mnt/ollie}"
|
||||
|
|
@ -25,6 +27,7 @@ WM="${OLLIE_CASCADE_MODEL:-qwen2.5-coder:14b}"
|
|||
die() { printf 'cascade: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
synthesize=1
|
||||
json_output=0
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
|
|
@ -33,6 +36,7 @@ while [ $# -gt 0 ]; do
|
|||
-wb) WB=$2; shift ;;
|
||||
-wm) WM=$2; shift ;;
|
||||
-no-synthesize) synthesize=0 ;;
|
||||
-json-output) json_output=1 ;;
|
||||
--) shift; break ;;
|
||||
-*) die "unknown flag: $1" ;;
|
||||
*) break ;;
|
||||
|
|
@ -111,13 +115,27 @@ 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. Note: workers marked [STATUS: failed] did not complete successfully — account for this in your synthesis.
|
||||
synth_flags=(-backend "$PB" -model "$PM")
|
||||
if [ "$json_output" -eq 1 ]; then
|
||||
synth_flags+=(-json)
|
||||
synth_prompt="Synthesize these worker results into a structured JSON response for the original task. Note: workers marked [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>\"]}
|
||||
|
||||
ORIGINAL TASK:
|
||||
$task
|
||||
|
||||
WORKER RESULTS:
|
||||
$results"
|
||||
else
|
||||
synth_prompt="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"
|
||||
fi
|
||||
"$B" "${synth_flags[@]}" "$synth_prompt"
|
||||
[ "$failures" -gt 0 ] && exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue