Skip to content

実装: SubAgent 発火前に bounded local context bundle を生成し Claude/Codex の両 loop で consume する #1909

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1889"
goal_ref: "SubAgent 起動直前に必要情報だけをローカルファイルへ出力し、Claude Code / Codex CLI の custom SubAgent へ同じ入力契約で渡す"
change_kind: workflow

Parent Issue

#1889

Parent Goal Ref

  • Goal: impl-review-loop と issue-refinement-loop の両方で、live authority(GitHub/repo/CI)・GitHub 人間向け履歴・ローカル context bundle の3面を混同せず運用する。
  • Desired Destination: Claude Code と Codex CLI の両方が dispatch context bundle を consume し、既存 GitHub machine-readable 経路が維持されている状態。

Current Validated Scope

  • impl-review-loop の直接 SubAgent(implementation-worker / test-runner / pr-reviewer)の起動直前 context bundle 生成・読取・破棄。
  • issue-refinement-loop の直接 SubAgent(codebase-investigator / web-researcher / issue-reviewer / issue-author)の起動直前 context bundle 生成・読取・破棄。
  • Claude Code の .claude/agents/*.md と Codex CLI の .codex/agents/*.toml における同一 semantic input contract。

Remaining Parent Gaps

Outcome

impl-review-loop と issue-refinement-loop の orchestrator が、対象 SubAgent を起動する直前に bounded なローカル context bundle(.claude/tmp/subagent-context/<run-id>/<agent>.json)を生成し、そのパスを起動入力へ含める状態。SubAgent は bundle を読み、live Issue/PR/head と照合した上で作業し、完了後に bundle は削除され、cross-session 再開時は GitHub から再生成される。

Runtime Verification Applicability

decision: immediate
applicable_acs: [AC1, AC2, AC3, AC4, AC5, AC6, AC7, AC8, AC9, AC10, AC11, AC12, AC13, AC14]
execution_environment: "Claude Code CLI と Codex CLI の両方が custom SubAgent/custom Agent を dispatch できる実行環境"
skip_conditions: "認証・CLI 前提が満たせない実行環境では exit 77 で SKIP する"
fallback_policy: "fallback(inline_fallback)実行が成功しても PASS として扱わない(fallback_success_is_pass: false)"
artifact_requirements: ".claude/artifacts/agent-ops/context-bundle/<run-id>/ 配下に生成・読取・削除の証跡を保存する"
required_runtime:
  - claude_code_custom_subagent_dispatch
  - codex_cli_custom_agent_dispatch
success_condition:
  - bundle_generated_before_spawn
  - agent_echoes_matching_bundle_id
  - context_source_is_local_bundle
fallback_success_is_pass: false

In Scope

  • SubAgent 起動直前の bounded context bundle generator(.claude/tmp/subagent-context/<run-id>/<agent>.json)。
  • atomic write(tmp へ書き込み後 rename)、permission 0600、cleanup(完了後削除/24時間超の stale bundle 削除)。
  • impl-review-loop の対象 SubAgent(implementation-worker / test-runner / pr-reviewer)の dispatch への接続。
  • issue-refinement-loop の対象 SubAgent(codebase-investigator / web-researcher / issue-reviewer / issue-author)の dispatch への接続。
  • Claude Code (.claude/agents/*.md) と Codex CLI (.codex/agents/*.toml) の入力契約への context_bundle_path 追加。
  • bundle ID/digest の SubAgent result への echo。
  • fixture test と Claude/Codex の live smoke。

Out of Scope

  • GitHub コメントの投稿先変更(Child B の責務)。
  • human report template(Child B の責務)。
  • raw transcript の保存、永続 LOOP_STATE、event ledger、Agent memory への保存。
  • 新規 SubAgent の追加。
  • GitHub 上の既存 machine-readable 経路の撤去。

Acceptance Criteria

  • AC1: orchestrator が各対象 SubAgent の起動直前に bundle を生成する。
  • AC2: bundle 完成前に SubAgent を起動しない。
  • AC3: bundle は有効な JSON で、必須 field と bounded size を満たす。
  • AC4: bundle のファイル permission が 0600 である。
  • AC5: bundle に credential・token・cookie・raw transcript・full tool output・absolute repository path が含まれない。
  • AC6: Claude/Codex の対象 Agent が context_bundle_path を入力として受理する。
  • AC7: SubAgent result が bundle_id と context_source: local_bundle | inline_fallback を返す。
  • AC8: missing/malformed bundle では stale file を再利用しない。
  • AC9: SubAgent 完了後に bundle を削除する。
  • AC10: 24時間超の stale bundle を cleanup する。
  • AC11: resume 時は GitHub から bundle を再生成する(古いローカル bundle を再利用しない)。
  • AC12: issue-refinement-loop の既存 planner_input/ARTIFACT を再利用し、同じ情報を別形式で重複生成しない。
  • AC13: 既存 machine-readable GitHub comment consumer が回帰しない。
  • AC14: Claude Code と Codex CLI の live smoke で bundle consumption を確認する。

Verification Commands

$ uv run --locked pytest scripts/agent-ops/tests/test_build_subagent_context_bundle.py -q
# AC1
# AC2
# AC3
# AC4
# AC5
# AC8
# AC9
# AC10
# AC11
# AC12
$ rg -n -e "context_bundle_path" -e "bundle_id" -e "context_source" .claude/agents .codex/agents .claude/skills/impl-review-loop .claude/skills/issue-refinement-loop
# AC6
# AC7
$ git diff --check
# AC13
# baseline-expect: pass
# AC14
# preflight-scope: pr_review_only
$ echo "live smoke evidence recorded in PR description per artifact_evidence"

Allowed Paths

  • scripts/agent-ops/build_subagent_context_bundle.py
  • scripts/agent-ops/tests/test_build_subagent_context_bundle.py
  • docs/dev/agent-skill-boundaries.md
  • .claude/skills/impl-review-loop/SKILL.md
  • .claude/skills/impl-review-loop/steps/context-protocol-and-guardrails.md
  • .claude/skills/issue-refinement-loop/SKILL.md
  • .claude/agents/implementation-worker.md
  • .claude/agents/test-runner.md
  • .claude/agents/pr-reviewer.md
  • .claude/agents/codebase-investigator.md
  • .claude/agents/web-researcher.md
  • .claude/agents/issue-reviewer.md
  • .claude/agents/issue-author.md
  • .codex/agents/implementation-worker.toml
  • .codex/agents/test-runner.toml
  • .codex/agents/pr-reviewer.toml
  • .codex/agents/codebase-investigator.toml
  • .codex/agents/web-researcher.toml
  • .codex/agents/issue-reviewer.toml
  • .codex/agents/issue-author.toml

Stop Conditions

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

Required Skills

なし

Required Design References

  • docs/dev/agent-skill-boundaries.md
  • docs/dev/workflow.md
  • .claude/skills/issue-refinement-loop/references/anchor-comment-handling.md

Scope Delta(任意)

N/A

Notes for Reviewer

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions