Skip to content

fix(ask-gemini): pass prompt via --print for agy >= 1.1.1#1

Open
blaze-000 wants to merge 1 commit into
ASACHIT:mainfrom
blaze-000:fix/agy-1.1-print-stdin
Open

fix(ask-gemini): pass prompt via --print for agy >= 1.1.1#1
blaze-000 wants to merge 1 commit into
ASACHIT:mainfrom
blaze-000:fix/agy-1.1-print-stdin

Conversation

@blaze-000

@blaze-000 blaze-000 commented Jul 11, 2026

Copy link
Copy Markdown

Symptom

Under agy >= 1.1.1, an ask-gemini delegation returns success:true but the response is a canned greeting / a stale session-continuation / an unrelated answer — the task text never reaches the model. exit code is 0, so the wrapper reports success and callers integrate junk as a real answer.

Root cause (version drift)

agy 1.1.1 changed print mode — from its changelog:

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.

So --print/-p now takes the prompt as an argument and no longer reads stdin. The script invoked agy -p - < prompt_file, so agy received a literal - as the prompt and discarded prompt_file. On a resumed conversation it answered the previous turn; on a fresh one it hung until timeout — always exit 0.

Fix

  • Pass the prompt as the --print argument: agy --print "$prompt_text" …
  • Read stdin from /dev/null so agy can never block on a pipe/tty
  • Bound agy's own print-mode wait with --print-timeout <max>s
  • Update the --dry-run invocation render; bump to 0.14.0

Verification

agy --print "<text>" returns a real answer, whereas the old agy -p - < file returns Error: timeout waiting for response. Confirmed end-to-end through the launcher on fresh and resumed sessions, chains, --task - stdin, special characters, and a ~19 KB prompt.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where prompts could be silently dropped with newer versions of the AI command-line tool.
    • Prevented prompt processing from hanging by providing prompts directly and safely handling standard input.
    • Added a print-timeout limit for improved reliability.
  • Documentation

    • Updated the changelog with version 0.14.0 details and verification results.

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.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updated ask-gemini to version 0.14.0 and changed agy prompt delivery from stdin to the --print argument, with stdin redirected from /dev/null and a print timeout applied. The changelog documents the fix and verification.

Changes

agy prompt handling

Layer / File(s) Summary
Runtime prompt delivery
skills/ask-gemini/scripts/ask-gemini
Reads the prompt file into an argument for agy --print, preserves model, conversation, and sandbox options, applies the print timeout, detaches stdin, updates the version, and reflects the new invocation in dry-run output.
Release documentation
skills/ask-gemini/CHANGELOG.md
Adds the 0.14.0 entry describing the agy prompt-handling fix and verification.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: passing the prompt via --print for agy >= 1.1.1.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with 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.

Inline comments:
In `@skills/ask-gemini/scripts/ask-gemini`:
- Around line 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.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69f6d228-d0dc-4ad2-a68d-00a23bbfd156

📥 Commits

Reviewing files that changed from the base of the PR and between f83c4d8 and 2c15949.

📒 Files selected for processing (2)
  • skills/ask-gemini/CHANGELOG.md
  • skills/ask-gemini/scripts/ask-gemini

Comment on lines +1134 to +1142
# 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")

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant