fix: prompt.md via stdin now combines with codex flags

Options like -s read-only routed execution into the /dev/null branch,
so codex got no prompt at all. codex natively appends piped stdin as
a <stdin> block, so feeding prompt.md unconditionally is safe.
This commit is contained in:
admin committed 2026-07-07 16:56:04 +05:00
1 parent 7256cdcf65
commit 32aaaa9b7a
3 files changed
+13 -4

No files matched your search

+3 -2
View File
@@ -6,7 +6,8 @@
# codex-run.sh <job_dir> resume <thread_id> [codex-flags...] [prompt] # codex-run.sh <job_dir> resume <thread_id> [codex-flags...] [prompt]
# codex-run.sh <job_dir> review [--base X|--commit Y|--uncommitted] [codex-flags...] [prompt] # codex-run.sh <job_dir> review [--base X|--commit Y|--uncommitted] [codex-flags...] [prompt]
# #
# If <job_dir>/prompt.md exists and no positional prompt given, it is fed via stdin. # If <job_dir>/prompt.md is non-empty it is always fed via stdin ('-'); codex-flags
# stay positional, so options and a file prompt combine freely.
# Review runs against the git repo at the CURRENT WORKING DIRECTORY (no -C support). # Review runs against the git repo at the CURRENT WORKING DIRECTORY (no -C support).
# #
# Files written to <job_dir>: events.jsonl last.md err.log thread_id status # Files written to <job_dir>: events.jsonl last.md err.log thread_id status
@@ -36,7 +37,7 @@ esac
rm -f "$JOB_DIR/status" "$LAST"; : > "$EV"; : > "$ERR" rm -f "$JOB_DIR/status" "$LAST"; : > "$EV"; : > "$ERR"
if [[ $# -eq 0 && -s $JOB_DIR/prompt.md ]]; then if [[ -s $JOB_DIR/prompt.md ]]; then
"${CMD[@]}" - < "$JOB_DIR/prompt.md" > "$EV" 2> "$ERR" & "${CMD[@]}" - < "$JOB_DIR/prompt.md" > "$EV" 2> "$ERR" &
else else
"${CMD[@]}" "$@" < /dev/null > "$EV" 2> "$ERR" & "${CMD[@]}" "$@" < /dev/null > "$EV" 2> "$ERR" &
+2 -1
View File
@@ -5,5 +5,6 @@ prev=""
for a in "$@"; do [[ $prev == "-o" ]] && out=$a; prev=$a; done for a in "$@"; do [[ $prev == "-o" ]] && out=$a; prev=$a; done
echo '{"type":"thread.started","thread_id":"test-thread-123"}' echo '{"type":"thread.started","thread_id":"test-thread-123"}'
echo '{"type":"turn.completed"}' echo '{"type":"turn.completed"}'
echo "stub answer" > "$out" stdin_content=$(cat)
echo "stub answer|$stdin_content" > "$out"
exit 0 exit 0
+8 -1
View File
@@ -9,7 +9,7 @@ trap 'rm -rf "$TMP"' EXIT
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/ok" exec "hello" CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/ok" exec "hello"
[[ $(cat "$TMP/ok/status") == ok ]] [[ $(cat "$TMP/ok/status") == ok ]]
[[ $(cat "$TMP/ok/thread_id") == test-thread-123 ]] [[ $(cat "$TMP/ok/thread_id") == test-thread-123 ]]
[[ $(cat "$TMP/ok/last.md") == "stub answer" ]] [[ $(cat "$TMP/ok/last.md") == "stub answer|" ]]
# 2. stall -> watchdog kills, status stalled, exit nonzero # 2. stall -> watchdog kills, status stalled, exit nonzero
if CODEX_BIN=$HERE/stub-hang/codex CODEX_STALL_TIMEOUT=4 CODEX_WATCH_INTERVAL=2 \ if CODEX_BIN=$HERE/stub-hang/codex CODEX_STALL_TIMEOUT=4 CODEX_WATCH_INTERVAL=2 \
@@ -23,5 +23,12 @@ fi
mkdir -p "$TMP/stdin"; echo "prompt from file" > "$TMP/stdin/prompt.md" mkdir -p "$TMP/stdin"; echo "prompt from file" > "$TMP/stdin/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/stdin" exec CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/stdin" exec
[[ $(cat "$TMP/stdin/status") == ok ]] [[ $(cat "$TMP/stdin/status") == ok ]]
[[ $(cat "$TMP/stdin/last.md") == "stub answer|prompt from file" ]]
# 4. prompt.md + codex flags -> stdin still delivered (regression: options ate the prompt)
mkdir -p "$TMP/flags"; echo "prompt with flags" > "$TMP/flags/prompt.md"
CODEX_BIN=$HERE/stub-ok/codex "$RUN" "$TMP/flags" exec -s read-only
[[ $(cat "$TMP/flags/status") == ok ]]
[[ $(cat "$TMP/flags/last.md") == "stub answer|prompt with flags" ]]
echo "ALL PASS" echo "ALL PASS"