From 2c15949a74b29e192bcc61580da654c1ff5bb72e Mon Sep 17 00:00:00 2001 From: Asmit Kumar Sah Date: Sat, 11 Jul 2026 22:58:45 +0545 Subject: [PATCH] fix(ask-gemini): pass prompt via --print for agy >= 1.1.1 agy 1.1.1 stopped reading stdin in print mode, so `agy -p - < file` sent a literal "-" and dropped the prompt (agy answered a stale turn or hung at exit 0, relayed as success:true). Pass the prompt as the --print arg, read stdin from /dev/null, and cap the wait with --print-timeout. Bumps to 0.14.0. --- skills/ask-gemini/CHANGELOG.md | 4 ++++ skills/ask-gemini/scripts/ask-gemini | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/skills/ask-gemini/CHANGELOG.md b/skills/ask-gemini/CHANGELOG.md index c5eeab4..eff1240 100644 --- a/skills/ask-gemini/CHANGELOG.md +++ b/skills/ask-gemini/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +### 0.14.0 + +- **Fix: prompt silently dropped under agy >= 1.1.1.** agy 1.1.1 changed print mode ("Fixed `agy -p` hanging when run inside a shell script or subprocess by no longer reading stdin when a prompt is provided via a flag") — `--print`/`-p` now takes the prompt as an argument and no longer reads stdin. The script was invoking `agy -p - < prompt_file`, so agy received a literal `-` as the prompt and discarded `prompt_file`; it would then answer a stale resumed turn (or hang) and exit 0, which the wrapper relayed as `success:true`. Now passes the prompt via `agy --print "$prompt"` with stdin from `/dev/null`, and bounds agy's own wait with `--print-timeout s`. Verified: `agy --print ""` returns a real answer where `agy -p - < file` times out. + ### 0.13.0 - Race-safe concurrent conversation-id capture: fresh delegations running at once each claim a distinct conversation id under a short lock + a claimed-ids registry (`~/.ask-gemini/captured-uuids.txt`), so parallel resumes no longer cross-wire. Documented the parallel fan-out pattern (grid, not queue) in SKILL.md. diff --git a/skills/ask-gemini/scripts/ask-gemini b/skills/ask-gemini/scripts/ask-gemini index 2d99f4e..74cd6d0 100755 --- a/skills/ask-gemini/scripts/ask-gemini +++ b/skills/ask-gemini/scripts/ask-gemini @@ -45,7 +45,7 @@ UPDATE_DEFAULTS=false # Cap on learned rules before --learn warns (lossless — the rule is still kept). LEARNED_CAP=20 -ASK_GEMINI_VERSION="0.13.0" +ASK_GEMINI_VERSION="0.14.0" ASK_GEMINI_HOME="$HOME/.ask-gemini" SESSIONS_DIR="$ASK_GEMINI_HOME/sessions" @@ -1048,7 +1048,7 @@ if [[ "$DRY_RUN" = true ]]; then echo "context_mode: $CONTEXT_MODE" echo "resuming: $RESUMING ${GEMINI_UUID:+(uuid=$GEMINI_UUID)}" # Render the agy invocation that would run (resume flag shown only when resuming). - _agy_inv="agy -p - --dangerously-skip-permissions --model \"$AGY_MODEL\"" + _agy_inv="agy --print \"\" --dangerously-skip-permissions --model \"$AGY_MODEL\" --print-timeout ${MAX_TIMEOUT}s" [[ -n "${GEMINI_UUID:-}" ]] && _agy_inv+=" --conversation $GEMINI_UUID" [[ "$SANDBOX" = true ]] && _agy_inv+=" --sandbox" echo "invocation: $_agy_inv" @@ -1131,9 +1131,15 @@ _run_gemini() { # agy: plain-text response on stdout (no JSON). Always skip permissions # (no approval modes). resume by conversation id. - local args=("-p" "-" "--dangerously-skip-permissions" "--model" "$AGY_MODEL") + # agy >= 1.1.1: --print takes the prompt as an ARG and no longer reads stdin, + # so the old `-p - < prompt_file` silently dropped the prompt. Pass it as the + # --print value; stdin from /dev/null so agy can't block on a pipe. + local prompt_text + prompt_text=$(cat "$prompt_file") + local args=("--print" "$prompt_text" "--dangerously-skip-permissions" "--model" "$AGY_MODEL") [[ -n "$resume_uuid" ]] && args+=("--conversation" "$resume_uuid") [[ "$SANDBOX" = true ]] && args+=("--sandbox") + args+=("--print-timeout" "${max_to}s") # Snapshot conversations dir before (for conversation-id capture on fresh calls only) local before="" @@ -1145,7 +1151,7 @@ _run_gemini() { start=$(date +%s) set +e - agy "${args[@]}" < "$prompt_file" > "$RG_RESPONSE_FILE" 2>"$RG_STDERR_FILE" & + agy "${args[@]}" < /dev/null > "$RG_RESPONSE_FILE" 2>"$RG_STDERR_FILE" & local pid=$! local last_stdout=0 last_stderr=0 idle=0 last_cpu=""