Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "Claude Code 2.1.285 で SubagentStop payload から last_assistant_message が欠落しても、runner の marker provenance が Agent tool の handbackReport に fail-closed で適応し、SubAgent causal evidence が hook_id_correlated として成立する"
change_kind: code
dedupe_key: "runtime-smoke:subagentstop-last-assistant-message-absent:handbackreport-provenance:v1"Parent Issue
なし(研究元は調査 Issue #2846。#2846 は research のため親 tracker ではなく、本 Issue は単独の実装 Issue として扱う)
Parent Goal Ref
- Goal: runtime_only の AC が
--require-subagent-causal-evidenceと--expect-marker-source subagentを併用して、現行の Claude Code(2.1.285)でも PASS できる状態にする。 - Desired Destination: N/A(単独改善 Issue)。
Current Validated Scope
2026-09-30 に、ローカルに導入済みの Claude Code 2.1.284 と 2.1.285 のバイナリを、同一 worktree・同一 prompt・同一 argv で直接実行して測定した事実のみを記載する。詳細は #2846 (comment) を正本とする。
- 2.1.285 の
SubagentStophook payload にはlast_assistant_messageの key 自体が存在しない。2.1.284 では存在し、値は marker と完全一致する。 agent_transcript_pathは両バージョンで存在する。--no-session-persistenceのため、どちらでも path の file は実在しない(transcript による fallback 検証は 2.1.284 でも成立しない)。- runner の
_marker_provenance_verified()(scripts/agent-ops/run_worktree_agent_runtime_smoke.pyの約 3585 行)はlast_assistant_messageを一次 provenance とし、transcript を fallback とする。2.1.285 ではどちらも成立せず、subagent_causal_evidence_verdict()(約 3712〜3854 行)がno_evidenceを返す。 - 両バージョンで、marker は Agent tool の
tool_use_result.handbackReport.text({'text': '<marker>'})に残る。tool_use_result.agentIdは hook のagent_idと一致し、tool_use_result.statusはcompletedである。runner はhandbackReportをどこでも参照していない。 - upstream の 2.1.285 release note に「a subagent's run now ends as soon as it hands its report back to its caller」がある。公式 hooks docs は
last_assistant_messageを SubagentStop の入力 field 一覧に載せておらず、今回の欠落は文書化されていない挙動変更である。因果の断定は避ける。 - 影響を受ける AC は、実装: 再発防止: Auto mode runtime VC の独立 claude -p session で approval context 欠落による false capability-blocker を防ぐ #2839 の AC10(runtime_only、PR 実装: 独立 claude -p の runtime VC に bounded な approval carrier と non-executable 検出を追加する (#2839) #2844)と 実装: Claude-GPT model/proxy 更新の runtime migration を完了工程に含め、人間介入を genuine blocker に限定する #2810 の AC9/AC10(PR 実装: Claude-GPT model/proxy runtime migration の3分類ルーティングを追加する #2831)である。pristine main(
8eeca46a)でも再現する。 - 既存 test の baseline は
uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -qで 47 passed である。既存 test はlast_assistant_messageを持つ payload を前提としており、handbackReportのみを持つ形は未カバーである。
Remaining Parent Gaps
- なし(単独改善 Issue)。実装: 再発防止: Auto mode runtime VC の独立 claude -p session で approval context 欠落による false capability-blocker を防ぐ #2839 AC10 と 実装: Claude-GPT model/proxy 更新の runtime migration を完了工程に含め、人間介入を genuine blocker に限定する #2810 AC9/AC10 の再実行は、それぞれの Issue / PR が所有する。
Outcome
scripts/agent-ops/run_worktree_agent_runtime_smoke.py の causal evidence parser が、SubagentStop に last_assistant_message が無い場合に相関済みの handbackReport.text を fail-closed で marker provenance に使うようになり、対応する fixture pytest と live smoke(Claude Code 2.1.285 以降)が PASS して causal_evidence_source == hook_id_correlated となった状態で PR が merge される。
Runtime Verification Applicability
- decision: immediate
- reason: 本 Issue は
scripts/agent-ops/**(runner)の causal evidence parser を変更し、extension-surface policy の hard trigger(subagent-lifecycle-start-stop-delegation-fallback)に一致する。upstream の payload 変更に対する適応は、fixture の pytest だけでは実 runtime での成立を証明できないため。
applicable_acs: [AC3]
execution_environment: 現在の Claude Code session と repository のscripts/agent-ops/run_worktree_agent_runtime_smoke.py(claude実行ファイルが PATH 上にあり 2.1.285 以降であること、uvが利用可能であること)。SubAgent が text の marker を 1 行返すだけの無害な fixture prompt を使う。mutation・外部 code 実行・network は行わない。
skip_conditions:claude実行ファイルまたはuvが利用不能な場合は、runner / VC は exit 77 と stdout 先頭SKIP:で SKIP を宣言する(docs/dev/runtime-verification-policy.mdの SKIP 規約に従う)。SKIP は PASS ではなく Stop Condition として扱う。
fallback_policy: pytest の PASS・fake claude・runner の SKIP・unverifiedの結果を、AC3 の PASS として扱わない。
artifact_requirements: AC3 は worktree-local のartifacts/runtime-smoke/subagentstop-handback-provenance/(main へ commit しない)配下の runner evidence を証跡とする。新しい schema・receipt・publisher は追加しない。
runtime_assertion_bindings:
- profile: subagent-lifecycle-causal-evidence-smoke
assertion: subagent_start_stop_causal_evidence_correlated
ac: AC3
In Scope
- runner の causal evidence parser の最小適応。相関した SubagentStop event に空でない
last_assistant_messageが無い場合に限り、hook のagent_idとagentIdが一致し、かつstatus == completed(terminal 成功)である Agent tool のtool_use_result.handbackReport.textを、marker provenance の追加入力として使う。 last_assistant_messageが存在する場合の既存挙動は byte-identical に保つ。- start/stop の相関、tool invocation の相関、qualifying candidate がちょうど 1 件であること、
agent_transcript_pathの存在といった既存の要件は緩めない。 handbackReportが無い・相関しない・terminal でない・矛盾する場合はno_evidenceのままとする(fail-closed)。- 使用した provenance source を、evidence summary の既存 schema の慣習に収まる場合に限り、allowlist 済みの加算的 field として記録する。収まらない場合は記録しない。
- 上記の fixture pytest を
scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.pyに追加する。 - 無害な live smoke 用 fixture prompt を新規に追加する。実装: 独立 claude -p の runtime VC に bounded な approval carrier と non-executable 検出を追加する (#2839) #2844 が追加する
runtime_vc_lifecycle_smoke_prompt.mdとは file 名を分け、衝突を避ける。
Out of Scope
- generic な hook compatibility framework の導入。
- Claude Code の version pinning・downgrade。
--require-subagent-causal-evidenceの要件の緩和。- 実装: 再発防止: Auto mode runtime VC の独立 claude -p session で approval context 欠落による false capability-blocker を防ぐ #2839 / PR 実装: 独立 claude -p の runtime VC に bounded な approval carrier と non-executable 検出を追加する (#2839) #2844 の carrier・overlay・precondition のコードの変更。
- 実装: Claude-GPT model/proxy 更新の runtime migration を完了工程に含め、人間介入を genuine blocker に限定する #2810 / PR 実装: Claude-GPT model/proxy runtime migration の3分類ルーティングを追加する #2831 の変更。
- 新しい gate / approval 層の追加。
--claude-adapter claude-gptの挙動の変更(parser の変更が結果として及ぼす範囲を超えるもの)。.claude/skills/worktree-agent-runtime-smoke/references/claude-code.mdの更新。skill 配下の文書であり、skill 契約の hard trigger と 実装: 再発防止: Auto mode runtime VC の独立 claude -p session で approval context 欠落による false capability-blocker を防ぐ #2839 / 実装: Claude-GPT model/proxy 更新の runtime migration を完了工程に含め、人間介入を genuine blocker に限定する #2810 / 実装: runtime_only VC の repository PreToolUse guard 互換性を Step 2 で早期検証する #2824 との重複を避けるため、本 Issue では扱わない。文書化が必要なら別 Issue で扱う。- 実装: runtime_only VC の repository PreToolUse guard 互換性を Step 2 で早期検証する #2824 の PreToolUse guard の compatibility(本 Issue は触れない)。
- 調査: Claude Code 2.1.285 で worktree-agent-runtime-smoke の SubAgent causal evidence が no_evidence になる原因を切り分ける #2846(research 親)への追記。cross reference は control-plane が行う。
Acceptance Criteria
- AC1:
last_assistant_messageが無い SubagentStop event と、hook のagent_idに一致するagentId・status == completed・期待 marker を持つhandbackReport.textの組がhook_id_correlatedになることが、fixture pytest で検証されている。last_assistant_messageが存在する場合の結果が従来どおりであることも検証されている(test 名にhandbackreport_provenanceを含める)。 - AC2:
handbackReportのagentId不一致・statusがcompletedでない・marker 欠落・矛盾する重複のいずれの場合もhook_id_correlatedにならない(fail-closed)ことが、fixture pytest で検証されている(test 名にhandbackreport_fail_closedを含める)。 - AC3: 実 runtime の run で、runner が
--require-subagent-causal-evidenceを付けた構造化 mode の smoke に PASS し、causal_evidence_source == hook_id_correlatedとなる(Claude Code 2.1.285 以降)。 - AC4: 既存の causal evidence test(47 件)が引き続き PASS している。
Verification Commands
# AC1
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -q -k handbackreport_provenance
# AC2
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -q -k handbackreport_fail_closed
# AC3
# preflight-scope: runtime_only
$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree "$PWD" --prompt-file scripts/agent-ops/tests/fixtures/subagentstop_handback_provenance_smoke_prompt.md --output-dir artifacts/runtime-smoke/subagentstop-handback-provenance --timeout-seconds 300 --max-turns 6 --agent-type pr-reviewer --expect-marker-source subagent --expect-marker "SUBAGENTSTOP_HANDBACK_PROVENANCE_SMOKE_OK" --require-subagent-causal-evidence --require-min-subagents 1 --require-clean-postcondition
# AC4
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -qAllowed Paths
- scripts/agent-ops/run_worktree_agent_runtime_smoke.py
- scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py
- scripts/agent-ops/tests/fixtures/subagentstop_handback_provenance_smoke_prompt.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- 実装が
--require-subagent-causal-evidenceの要件の緩和、または generic な compatibility 層を必要とすると判明した場合 - AC3 が SKIP(exit 77)または FAIL になった場合は PASS 扱いにせず、報告して停止する(原因を修正した新しい head でのみ再実行する)
Required Skills
なし
Required Design References
- docs/dev/runtime-verification-policy.md
- docs/dev/extension-surface-runtime-policy.yaml
- scripts/agent-ops/run_worktree_agent_runtime_smoke.py
Delivery Rule
1 Issue = 1 PR。Draft PR を既定とする。- 順序: PR 実装: 独立 claude -p の runtime VC に bounded な approval carrier と non-executable 検出を追加する (#2839) #2844(Issue 実装: 再発防止: Auto mode runtime VC の独立 claude -p session で approval context 欠落による false capability-blocker を防ぐ #2839)も
scripts/agent-ops/run_worktree_agent_runtime_smoke.pyを変更するが、変更領域が異なる(実装: 独立 claude -p の runtime VC に bounded な approval carrier と non-executable 検出を追加する (#2839) #2844 は carrier / overlay / precondition、本 Issue は causal evidence の parsing)。どちらが先に merge されても、後から merge する側が rebase する。両 PR の間で copy / cherry-pick しない。 - 関連: 調査: Claude Code 2.1.285 で worktree-agent-runtime-smoke の SubAgent causal evidence が no_evidence になる原因を切り分ける #2846(research 親)、実装: 再発防止: Auto mode runtime VC の独立 claude -p session で approval context 欠落による false capability-blocker を防ぐ #2839 / PR 実装: 独立 claude -p の runtime VC に bounded な approval carrier と non-executable 検出を追加する (#2839) #2844(blocked consumer)、実装: Claude-GPT model/proxy 更新の runtime migration を完了工程に含め、人間介入を genuine blocker に限定する #2810 / PR 実装: Claude-GPT model/proxy runtime migration の3分類ルーティングを追加する #2831、実装: 再発防止: 独立 VC の正規消費経路を Step 2 / 4 / 5 に接続し、検証未了・失効後の approved を防ぐ #2837、実装: runtime_only VC の repository PreToolUse guard 互換性を Step 2 で早期検証する #2824(触れない)、調査: structured causal-evidence smoke の markerless FAIL を --no-session-persistence 契約と照合する #2338 / 実装: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定と runtime verification policy 更新を導入する #2183(closed)。
Scope Delta(任意)
なし
Notes for Reviewer
- 新規の fixture prompt は
.mdのため PR Body Japanese Check の対象になる。各 prose block に日本語の注記を含める。 references/claude-code.mdの更新は、skill 契約の hard trigger を避けるため Out of Scope とした。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Sep 30, 2026
implement-issue: 実装完了
worktree-issue-2848-handback-provenancefix: Agent invocation 単位の result 矛盾を handbackReport 有無と独立に fail-close…
fix: SubagentStop に last_assistant_message が無い場合に handbackReport で ma…
squne121 commentedon Sep 30, 2026
完了報告
PR #2849(merge commit
ab2d9238f4c762a68da29d4da7b36597161f5f41)が main に merge され、この Issue の受け入れ条件 AC1〜AC4 は同 PR で満たされています。PR 本文のCloses #2848による自動 close が反映されなかったため、手動で close します。FACT_TASK_IDENTITY_CONFLICTで適用できませんでした。人間の判断で signal を経由せずにローカル cleanup(worktree・branch の削除、main の更新)を実施しています。