TASK-1110: Gemini CLI 遷移至 AGY(closed) - #52
Open
arcobaleno64 wants to merge 6 commits into
Open
Conversation
Re-verifies (not assumed from memory) that gemini.cmd still fails auth (API key not valid) while agy -p succeeds on retest, though this contradicts the 2026-06-21 five-attempt 0-byte failure recorded in TASK-1100/1101 status/verify artifacts. Research inventories the full impact scope of both remediation routes (migrate wrapper+docs+validator to AGY vs fix gemini CLI auth in place) without recommending either — route decision deferred to user via AskUserQuestion per task Constraints. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
council-forge | 5157b2c | Jul 16 2026, 03:44 AM |
…idence agy 1.1.1 changelog explicitly documents a fixed bug: print mode (-p/--print) used to silently exit 0 with empty output on server-side failure. This matches the exact symptom recorded in TASK-1100/1101 (five attempts, all 0-byte, exit 0) from 2026-06-21. Local install artifacts (installation_id mtime 2026-05-25, .old backup mtime 2026-07-14) confirm an auto-update occurred in between, current version is 1.1.3. High-confidence explanation, not fully certain (exact June version unrecorded) — downgraded from unresolved contradiction to a mostly-explained discrepancy with residual caveat about --sandbox mode remaining a separate open issue. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…lenge User selected route (a) migrate to AGY. Plan covers wrapper, 4 docs, guard_contract_validator.py allowlist logic, tests, and PR-cases. Premortem R1-R5 written, then independently challenged by a separate Explore subagent (fresh context, no visibility into this conversation) per docs/premortem_rules.md §12, since this is a cross-module migration into an unfamiliar CLI. The challenge corrected R2 (the wrapper's retry logic doesn't actually gate on the retry-pattern regex the way the original R2 assumed) and found four real gaps the plan had missed: - R7 (blocking): agy has no --approval-mode/-m flags; it defaults to request-review mode which pauses on file writes, so migrating with the current --approval-mode yolo call would hang headless dispatches instead of failing fast. Confirmed via agy --help/--changelog. - R8 (blocking): test_guard_contract_validator.py (an EXACT_SYNC file) tests validate_allowed_gemini_models() with gemini-format fixtures; the plan's original file list missed it entirely. - R9/R10 (non-blocking): docs/orchestration-workflow.md and docs/sop/dispatch_research.md both hardcode the old gemini model ladder/invocation and aren't covered by any validator gate, so they'd silently drift after migration if not added to scope. Plan now carries 10 risks (5 blocking), the independent challenge verdicts per risk, and an expanded Files Likely Affected list. Routing: Coding deferred to Codex CLI per §2.7 (risk score 5, context cost L). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Migrates artifacts/scripts/Invoke-GeminiAgent.ps1 (root+template) and its
supporting docs/validator/tests off the dead gemini.cmd executable onto agy
(Antigravity CLI), addressing the auth failure this task was opened for.
Key changes: -Executable default -> agy; model ladder -> agy's display-name
strings ("Gemini 3.5 Flash (Medium/High)", "Gemini 3.1 Pro (High)");
--approval-mode yolo (which agy doesn't have) replaced with
--dangerously-skip-permissions/--mode accept-edits, since agy defaults to a
request-review mode that pauses on file writes; retry-pattern matching
narrowed to stderr only to stop false-positive failures on replies that
happen to contain digit strings like "429"; explicit empty-stdout-with-
exit-0 now treated as failure (this exact symptom caused TASK-1100/1101's
five silent 0-byte failures in June). guard_contract_validator.py's
validate_allowed_gemini_models() gets a second regex for agy's display-name
format alongside the legacy gemini-x.y-z pattern, and the redundant
DISALLOWED_GEMINI_FRAGMENTS list is dropped now that the allowlist is a
closed-set match (see decision artifact R5). Tests and PR-010 updated to
match; docs/orchestration-workflow.md and docs/sop/dispatch_research.md
(missed by the initial plan, caught by an independent premortem challenge)
also updated so they don't silently drift.
Coding was dispatched to Codex CLI (gpt-5.5, cross-module), which completed
the full implementation before its workspace ran out of credits partway
through writing its own summary artifacts; the dispatch wrapper's
write-scope guard then deleted those in-progress artifacts because they
weren't in -AllowedPaths. Per user decision, Claude independently verified
the already-complete code (validators, full pytest, root/template SHA-256
parity, and two live end-to-end agy calls including a file-write case
wrapped in a timeout to confirm R7 doesn't hang) and wrote the code/test/
verify/decision lifecycle artifacts itself rather than re-dispatching
Codex to redo already-correct, already-verified work. Full provenance is
recorded in artifacts/code/TASK-1110.code.md and artifacts/decisions/
TASK-1110.decision.md.
12 pre-existing pytest failures (repo-root detection breaking inside a
git worktree subdirectory) are confirmed unrelated via before/after stash
comparison and are out of this task's scope.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
arcobaleno64
marked this pull request as ready for review
July 16, 2026 03:27
There was a problem hiding this comment.
Pull request overview
This PR completes TASK-1110 by migrating the repository’s Gemini research-agent integration from gemini.cmd (API key auth failures) to AGY (agy), updating the PowerShell wrapper, Gemini model allowlist enforcement, regression cases, and related documentation. It also adds the full TASK-1110 lifecycle artifacts (task/research/plan/code/test/verify/decision/status) that record provenance and verification.
Changes:
- Switch
Invoke-GeminiAgent.ps1to callagywith non-interactive flags, stderr-based retry classification, and empty-stdout retry defense. - Update Gemini/AGY model allowlist policy enforcement (
guard_contract_validator.py), wrapper tests, and prompt regression cases to pin the new model ladder + flags. - Update workflow documentation and bootstrap prompts (root + template mirrors) to reflect AGY invocation/auth.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| template/docs/subagent_roles.md | Document AGY-backed Gemini agent models/auth/invocation (template mirror). |
| template/docs/sop/dispatch_research.md | Update research dispatch SOP to AGY (template mirror). |
| template/docs/orchestration-workflow.md | Update model policy section to AGY allowlist (template mirror). |
| template/BOOTSTRAP_PROMPT.md | Update bootstrap instructions for AGY-backed Gemini agent (template mirror). |
| template/artifacts/scripts/test_invoke_gemini_agent.py | Update wrapper tests for AGY invocation and new retry/empty-output behaviors (template mirror). |
| template/artifacts/scripts/test_guard_contract_validator.py | Update/extend allowlist validator tests for AGY display-name models (template mirror). |
| template/artifacts/scripts/Invoke-GeminiAgent.ps1 | Migrate wrapper implementation from gemini CLI flags to AGY flags (template mirror). |
| template/artifacts/scripts/guard_contract_validator.py | Update allowlist set + model reference extraction for AGY display names (template mirror). |
| template/artifacts/scripts/drills/prompt_regression_cases.json | Update PR-010 assertions to require AGY allowlist + flags (template mirror). |
| docs/subagent_roles.md | Document AGY-backed Gemini agent models/auth/invocation. |
| docs/sop/dispatch_research.md | Update research dispatch SOP to AGY. |
| docs/orchestration-workflow.md | Update model policy section to AGY allowlist. |
| BOOTSTRAP_PROMPT.md | Update bootstrap instructions for AGY-backed Gemini agent. |
| artifacts/verify/TASK-1110.verify.md | Add verification artifact capturing validator/pytest/e2e AGY evidence. |
| artifacts/test/TASK-1110.test.md | Add test report with executed commands and results for TASK-1110. |
| artifacts/tasks/TASK-1110.task.md | Add task artifact documenting objective, constraints, and acceptance criteria. |
| artifacts/status/TASK-1110.status.json | Add status artifact marking TASK-1110 lifecycle completion. |
| artifacts/scripts/test_invoke_gemini_agent.py | Update wrapper tests for AGY invocation and new retry/empty-output behaviors. |
| artifacts/scripts/test_guard_contract_validator.py | Update/extend allowlist validator tests for AGY display-name models. |
| artifacts/scripts/Invoke-GeminiAgent.ps1 | Migrate wrapper implementation from gemini CLI flags to AGY flags. |
| artifacts/scripts/guard_contract_validator.py | Update allowlist set + model reference extraction for AGY display names. |
| artifacts/scripts/drills/prompt_regression_cases.json | Update PR-010 assertions to require AGY allowlist + flags. |
| artifacts/research/TASK-1110.research.md | Add research artifact documenting gemini auth failure + AGY investigation. |
| artifacts/plans/TASK-1110.plan.md | Add plan artifact with premortem risks and validation strategy. |
| artifacts/decisions/TASK-1110.decision.md | Add decision artifact capturing provenance + key policy decisions (e.g., disallow-list removal). |
| artifacts/code/TASK-1110.code.md | Add code artifact summarizing implementation and provenance. |
| - GEMINI.md 的規則條文 | ||
| - 預期輸出格式(見 docs/schemas/artifact-spec-research.md §5.2) | ||
| 2. 執行 `gemini -m gemini-3.1-flash-lite-preview --approval-mode=yolo -p "..."` 或 `artifacts/scripts/Invoke-GeminiAgent.ps1` | ||
| 2. 執行 `agy -p "..." --model "Gemini 3.5 Flash (Medium)" --mode accept-edits --dangerously-skip-permissions --add-dir "<cwd>"` 或 `artifacts/scripts/Invoke-GeminiAgent.ps1` |
| - GEMINI.md 的規則條文 | ||
| - 預期輸出格式(見 docs/schemas/artifact-spec-research.md §5.2) | ||
| 2. 執行 `gemini -m gemini-3.1-flash-lite-preview --approval-mode=yolo -p "..."` 或 `artifacts/scripts/Invoke-GeminiAgent.ps1` | ||
| 2. 執行 `agy -p "..." --model "Gemini 3.5 Flash (Medium)" --mode accept-edits --dangerously-skip-permissions --add-dir "<cwd>"` 或 `artifacts/scripts/Invoke-GeminiAgent.ps1` |
Comment on lines
+68
to
+69
| def _normalize_powershell_stdin(text: str) -> str: | ||
| return text.lstrip("\ufeff\u569c\u7bdb").rstrip("\n") |
Comment on lines
+68
to
+69
| def _normalize_powershell_stdin(text: str) -> str: | ||
| return text.lstrip("\ufeff\u569c\u7bdb").rstrip("\n") |
…trees Files a pending task for the 12 pytest failures discovered during TASK-1110's verification (detect_repo_root()/Get-RepoRoot()/get_repo_root() across run_quality_gates.py, guard_status_validator.py, publish_release_verify.py resolve to the worktree path rather than the main repo root when invoked from a .claude/worktrees/ subdirectory). Confirmed unrelated to TASK-1110 via before/after git-stash comparison. Intake only per user instruction — not scheduled into Research/Planning yet. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
agy changelog 1.1.3 changed how eligibility errors (e.g. IneligibleTierError) are displayed (inline + verification URL, replacing the old stacked-above display). The wrapper's $RetryPatterns were designed against assumed prior behavior; this hasn't been re-checked against the actual 1.1.3 output format. Same underlying gap as the existing R2 residual note (agy's real error formats were never exhaustively tested), just naming a concrete contributing factor. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-p在伺服器端失敗時靜默回傳空輸出的 bug。--approval-mode,預設模式會在寫入前暫停)。-AllowedPaths設定疏漏誤刪 Codex 的草稿 artifact。使用者裁決由 Claude 獨立驗證已完成之程式碼(validator + 完整 pytest + SHA-256 鏡像比對 + 兩次真實 agy 端對端呼叫,含 R7 之逾時包裹驗證)並補寫 code/test/verify/decision 四份收尾 artifact,不重新 dispatch。Test plan
guard_status_validator.py --task-id TASK-1110→ OKguard_contract_validator.py --root .→ OKprompt_regression_validator.py --root .→ 33/33 passpytest artifacts/scripts -q→ 2015 passed(12 既有無關失敗,stash 對照確認)🤖 Generated with Claude Code