Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions skills/ask-gemini/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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 <max>s`. Verified: `agy --print "<text>"` 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.
Expand Down
14 changes: 10 additions & 4 deletions skills/ask-gemini/scripts/ask-gemini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 \"<prompt>\" --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"
Expand Down Expand Up @@ -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")
Comment on lines +1134 to +1142

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify --print-timeout is a valid agy flag and check its expected format.
agy --help 2>&1 | grep -A2 'print-timeout' || echo "Flag not found in help output"

# Also check if agy supports a file-based prompt input as an alternative for large prompts.
agy --help 2>&1 | grep -iE 'print|prompt|file|stdin' || echo "No relevant flags found"

Repository: ASACHIT/ask-gemini

Length of output: 210


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the prompt launch path and nearby helper logic.
sed -n '900,980p' skills/ask-gemini/scripts/ask-gemini
printf '\n---\n'
sed -n '1120,1160p' skills/ask-gemini/scripts/ask-gemini

printf '\n=== searches ===\n'
rg -n --hidden --no-messages 'print-timeout|dangerously-skip-permissions|--print|CONTEXT_MODE=relay|build_prompt\(' skills/ask-gemini/scripts/ask-gemini

Repository: ASACHIT/ask-gemini

Length of output: 5725


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect prompt construction and any size limits/truncation logic.
sed -n '875,940p' skills/ask-gemini/scripts/ask-gemini
printf '\n---\n'
rg -n --hidden --no-messages 'MAX_PROMPT|prompt.*limit|truncate|ARG_MAX|E2BIG|prompt_file|prompt_text|relay' skills/ask-gemini/scripts/ask-gemini

Repository: ASACHIT/ask-gemini

Length of output: 3357


Guard relay prompts against argv size limits CONTEXT_MODE=relay inlines file contents, so passing the assembled prompt via --print can hit E2BIG for larger projects. Add a size guard or fallback path so these runs fail with a clear message instead of an OS-level argv error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/ask-gemini/scripts/ask-gemini` around lines 1134 - 1142, Add an
argument-size guard around prompt_text and the args construction in the agy
invocation flow, especially for CONTEXT_MODE=relay. When the assembled prompt
exceeds the safe argv limit, fail early with a clear user-facing error instead
of attempting the --print invocation; preserve the existing behavior for prompts
within the limit.


# Snapshot conversations dir before (for conversation-id capture on fresh calls only)
local before=""
Expand All @@ -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=""
Expand Down