Skip to content

調査: Claude Code 2.1.285 で worktree-agent-runtime-smoke の SubAgent causal evidence が no_evidence になる原因を切り分ける #2846

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: research
parent_issue: "none"
goal_ref: "Claude Code 2.1.285 で runtime smoke の SubagentStop 由来 causal evidence が no_evidence になる原因を特定し、最小修正方針を決める"
change_kind: research-only

Parent Issue

none

Background

2026-09-30 に実測した事実を以下に記す。

Outcome

scripts/agent-ops/run_worktree_agent_runtime_smoke.py の marker provenance と causal evidence 導出が 2.1.285 で no_evidence になる根本原因を、2.1.284 と 2.1.285 の SubagentStop payload と subagent transcript path の差分証跡付きで特定し、最小修正方針(parser 適応、または version constraint の文書化)を本 Issue のコメントに記録して、必要なら follow-up implementation Issue が起票可能な状態にする。

In Scope

  • run_worktree_agent_runtime_smoke.py 内の marker provenance / causal evidence 導出ロジックの読解
  • 2.1.284 と 2.1.285 の stream-json、SubagentStop hook payload、subagent transcript path 有無の比較
  • 2.1.285 が SubagentStop payload を変更したか(field の有無)の判定と証跡の記録
  • 最小修正方針の決定(parser 適応 vs version constraint 文書化)
  • 必要な場合の follow-up implementation Issue の起票(本 Issue の Allowed Paths 外の実装は含まない)

Out of Scope

Runtime Verification Applicability

  • decision: immediate
  • reason: runner と Claude Code runtime の相互作用は静的テストだけでは証明できず、2.1.285 の実 payload を採取して判定する必要があるため。
  • if immediate: AC2 が runtime 証跡(実 payload 差分)を要求する。

Acceptance Criteria

  • AC1: run_worktree_agent_runtime_smoke.py が marker provenance と causal evidence をどの入力(hook payload、transcript path、stdout)から導出するかが、本 Issue のコメントに記録されている
  • AC2: 2.1.285 が SubagentStop payload を変更したか(field の存在と欠落)が 2.1.284 との比較証跡付きで判定され、コメントに記録されている
  • AC3: 最小修正方針(parser 適応、または version constraint の文書化)が決定され、follow-up implementation Issue の参照、または文書化先が本 Issue のコメントに記録されている
  • AC4: 導出ロジックの既存 fixture テストが baseline で通ることが確認され、調査結果の比較基準として記録されている

Verification Commands

# AC1
$ rg -n "marker_provenance_transcript_fallback_used" scripts/agent-ops/run_worktree_agent_runtime_smoke.py
# AC2
$ rg -n "SubagentStop" scripts/agent-ops/run_worktree_agent_runtime_smoke.py
# AC3
$ gh issue view 2839 --repo squne121/loop-protocol --json number,state
# AC4
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -q

Allowed Paths

  • (none) 読み取り専用。参照対象は scripts/agent-ops/**、.claude/skills/worktree-agent-runtime-smoke/**、docs/dev/runtime-verification-policy.md。成果物は Issue コメントと report で表現する。

Stop Conditions

  • Outcome / Scope / AC が検索可能な形で記載されていない場合は即停止
  • Allowed Paths 外への書き込みを試みた場合は即停止
  • 権限不足(permission denied)により操作が完了できない場合は即停止
  • 成果物の書き込みに失敗した場合(I/O エラー等)は即停止

Handoff Contract

Activity

  1. added
    phase/research
    agent/research
    on Sep 30, 2026
  2. squne121 commented on Sep 30, 2026

    @squne121
    OwnerAuthor

    調査結果(#2846 AC1〜AC4)

    結論: 原因は repository 側の parser の欠陥ではなく、Claude Code 2.1.285 の upstream 挙動変更です。2.1.285 では SubagentStop hook payload から last_assistant_message が出なくなりました。runner はこの field を marker provenance の一次入力としているため、no_evidence になります。最小修正は parser 適応です(version constraint の文書化ではありません)。

    調査は read-only で行い、repository file は変更していません。採取した raw stream は GitHub に投稿せず、field の有無・型・長さ・hash 相当の情報だけを記載します。

    AC1: 導出元(producer → parser → decision)

    すべて scripts/agent-ops/run_worktree_agent_runtime_smoke.py 内です(main 8eeca46a)。

    • producer: 子 claude -p の stream-json に含まれる SubagentStart / SubagentStop の hook_response(固定 overlay の cat hook が payload を echo する)。
    • parser: extract_claude_hook_lifecycle_events()(約 2214 行以降)が embedded JSON から agent_id / agent_type / agent_transcript_path / last_assistant_message を取り出す。
    • marker provenance: _marker_provenance_verified()(約 3585 行)。last_assistant_message に期待 marker がすべて含まれれば一次 provenance として成立する。無い場合だけ transcript を fallback として読む。
    • 判定: subagent_causal_evidence_verdict()(約 3712〜3854 行)。agent_transcript_path 存在、tool invocation 相関、terminal 成功、marker provenance が揃う候補がちょうど 1 件のときだけ hook_id_correlated。それ以外は no_evidence。
    • runner は tool_use_result.handbackReport を現時点でどの経路でも参照していない(handback の grep は 0 件)。

    AC2: 2.1.284 と 2.1.285 の SubagentStop payload 差分(runtime 実測)

    同一 worktree・同一 prompt(runtime_vc_lifecycle_smoke_prompt.md)・同一 argv(--no-session-persistence --include-hook-events --output-format stream-json、runner 固定 overlay と同一の --settings)で、ローカルに導入済みの 2.1.284 と 2.1.285 のバイナリをそれぞれ直接実行して比較しました。

    観測項目 2.1.284 2.1.285
    SubagentStop payload の key session_id, transcript_path, cwd, prompt_id, permission_mode, agent_id, agent_type, effort, hook_event_name, stop_hook_active, agent_transcript_path, last_assistant_message, background_tasks, session_crons 同じ集合から last_assistant_message だけが欠落
    last_assistant_message 存在(str、marker と完全一致) key 自体が存在しない
    agent_transcript_path 存在(str)。path の file は実在しない 存在(str)。path の file は実在しない
    SubagentStart payload 差なし 差なし
    tool_use_result.status completed completed
    tool_use_result.agentId と hook の agent_id 一致 一致
    tool_use_result.handbackReport.text marker と完全一致 marker と完全一致
    最終 result に marker あり あり

    読み取れること:

    • agent_transcript_path は両バージョンとも存在します。--no-session-persistence のため、どちらでも path の file は存在しません(transcript による fallback 検証は 2.1.284 でも成立しません)。したがって差は transcript path ではなく、last_assistant_message の欠落です。
    • 2.1.284 では last_assistant_message だけで marker provenance が成立し、transcript を必要としませんでした。2.1.285 では成立せず、transcript fallback も使えないため marker_provenance_verified=False となり no_evidence になります。
    • 2.1.285 でも marker は tool_use_result.handbackReport.text に残っており、agentId は hook の agent_id と一致します。

    upstream 側の裏付け(一次資料):

    • 2.1.285 の release notes に「Improved subagents in auto mode: a subagent's run now ends as soon as it hands its report back to its caller, instead of taking extra turns that reach no one」がある(https://github.com/anthropics/claude-code/releases/tag/v2.1.285 )。handback で run が終わるため、SubagentStop 時点に最終 assistant text が残らないことと整合する。これは runtime 実測との整合であり、因果の断定は避ける。
    • 公式 hooks docs は「final assistant text は Stop と SubagentStop の last_assistant_message を使う」と述べているが、SubagentStop の入力 field 一覧には載っていない(https://code.claude.com/docs/en/hooks )。release notes に SubagentStop payload の変更の記載は確認できなかった。つまり 文書化されていない挙動変更である。
    • SubAgent 経由の web 調査の一部(release notes の引用)は一次資料と一致しなかったため採用していない。上記はすべて root が一次資料を直接確認した内容である。

    AC3: 最小修正方針

    parser 適応を採用します。version constraint の文書化は採りません(新しい upstream を恒久的に排除することになり、runner の役割と合わないため)。

    • 方針: last_assistant_message が無い場合に限り、同一 agent_id に相関した Agent tool の tool_use_result.handbackReport.text を、marker provenance の追加の入力として使う。
    • 相関は既存の agentId 一致(hook の agent_id と tool_use_result.agentId)で行い、terminal 成功(status == completed)を必須にする。last_assistant_message がある場合の既存の挙動は変えない。
    • causal evidence の要件(start/stop の相関、tool invocation 相関、候補が 1 件であること)は緩めない。
    • generic な hook compatibility 層や permission 層は作らない。

    follow-up implementation Issue: 下記コメントで参照する(起票後に追記)。

    AC4: baseline 既存 fixture テスト

    uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py -q → 47 passed(main 8eeca46a、exit 0)。既存テストは last_assistant_message を持つ payload を前提としており、last_assistant_message が無く handbackReport だけがある形は未カバーである。この形を新しい回帰テストとして follow-up で固定する。

    参考: 影響範囲

  3. squne121 commented on Sep 30, 2026

    @squne121
    OwnerAuthor

    調査結果の反映(follow-up implementation Issue)

    最小修正方針(parser 適応)の follow-up implementation Issue を #2848 として起票しました。
    #2848

    AC3 の参照先はこの #2848 です。本 Issue(research-only)では repository file を変更していません。

  4. squne121 commented on Oct 2, 2026

    @squne121
    OwnerAuthor

    Backlog audit (2026-10-02): close as completed. #2846 recorded the root cause and selected parser adaptation as the remediation. Follow-up implementation Issue #2848 is CLOSED / completed (2026-09-30). The research-only Issue therefore has no remaining delivery scope.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/researchphase/research

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions