Skip to content

実装: claude -p の空文字列 prompt 拒否 regression に対する agent-retrospective live smoke 検知経路の修正 #2345

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "agent-retrospective live smoke verifier (`verify_agent_retrospective_live_smoke.py`) が前提とする「空 prompt → 決定論的に run_id mismatch」という記述が現行 Claude Code CLI の実測挙動と矛盾している regression を解消する"
change_kind: workflow

Parent Issue

なし(単独改善)

Parent Goal Ref

  • Goal: なし(単独 Issue)
  • Desired Destination: なし(単独 Issue)

Current Validated Scope

  • .claude/skills/agent-retrospective/scripts/tests/verify_agent_retrospective_live_smoke.py の empty-prompt 前提の観測/検知経路
  • .claude/skills/agent-retrospective/scripts/run_retrospective.py の --prompts-file 未指定時のデフォルト prompt 生成箇所(必要な場合のみ)

Remaining Parent Gaps

なし(単独改善 Issue のため)

Outcome

verify_agent_retrospective_live_smoke.py の claude_live 手動実行時、--prompts-file を渡さないケースが「observer prompt が空文字列になり、run_retrospective.py の bundle validation で run_id/ctx.run_id mismatch に決定論的に到達する」という前提で設計されている。しかし Issue #2341 / PR #2342 の fix_delta 実装中の実測では、Claude Code 2.1.245 において claude -p 自体が空文字列 prompt を bundle validation に到達する前に拒否する(Error: Input must be provided either through stdin or as a prompt argument when using --print, exit code 1)ため、run_retrospective.py の invoke_agent() は status="api_error" / reason_code="nonzero_exit" を返し、observer_failed:<agent>:<status> の raise site 経由で ObserverWaveFailed(reason_code="nonzero_exit") に到達する。これは verifier の allowlist(observer_run_id_mismatch のみ許容)に含まれないため、verifier は意図せず FAIL する。

この Issue の完了時点で、verifier が意図した検知経路(observer_run_id_mismatch への到達、または status: pass)に確実に到達できる状態、または「空 prompt 拒否を意図的に許容する」設計判断のいずれかを明文化・実装した状態を Outcome とする。

Runtime Verification Applicability

  • decision: immediate
  • reason: 本 Issue は claude_live マーカー付きの実 Claude Code CLI 経由 live smoke verifier(verify_agent_retrospective_live_smoke.py)の前提・挙動を扱うため、docs/dev/runtime-verification-policy.md の適用判定スキーマ上 immediate に該当する。実装完了時に verifier を実 CLI で手動実行し証跡を残すこと。
    applicable_acs: AC1
    execution_environment: 現在インストール済みの claude CLI バイナリ(実装時点の最新 main HEAD、認証済みサブスクリプションログイン環境)による手動実行環境。ローカル開発機または人間/agent が直接操作できる環境を前提とし、デフォルト CI 実行環境(claude CLI 非搭載)とは区別する。
    skip_conditions: claude binary が PATH に存在しない、または claude auth status が非ゼロ exit で終了する(認証未確立)場合は SKIP(exit 77)とする。
    fallback_policy: SKIP は PASS に昇格しない。SKIP が発生した場合は fail-closed のまま維持し、実装完了報告には「実行できなかった」ことと skip_condition の種別を明記する。
    artifact_requirements: verify_agent_retrospective_live_smoke.py --runtime-profile claude_code --repo-root . の実行 stdout(JSON 1行、reason_code 込み)を実装完了時に PR 本文または PR コメントへ証跡として残す。raw stdout 全文・credential・絶対パスは含めない(bounded classification のみ)。

Background

Issue #2341(PR #2342)の実装・fix_delta 対応中に、.claude/skills/agent-retrospective/scripts/tests/verify_agent_retrospective_live_smoke.py の claude_live 手動実行を通じて、Issue #2341/PR #2342 のスコープとは別の regression を発見した(発見経緯: PR #2342 への OWNER レビューコメント #2342 (comment) P2 item 3〜4)。

verify_agent_retrospective_live_smoke.py はこれまで、--prompts-file を渡さずに run_retrospective.py を起動すると、observer 向け prompt が空文字列 (prompts.get(observer_id, "") -> "") になり、その結果 observer wave が run_id/ctx.run_id mismatch により決定論的に ObserverWaveFailed に到達する、という前提を docstring / コメントに記載していた。

しかし実際に Claude Code 2.1.245 で計測したところ、空文字列 prompt は run_retrospective.py の bundle validation(bundle.run_id != ctx.run_id の envelope check)に到達する前に、claude -p 自体が起動段階で拒否する。

Error: Input must be provided either through stdin or as a prompt argument when using --print
exit_code=1

run_retrospective.py の invoke_agent() はこれを status="api_error" / reason_code="nonzero_exit" として観測する(observer_failed:<agent>:<status> の raise site 経由で ObserverWaveFailed(reason_code="nonzero_exit") になる)。つまり、これまで docstring が記載していた「空 prompt → run_id mismatch」という deterministic path は、少なくとも Claude Code 2.1.245 環境では成立しない。

claude -p (Claude Code CLI の headless invocation)が空文字列 prompt を拒否する挙動そのものは、run_retrospective.py / agent-retrospective skill のバグではなく、Claude Code CLI 側の既存の別 regression(起動前の入力バリデーション挙動)である。Issue #2341 / PR #2342 は run_retrospective.py の ObserverWaveFailed reason_code 診断性改善が主眼であり、この空 prompt 拒否挙動自体の修正・回避は Issue #2341 / PR #2342 のスコープ外・別 ownership として明示的に切り出す。

なお verify_agent_retrospective_live_smoke.py の docstring / コメント自体の誤記述訂正は PR #2342 fix_delta 側で既に対応済み(この Issue は「訂正後の記述が指す本来の検知経路を実際に機能させる/設計判断を確定する」ことを scope とする)。

In Scope

  1. verify_agent_retrospective_live_smoke.py(または run_retrospective.py の --prompts-file 未指定時のデフォルト prompt 生成箇所)が、observer 向け prompt に非空文字列を確実に渡せるようにする対応、または「空 prompt 拒否を意図的に許容し、nonzero_exit を新たに allowlist する」設計判断を明文化する対応、のいずれかを選択し実装する。
  2. 選択した対応方針を verify_agent_retrospective_live_smoke.py の docstring / コメントに、実測に基づく正確な記述として反映する。

Out of Scope

Acceptance Criteria

  • AC1: verify_agent_retrospective_live_smoke.py --runtime-profile claude_code --repo-root . を手動実行し、reason_code が空 prompt 拒否由来の nonzero_exit(未対応のまま)ではなく、意図した経路(observer_run_id_mismatch または status: pass)に到達することを確認する
  • AC2: 対応方針(prompt 非空化、または nonzero_exit allowlist 追加のいずれか)が verify_agent_retrospective_live_smoke.py のソース上に実装として反映されている

Verification Commands

VC 補足:

  • AC1 の baseline(未実装)では、verifier が空 prompt 拒否由来の nonzero_exit で FAIL する(exit 1)ことが期待値。実装後は exit 0(observer_run_id_mismatch への到達、または status: pass)を期待する。
# AC1
# baseline-expect: fail
# preflight-scope: runtime_only
$ uv run --locked python3 .claude/skills/agent-retrospective/scripts/tests/verify_agent_retrospective_live_smoke.py --runtime-profile claude_code --repo-root .

# AC2
# baseline-expect: pass
$ grep -n "nonzero_exit" .claude/skills/agent-retrospective/scripts/tests/verify_agent_retrospective_live_smoke.py

Allowed Paths

  • .claude/skills/agent-retrospective/scripts/tests/verify_agent_retrospective_live_smoke.py
  • .claude/skills/agent-retrospective/scripts/run_retrospective.py(--prompts-file 未指定時のデフォルト prompt 生成箇所に限る)

Scope Delta(該当時のみ記載)

N/A

Required Skills

  • なし(Python subprocess ラッパー・既存 CLI 呼び出し規約の範囲で完結する)

Required Design References

  • .claude/skills/agent-retrospective/scripts/run_retrospective.py
  • docs/dev/runtime-verification-policy.md

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Aug 25, 2026
  2. squne121 commented on Aug 25, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: stop
    reason: review_verdict_blocked

  3. squne121 commented on Aug 25, 2026

    @squne121
    OwnerAuthor

    root-owned entry router audit

    route: invoke_impl_review_loop
    reason: fresh_review_go_live_equality

  4. squne121 commented on Aug 25, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-08-25T20:01:52Z)

    • PR: fix: agent-retrospective live smoke の空 prompt 拒否 regression を解消 (#2345) #2347
    • Worktree: .claude/worktrees/issue-2345-claude-live-smoke-fix
    • Branch: worktree-issue-2345-claude-live-smoke-fix
    • Verification: typecheck/lint/test/build 4/4 PASS + agent-retrospective pytest 432 passed(6 deselected) + model_routing 24 passed
    • AC1 動作検証(実 claude 2.1.245 CLI): reason_code=observer_run_id_mismatch, 検証スクリプト exit code=0 (baseline は nonzero_exit で exit code=1 だった)
    • AC2: grep -n "nonzero_exit" 確認済み(allowlist へは追加せず、docstring/コメントのみ訂正)
    • 後続: PR レビュー(pr-review-judge) → マージ → post-merge-cleanup
  5. self-assigned this
    on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent/implementerenhancementphase/implementation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions