@@ -159,16 +159,24 @@ jobs:
159159 while (( SECONDS < deadline )); do
160160 poll_command="if test -f '\$status_file'; then cat '\$status_file'; else echo status=starting; fi; echo __LOG_TAIL__; tail -n 120 '\$log_file' 2>/dev/null || true"
161161 last_output="\$(agentkit sandbox shell --tool-id "\$tool_id" -s "\$session_id" --command "\$poll_command" 2>&1 || true)"
162- status="\$(printf '%s\n' "\$last_output" | awk -F= '\$1 == "status" {value=\$2} END {print value}')"
162+ sandbox_output="\$(printf '%s\n' "\$last_output" | python3 -c 'import json, sys
163+ text = sys.stdin.read()
164+ try:
165+ payload = json.loads(text)
166+ sys.stdout.write(payload.get("data", {}).get("output", ""))
167+ except Exception:
168+ sys.stdout.write(text)
169+ ')"
170+ status="\$(printf '%s\n' "\$sandbox_output" | awk -F= '\$1 == "status" {value=\$2} END {print value}')"
163171 echo "sandbox status: \${status:-unknown}"
164172
165173 case "\$status" in
166174 success)
167- printf '%s\n' "\$last_output "
175+ printf '%s\n' "\$sandbox_output "
168176 exit 0
169177 ;;
170178 failed)
171- printf '%s\n' "\$last_output " >&2
179+ printf '%s\n' "\$sandbox_output " >&2
172180 exit 1
173181 ;;
174182 esac
@@ -351,16 +359,24 @@ jobs:
351359 while (( SECONDS < deadline )); do
352360 poll_command="if test -f '\$status_file'; then cat '\$status_file'; else echo status=starting; fi; echo __LOG_TAIL__; tail -n 120 '\$log_file' 2>/dev/null || true"
353361 last_output="\$(agentkit sandbox shell --tool-id "\$tool_id" -s "\$session_id" --command "\$poll_command" 2>&1 || true)"
354- status="\$(printf '%s\n' "\$last_output" | awk -F= '\$1 == "status" {value=\$2} END {print value}')"
362+ sandbox_output="\$(printf '%s\n' "\$last_output" | python3 -c 'import json, sys
363+ text = sys.stdin.read()
364+ try:
365+ payload = json.loads(text)
366+ sys.stdout.write(payload.get("data", {}).get("output", ""))
367+ except Exception:
368+ sys.stdout.write(text)
369+ ')"
370+ status="\$(printf '%s\n' "\$sandbox_output" | awk -F= '\$1 == "status" {value=\$2} END {print value}')"
355371 echo "sandbox status: \${status:-unknown}"
356372
357373 case "\$status" in
358374 success)
359- printf '%s\n' "\$last_output "
375+ printf '%s\n' "\$sandbox_output "
360376 exit 0
361377 ;;
362378 failed)
363- printf '%s\n' "\$last_output " >&2
379+ printf '%s\n' "\$sandbox_output " >&2
364380 exit 1
365381 ;;
366382 esac
0 commit comments