修正 Codex Action 重複輸出最後回答 #4

Merged
jiantw83 merged 6 commits from develop into master 2026-06-24 14:30:54 +00:00
Showing only changes of commit ffdb53c645 - Show all commits
+35
View File
@@ -56,6 +56,26 @@ SH
chmod +x "$dir/codex"
}
make_fake_transcript_codex() {
local dir="$1"
cat > "$dir/codex" <<'SH'
#!/bin/sh
last_message_file=""
while [ "$#" -gt 0 ]; do
if [ "$1" = "--output-last-message" ]; then
shift
last_message_file="$1"
fi
shift
done
printf '%s\n' 'codex' 'final answer' 'tokens used' '123' 'final answer'
printf '%s\n' 'final answer' > "$last_message_file"
SH
chmod +x "$dir/codex"
}
encoded_json() {
printf '%s' "$1" | base64 | tr -d '\n'
}
@@ -269,6 +289,20 @@ test_codex_output_truncation() {
rm -rf "$tmpdir"
}
test_last_message_output_without_transcript_duplicate() {
local tmpdir
tmpdir="$(mktemp -d)"
make_fake_transcript_codex "$tmpdir"
run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="hello"
[[ "$(grep -c "final answer" "$tmpdir/stdout")" -eq 1 ]] || die "stdout printed final answer more than once"
grep -q "status=completed" "$tmpdir/github-output" || die "last message completed status"
[[ "$(grep -c "final answer" "$tmpdir/github-output")" -eq 1 ]] || die "github output included transcript duplicate"
! grep -q "tokens used" "$tmpdir/github-output" || die "github output included codex transcript"
rm -rf "$tmpdir"
}
test_invalid_execution_config_uses_defaults() {
local tmpdir
tmpdir="$(mktemp -d)"
@@ -299,6 +333,7 @@ test_missing_codex_command_output
test_codex_timeout_output
test_codex_signal_output
test_codex_output_truncation
test_last_message_output_without_transcript_duplicate
test_invalid_execution_config_uses_defaults
echo "entrypoint tests passed"