Skip to content

実装: 通常 claude-gpt 対話中、明示 @ 指示時だけ GPT-5.3-Codex-Spark SubAgent を起動する #2186

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "2154"
goal_ref: "通常の claude-gpt 対話セッション中、user が current turn で明示的に canonical @agent-spark-codex mention を書いた場合だけ、main session model を変えずに GPT-5.3-Codex-Spark を SubAgent として起動し、causal evidence で実際の Spark 使用を証明する"
change_kind: mixed
runtime_verification_applicability: immediate
child_id: spark-explicit-subagent
dedupe_key: "claude-gpt-gpt-5.3-codex-spark-explicit-subagent-v1"

Parent Issue

#2154

Parent Goal Ref

  • Goal: Claude Code を共通 development harness とし、Anthropic subscription と ChatGPT Pro Codex subscription を独立 runtime として並列運用できる状態へ移行し、Codex CLI 実行系を段階的に廃止する。
  • Desired Destination: Native Claude と通常 claude-gpt(main Terra / opus Sol / sonnet Terra / haiku Luna)が config・credential・session・working tree を分離して並列稼働し、Spark は通常 destination を置換しない明示的 guarded opt-in の SubAgent としてだけ扱われる。

Current Validated Scope

Remaining Parent Gaps

  • Spark の entitlement、request parameter、tool、reasoning effort/summary、encrypted continuation、server compaction の live compatibility は未証明である。
  • 「UserPromptSubmit で観測した mention」を「直後の PreToolUse(Agent) の authorization」へ束縛する hook-native な一級 API は現時点で存在しない。nonce/session_id/prompt_id keyed sidecar による自前実装が必要であり、これは scripts/claude-gpt/launch.sh の既存 hook-sink パターンと整合する形で構築する。
  • @agent-spark-codex mention が code block・quoted text・別ソースからの injected text 内に現れた場合に Claude Code 自身の mention parser がそれを invocation syntax として扱わないことは公式ドキュメントで明言されていない。authorization detection は UserPromptSubmit の raw prompt 文字列への単純 substring match ではなく、SubagentStart payload の agent_type 等 Claude Code 自身が resolve した結果で裏付ける設計にする。
  • 非 Anthropic full model ID を持つ session-local SubAgent が実際に per-subagent 単位で proxy 経由 GPT backend へ route されるかは live 検証が必要な未確認の前提である。
  • 実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160 の provider-neutral parity と 実装: retire Codex CLI assets and documentation(Phase 3, Child 3 of #2154) #2161 の Codex CLI retirement は本 child の scope 外である。
  • scripts/claude-gpt/launch.sh --profile spark(session-wide pre-start profile として Spark を選択する UX)は本 child の Outcome / closure condition に含めない。独立した機能として将来必要になった場合でも、本 Issue の中では新規 Issue を起票しない。

Background

前回の Issue 設計(--profile spark による fresh session/process 起動)は、OWNER の direct human intent(通常 claude-gpt 対話セッションを維持し、user が current turn で明示した場合だけ Spark を SubAgent として使う。main session model を Spark に切り替えない)を4軸すべてで反転させていたため、reframe_in_place の対象となった。

human_intent:
  interaction_mode: interactive
  trigger: explicit_current_turn
  execution_unit: subagent
  main_session_model_change: false

Spark は text-only research preview として扱い、source document context ceiling は 128K である。通常 profile の [1m] 又は 272K 設定・閾値を継承してはならない。ordinary model と Spark の hot switch、stale session resume、Spark からの automatic fallback、quota exhaustion を契機とする切替はいずれも禁止する。

proxy は Spark を full Responses lane として扱い、Lite lane を採用しない。catalog/allowlist の存在だけで entitlement や request/tool/context compatibility を主張しない。reasoning effort、reasoning summary、encrypted continuation は別々の互換性項目として扱う。reasoning summary suppression は upstream-supported な scoped mechanism を runtime canary で確認できた場合に限り、Spark child にだけ確認済み値を inject する。確認できない場合は停止する。

Outcome

通常 claude-gpt 対話セッションの main session model・ordinary SubAgent model mapping・Native runtime を一切変更せず、claude-gpt session 内にだけ Spark custom SubAgent(spark-codex)を登録し、user が current turn で canonical @agent-spark-codex を明示した場合だけ起動する。authorization は current turn かつ exactly-one-invocation に限定され、次 turn/resume へ持ち越されない。automatic fallback は一切禁止し、Spark delegated task の失敗は親へ明示的に返され、main claude-gpt session は以降も ordinary turn を継続できる。実際の Spark model 使用は PR #2220/#2222 の causal evidence 機構を reuse した hook ID 相関で証明し、自己申告や prompt 出力の model 名は証拠にしない。

In Scope

  • claude-gpt session にだけ spark-codex custom SubAgent(.claude/agents/相当の session-local 定義、model に Spark の full model ID を指定)を登録する。Native session・通常 claude-gpt の main model・ordinary SubAgent mapping は不変。
  • UserPromptSubmit → current-turn の canonical @agent-spark-codex mention 検出・nonce/session_id/prompt_id keyed authorization 記録 → PreToolUse(Agent)(新規 matcher 追加)→ subagent_type == spark-codex かつ authorization 存在時のみ許可・authorization consume → SubagentStart(agent_id) → SubagentStop(agent_id) → parent 受信、の deterministic fail-closed gate を実装する。authorization が存在しない spark-codex 起動は deny する。
  • authorization は現在 turn かつ 1 回限りの invocation に限定し、次 turn・resume・duplicate invocation には持ち越さない。
  • quoted text、code block 内 mention、過去 turn の mention、typo、別 agent mention は authorization として扱わない。detection は UserPromptSubmit の raw prompt 文字列への単純 substring match だけに依存せず、SubagentStart payload の Claude Code 自身が resolve した agent_type で裏付ける。
  • 他 SubAgent や main model からの自律的 spark-codex 起動(top-level 自律呼び出し、nested SubAgent からの delegation の双方)を拒否する。
  • Spark delegated task が失敗しても main claude-gpt session が死なないよう failure を task スコープに閉じ込め、失敗後も同一 session で ordinary turn を継続できることを確認する。
  • PR feat: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定を追加する #2220 の subagent_causal_evidence_verdict() / extract_claude_hook_lifecycle_events() と PR feat: worktree-agent-runtime-smoke に claude-gpt 同一 session multi-turn / 複数 SubAgent lifecycle 判定を追加する #2222 の multi-turn/lifecycle 判定機構を reuse し、requested_model / agent_resolved_model / proxy_observed_model の3フィールドがすべて gpt-5.3-codex-spark で一致することを causal evidence として証明する。model 名の自己申告や prompt 出力は証拠にしない。
  • unsupported entitlement、catalog unavailable、request parameter incompatibility、quota、tool incompatibility、context/continuation error を sanitized structured classification として出力する。credential、token、raw auth、raw request/response、raw transcript は capture、persist、report しない。unsupported entitlement は exit 77 の SKIP/blocked として記録し、PASS や ordinary model への automatic fallback に昇格させない。
  • focused deterministic tests と default normal runtime regression を allowed paths 内で更新する。

Out of Scope

  • scripts/claude-gpt/launch.sh --profile spark(session-wide pre-start profile モデル)。独立した機能として将来必要になった場合でも、本 Issue のスコープにも closure condition にも含めない。本 Issue 内で新規 Issue も起票しない。
  • Native profile、通常 claude-gpt mapping(main Terra / opus Sol / sonnet Terra / haiku Luna)、provider-neutral project agent definitions(既存 .claude/agents/** の12定義)、CLAUDE_CODE_SUBAGENT_MODEL の変更。
  • main session model の Spark への切り替え、/model を Spark 選択経路にすること、session 全体の resume/hot switch。
  • image/web-search capability の Spark への付与、意図的 quota exhaustion、credential/auth/raw transcript の保存又は投稿。
  • 非 Anthropic full model ID を持つ session-local SubAgent が per-subagent 単位で実際に proxy 経由 GPT backend へ route されることの一般的な保証(本 child は Spark 固有の live canary でのみ検証し、一般化された仕組みとしては主張しない)。
  • 実装: migrate agent/runtime parity contracts(Phase 2, Child 2 of #2154) #2160 の provider-neutral parity、実装: runtime guard が peer pytest nodeids を child write と誤帰属しないようにする #1526(.pytest_cache/v/cache/nodeids の unauthorized_write_path 誤検知修正)の実装。

Acceptance Criteria

  • AC1: Spark directive のない通常 turn では main claude-gpt session の model(main Terra / opus Sol / sonnet Terra / haiku Luna)・ordinary SubAgent mapping・Native profile は一切変更されない。
  • AC2: user が current turn で canonical @agent-spark-codex を明示した場合にのみ、UserPromptSubmit → PreToolUse(Agent) → subagent_type == spark-codex → authorization consume → SubagentStart/SubagentStop の fail-closed gate を通って spark-codex SubAgent が起動する。quoted mention、code block 内 mention、typo、別 agent mention では起動しない。
  • AC3: authorization は current turn かつ exactly-one-invocation に限定される。過去 turn にのみ存在した directive、同一 authorization からの duplicate invocation、次 turn・resume への持ち越しはいずれも拒否される。
  • AC4: Spark 起動時、requested_model / agent_resolved_model / proxy_observed_model の3フィールドがすべて gpt-5.3-codex-spark で一致する causal evidence(PR feat: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定を追加する #2220 の hook ID 相関機構 reuse)が得られる。parent の自己出力 marker や prompt 内の model 名の自己申告だけでは証拠にならない。
  • AC5: 他 SubAgent からの nested delegation、main model からの自律的呼び出しはいずれも spark-codex を起動しない。
  • AC6: Spark delegated task を強制失敗させても、同一 main claude-gpt session は直後の ordinary turn を正常に継続できる(failure isolation の positive control)。
  • AC7: entitlement unavailable、catalog unavailable、quota、tool/context incompatibility はいずれも自動 fallback せず SKIP/blocked(exit 77)として記録され、PASS や ordinary model fallback に昇格しない。
  • AC8: 同一 main claude-gpt session 内で ordinary → explicit Spark → ordinary(未起動であること) → explicit Spark(fresh child identity であること) の4-turn live sequence を確認する。
  • AC9: baseline regression(pnpm typecheck、pnpm lint、pnpm test、pnpm build、model-routing test)が PASS する。

Runtime Verification Applicability

decision: immediate
reason: "Spark entitlement、explicit-only gate の実 hook chain 動作、causal evidence 相関、failure isolation は static test だけでは証明できない"
applicable_acs: [AC2, AC4, AC6, AC7, AC8]
execution_environment: "ChatGPT Pro Codex authentication と proxy が利用できる clean worktree。#2174/PR #2176・#2183/PR #2220・#2219/PR #2222 の merged infrastructure が前提。"
skip_conditions: "proxy/auth unavailable、unsupported entitlement、又は安全に redacted evidence を作れない場合。VC は SKIP: を先頭に出し exit 77 とし、stop_condition_triggered: true を記録する。"
fallback_policy: "Spark、ordinary model、Lite lane、cached/catalog-only result のいずれへの fallback も PASS にしない。unsupported entitlement は SKIP/blocked、実行可能環境での incompatibility は classified FAIL/blocked とする。"
artifact_requirements: "worktree-local の sanitized evidence のみを保存し、PR には expected_evidence_fields と verdict の compact summary のみを引用する。raw log/transcript は commit 又は GitHub 本文へ貼らない。"
  • expected_evidence_fields:
    • schema, status, verdict, exit_code, timestamp, sut.git_head, sut.launcher_sha256, proxy.version
    • requested_model, agent_resolved_model, proxy_observed_model, models_used, fallback_observed:false
    • authorization_turn_id, authorization_consumed:true, authorization_carryover:false
    • agent_id, session_id, prompt_id, causal_evidence_source:hook_id_correlated
    • classification(unsupported_entitlement|unavailable_catalog|request_parameter_incompatibility|quota|tool_incompatibility|context_continuation_error|other_safe_failure)
    • failure_isolation_confirmed, main_session_survived:true
    • redaction_confirmed:true(credential/token/raw auth/raw request/response/raw transcript を含めない)

Verification Commands

# AC1
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_operator_journey.py
# AC2
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py -k mention_authorization
# AC3
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py -k authorization_single_use
# AC4
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py
# AC5
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py -k nested_delegation_forbidden
# AC6
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py -k failure_isolation
# AC7
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py -k no_fallback_skip_blocked
# AC8
$ uv run pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_hermetic_matrix.py
# AC9
$ pnpm typecheck
# Baseline requirement for AC9
$ pnpm lint
# Baseline requirement for AC9
$ pnpm test
# Baseline requirement for AC9
$ pnpm build
# Baseline requirement for AC9
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py

Allowed Paths

  • .claude/settings.json
  • .claude/agents/spark-codex.md
  • scripts/claude-gpt/launch.sh
  • scripts/claude-gpt/lib.sh
  • scripts/claude-gpt/preflight.sh
  • .claude/skills/worktree-agent-runtime-smoke/SKILL.md
  • .claude/skills/worktree-agent-runtime-smoke/references/claude-code.md
  • docs/dev/runtime-verification-policy.md
  • scripts/agent-ops/run_worktree_agent_runtime_smoke.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_bin.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_bin_settings_channel.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_operator_journey.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_causal_evidence.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_claude_gpt_hermetic_matrix.py
  • scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py
  • scripts/claude-gpt/test_launch_strict_mcp_config_normalization.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合。
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合。
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)。
  • 後続 Phase / 別スコープへの波及が判明した場合。
  • nested SubAgent delegation が必要になった場合。
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合。
  • explicit-only gate(UserPromptSubmit → authorization → PreToolUse(Agent) → consume → SubagentStart/SubagentStop)が現行 Claude Code hook semantics で deterministic に構築できないと判明した場合。description prose だけへの格下げは禁止し、この場合は実装を停止する。
  • 非 Anthropic full model ID を持つ SubAgent の per-subagent model routing が live 検証で確認できない場合。
  • upstream-supported な scoped reasoning summary suppression を確認できない場合。
  • credentials/evidence safety 又は sanitized failure classification を保証できない場合。
  • Native / 通常 claude-gpt の main model・ordinary SubAgent mapping に影響する場合。
  • automatic fallback、deliberate quota exhaustion、secret export、又は allowed paths 外の変更が必要になる場合。
  • runtime VC が SKIP(exit 77)を返した場合、又は fallback 経由でのみ成功する場合。SKIP は PASS に昇格しない。

Required Skills

  • Claude Code custom SubAgent 登録 / model resolution / hook lifecycle(UserPromptSubmit / PreToolUse / SubagentStart / SubagentStop)
  • claude-gpt launcher architecture(scripts/claude-gpt/launch.sh / lib.sh、env -i scoped injection パターン)
  • claude-code-proxy の request-level model routing(Codex provider、ALLOWED_MODELS allowlist)
  • GPT-5.3-Codex-Spark の runtime constraints(text-only、128K 保守的 context ceiling、entitlement gating、独立 rate-limit pool)
  • worktree-agent-runtime-smoke

Required Design References

Notes for Reviewer

Merged baseline reconciliation: #2174/PR #2176、#2183/PR #2220、#2219/PR #2222 は全て MERGED 済みであり、blocker でも open coordination target でもない。旧本文の「draft PR #2176」表記は stale であったため削除した。

未確認の技術的前提として reviewer に特に検証してほしい点: (1) .claude/agents/*.md の model: に非 Anthropic full model ID(gpt-5.3-codex-spark)を指定した場合に、その SubAgent 単体だけが proxy 経由で GPT backend へ route され、parent session が Claude のままであることは repository にも公式ドキュメントにも先例・確証がなく live 検証が必要である。(2) UserPromptSubmit の mention 検出を PreToolUse(Agent) の authorization consume へ束縛する hook-native な一級 API は存在しないため、nonce/session_id/prompt_id keyed sidecar の自前実装が必要であり、この実装自体が spoofing に対して安全であることを reviewer は確認すること。

Operational risk reports(normative specification ではない): openai/codex#32537, openai/codex#19868, openai/codex#31969, openai/codex#22324, openai/codex#32132, https://github.com/openai/codex/issues/23243(context window の実効値に関する未解決の不一致)。

用語ルール

人間向けの報告・本文・コメントでは、モデルを必ず GPT-5.3-Codex-Spark または GPT-5.3-Codex-Spark SubAgent と呼ぶこと。spark-codex は Claude Code 内部の custom-agent identifier(agent_type)としてのみ使用し、モデル名・製品名の別称として文章中で用いないこと。

Delivery Rule

1 Issue = 1 PR。#2174/PR #2176、#2183/PR #2220、#2219/PR #2222 は merged 済みのため blocked-by 依存としない。dedicated worktree と Draft PR を既定にする。runtime evidence は sanitized compact result だけを PR に引用し、既存 Issue/PR の本文・comment mutation は本 Issue の delivery に含めない。

Activity

  1. added
    enhancement
    phase/implementation
    agent/implementer
    triage-required
    on Aug 15, 2026
  2. squne121 commented on Aug 15, 2026

    @squne121
    OwnerAuthor

    「scripts/claude-gpt/launch.sh --profile spark」その機能を追加することは別に妨げないが、おそらく私が想定しているユースケースと異なる実装になっています。ClaudeCodeを対話的に利用する際に、私が明示的にgpt-5.3-codex-sparkの利用をプロンプトに加えた際にのみgpt-5.3-codex-sparkサブエージェントを使って作業をしてほしいという意図です。非対話的なスクリプトの機能実装や、特定の引数を指定してclaude-gpt起動したときのみ、gpt-5.3-codex-sparkモデルを使用したいという意図ではありません。
    Required Skills なしとなっていますが、ClaudeCodeの運用に関する知識、Claude-GPTの実装に関する知識、動作検証として.claude/skills/worktree-agent-runtime-smokeスキルの利用が必要ではないですか?なぜなしを記載してしまったのか、ワークフローの見直しが必要だと思います。起票時、レビュー時、それぞれでGitHub Issueを作業の計画として見たときに、ClaudeCodeが作業に必要な知識をGitHub Issueにどのように記載できるか検討してほしいです。

  3. squne121 commented on Aug 17, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES — 推奨 disposition は reframe_in_place です。

    #2186 は Spark の制約や証跡設計をかなり慎重に扱っていますが、実装しようとしている利用形態が、OWNER の要求と逆になっています。現状のまま実装すると、「通常の claude-gpt 対話中に、明示したときだけ Spark SubAgent を使う」という目的を達成せず、別機能である「Spark を main model にした専用セッション起動」を完成させることになります。


    P0 — マージ阻害事項

    P0-1. authoritative human intent を反転している

    親 Issue の OWNER コメントは最初から、「人間がプロンプトで指示したときに Spark を利用する」と明記しています。今回の指定コメントも、「通常の Claude Code 対話中」「明示的にプロンプトへ加えたときだけ」「Spark サブエージェントを使う」と再確認しています。

    しかし #2186 は、以下を正本にしています。

    • prompt directive を選択機構にしない
    • launch.sh --profile spark で fresh Spark process を起動する
    • Task/SubAgent canary を Out of Scope にする
    • per-invocation Spark SubAgent override を Out of Scope にする
    • Task/SubAgent 追加が必要なら Stop Condition にする

    つまり、要求された経路を明示的に禁止し、要求されていない経路を Outcome にしています。

    親 #2154 側でも、OWNER の「プロンプトで指示」を「prompt submission 前に別プロファイルを起動する意味」と読み替えています。この再定義を OWNER が承認した証拠はなく、refinement による意味変更です。

    これは仕様の曖昧さではありません。以下の四軸すべてが反転しています。

    human_intent:
      interaction_mode: interactive
      trigger: explicit_current_turn_prompt
      execution_unit: subagent
      main_session_model_change: false
    
    current_issue:
      interaction_mode: pre_start_launcher
      trigger: cli_profile
      execution_unit: main_process
      main_session_model_change: true

    必須修正: #2186 の Outcome、In Scope、Out of Scope、AC、VC、Stop Conditions を全面的に書き換える必要があります。既存 body への部分追記では不十分です。


    P0-2. --profile spark は技術的にも必須ではない

    Claude Code は、セッション限定の custom subagent を --agents で登録でき、各 agent に full model ID を指定できます。また、自然言語による委譲は Claude の判断になりますが、@ で agent を明示すると、その agent の実行を保証できます。(Claude)

    claude-code-proxy も、単一のローカル endpoint のまま、各 request の model ID によって provider/model を振り分ける設計です。したがって、main session を Terra のまま維持し、Spark SubAgent の request だけ gpt-5.3-codex-spark にすることが可能な構造です。([claude-code-proxy]2)

    現行 launcher も、

    • main を Terra
    • opus / sonnet / haiku を Sol / Terra / Luna
    • CLAUDE_CODE_SUBAGENT_MODEL は unset

    としているため、特定 custom agent の model: 指定を尊重できる方向の構成です。

    したがって、正しい基本構成は次です。

    通常 claude-gpt session
    ├─ main: gpt-5.6-terra
    ├─ ordinary subagents: Sol / Terra / Luna
    └─ explicit-only subagent: gpt-5.3-codex-spark
    

    --profile spark 自体を別機能として追加することは妨げません。ただし、それを #2186 の完了条件にしてはいけません。必要なら別 Issue に分離すべきです。


    P0-3. 「明示時だけ」を agent description では保証できない

    custom agent を登録して description に「明示時だけ使用」と書くだけでは不十分です。Claude Code は description を見て自律的に委譲できるため、未指定時の起動を決定論的には防げません。

    正本 UX は次のようにすべきです。

    @agent-spark-codex この調査を行って
    

    または @ picker から spark-codex (agent) を選択する形式です。公式仕様上、これなら対象 agent の invocation を保証できます。自由文の「Sparkを使って」まで受理すると、自然言語 intent classifier の精度に依存し、「明示したときだけ」という安全契約を保証しにくくなります。([Claude]1)

    さらに未指定時の自律起動を防ぐには、hook による gate が必要です。

    1. UserPromptSubmit で現在 turn に正規の Spark agent mention があるか記録する。
    2. PreToolUse の Agent 呼び出しを検査する。
    3. subagent_type == spark-codex かつ current-turn authorization がない場合は拒否する。
    4. authorization は一回の invocation で consume し、次 turn に持ち越さない。
    5. Stop / StopFailure で残存状態を破棄する。

    Claude Code の hook 入力には session、tool input、tool-use ID、subagent type、resolved model、SubagentStart/Stop の agent ID など、必要な相関面があります。([Claude]3)


    P0-4. 現行 AC/VC は、要求された性質を一切証明できない

    現在の AC7 は text、Bash、fresh multi-turn、cleanup の canary を要求していますが、Task/SubAgent は明示的に未検証です。したがって、現在の VC がすべて PASS しても分かるのは次だけです。

    Spark を main model にした fresh process が動いた。

    要求されているのは次の因果チェーンです。

    current user turn の明示 authorization
      → Agent tool_use(subagent_type=spark-codex)
      → SubagentStart(agent_id=A)
      → actual model == gpt-5.3-codex-spark
      → SubagentStop(agent_id=A)
      → parent session へ結果返却
    

    さらに、以下の negative control が必要です。

    • Spark 指示なし
    • 前 turn にだけ Spark 指示あり
    • quoted text やコード例の中に agent 名があるだけ
    • typo または別 agent の指定
    • unrelated SubAgent が起動しただけ
    • parent が Spark 完了 marker を自己出力しただけ
    • requested model は Spark だが effective model が別モデル
    • Spark quota / entitlement failure 後に ordinary model へ落ちた
    • resume 後に古い authorization が残った

    PR #2220 は既に、Agent tool-use ID、SubagentStart/Stop の agent ID、child transcript、marker provenance を相関し、marker-only の偽陽性を拒否する実装を main に取り込んでいます。#2186 はこの証跡基盤を再利用すべきです。

    また #2219 / PR #2222 は、同一 Herdr session の multi-turn、複数 SubAgent lifecycle、hook sink、stale evidence、cleanup を扱っています。PR #2222 は現時点ではまだ open なので、#2186 はその current head と fresh collision review を行う必要があります。


    P0-5. Required Skills: なし は個別ミスではなく authoring/review contract の欠陥

    現行 authoring guidance は Required Skills を「ドメイン知識のみ」とし、workflow skill を書かないよう指示しています。一方、guard は canonical skill 名や repo-local skill の存在を検証する経路を持っています。つまり、同じ欄で次の異なる概念が混在しています。

    • 人間・Agent に必要な技術知識
    • 実行必須の repository skill
    • 読むべき設計資料
    • 動作検証 harness
    • workflow が暗黙に起動する skill

    この分類では、worktree-agent-runtime-smoke を「workflow skill なので書かない」と処理しつつ、Claude Code / claude-gpt の知識も canonical skill 名ではないため、結果として「なし」に正規化されやすくなります。

    レビュー側も、現在は決定論的な構造 checker の結果を LLM が relay する設計で、LLM が独自に意味評価を補完できません。

    さらに refinement loop は旧 adversarial review / spec review を採用せず、reviewer verdict を再評価せず直接信頼します。一方、issue-reviewer は anchor comment の domain judgment を orchestrator 責務としています。結果として、authoritative human intent と Outcome の意味同値性を最終的に所有する component がありません。

    これが、形式上 approve された Issue が OWNER 要求を反転できた根本原因です。


    P1 — 重大な改善事項

    P1-1. dependency 情報が stale

    #2186 は #2174 / 「draft PR #2176」を blocker としていますが、PR #2176 は既に merged です。

    現在の dependency は少なくとも次のように更新すべきです。

    古い blocker を解除するだけでなく、#2220/#2222 後の evidence schema に合わせて AC と expected evidence fields を再設計する必要があります。


    P1-2. Spark failure が session 全体を殺す設計になっている

    whole-session profile では、entitlement、quota、context、tool compatibility のどれかが失敗すると、ユーザーが通常作業していた claude-gpt session 全体が利用不能になります。

    SubAgent 方式なら、

    main Terra session: 継続可能
    Spark delegated task: 明示的に失敗
    automatic fallback: なし
    

    という failure containment が可能です。

    Spark は公式には ChatGPT Pro 向け research preview、128K、text-only、独立 rate limit と説明されています。registry に model ID があることと、当該アカウントで利用可能であることは別なので、account-specific catalog と actual request の両方を検証する必要があります。([OpenAI]4)


    P1-3. requested model ではなく effective model を証明する必要がある

    証跡には最低限、次を別フィールドで残すべきです。

    requested_model: gpt-5.3-codex-spark
    agent_resolved_model: gpt-5.3-codex-spark
    proxy_observed_model: gpt-5.3-codex-spark
    models_used:
      - gpt-5.3-codex-spark
    fallback_observed: false

    Claude Code の Agent tool lifecycle では resolvedModel / modelsUsed を取得でき、proxy 側も request model に基づいて routing します。片方だけではなく、両面を相関してください。([Claude]3)

    model self-report や prompt 出力に model 名が含まれたことは証拠にしてはいけません。


    P1-4. text-only と tool-less を混同しない

    Spark が text-only であることは、image input/output を扱わないという modality 制約です。Bash や file tools まで使用不能であることを意味しません。proxy は Claude tool calls を Responses API の function calls に変換します。したがって Bash canary 自体は妥当です。([OpenAI]4)

    ただし Issue では、以下を別々に規定すべきです。

    • input modality: text only
    • allowed tools: Read / Grep / Glob / Bash / Edit など
    • prohibited tools: Agent nesting、image系、必要なら WebSearch
    • context ceiling: 128K
    • main transcript 全体を無条件で Spark child に転送しない
    • continuation / compaction policy
    • failure classification

    P1-5. continuation と authorization の漏洩試験が不足

    proxy は設定によって Agent ID 単位の continuation を扱えるため、Spark child 間、通常 child 間、次 turn 間で state が混ざらないことを検証する必要があります。([claude-code-proxy]5)

    初版では continuation を無効化するのが安全です。その場合でも次のシーケンスを live test してください。

    Turn 1: ordinary request
    Turn 2: @agent-spark-codex request
    Turn 3: ordinary request, Spark must not run
    Turn 4: @agent-spark-codex request, new child identity
    

    P1-6. reasoning summary の値自体は blocker ではない

    現行 proxy は CCP_CODEX_REASONING_SUMMARY=off と none の双方を summary suppression 値として明示的にサポートしています。ここは現在の Issue の理解どおりで、欠陥ではありません。([claude-code-proxy]6)

    ただし AC で二つの値を許す必要はありません。tested proxy version と canonical 値を一つ固定し、通常 profile へ波及しないことを回帰確認する方が決定論的です。


    推奨する #2186 のリフレーム

    タイトル

    実装: 通常 claude-gpt 対話中、明示 @ 指示時だけ GPT-5.3-Codex-Spark SubAgent を起動する

    Outcome

    通常の claude-gpt 対話セッションでは main の Terra と既存 SubAgent mapping を維持し、ユーザーが current turn で @agent-spark-codex を明示した場合に限り、session-local custom SubAgent が gpt-5.3-codex-spark を使って実行される。未指定時の自律起動、前 turn からの authorization 持越し、model fallback、Native runtime への影響を禁止し、prompt authorization から actual model 使用・child completion までを hook/proxy evidence で fail-closed に証明する。

    推奨実装形

    spark_subagent:
      registration:
        scope: claude-gpt session only
        mechanism: launcher-owned runtime agent definition
        project_agent_asset_modified: false
    
      name: spark-codex
      model: gpt-5.3-codex-spark
    
      canonical_trigger:
        syntax: "@agent-spark-codex"
        scope: current user turn
        max_invocations_per_authorization: 1
    
      main_session:
        model: gpt-5.6-terra
        changed: false
    
      fallback:
        automatic_model_fallback: forbidden
        ordinary_agent_substitution: forbidden
    
      failure_boundary:
        spark_task_failure: reported_to_parent
        main_session_remains_usable: true

    runtime agent definition は launcher が所有し、generic caller が任意 JSON を注入するだけの --agents passthrough にしない方が安全です。現行 launcher は -- 後の Claude 引数を透過できますが、専用 agent contract としては以下のいずれかを採用すべきです。

    • launcher が固定 --agents JSON を追加し、caller の重複 --agents を拒否する
    • isolated CLAUDE_CONFIG_DIR 配下へ launcher-owned agent definition を生成する
    • validated merge helper で caller agent JSON と安全に合成する

    provider-specific model ID を共有 .claude/agents/** にコミットしない点は、親 #2154 の provider-neutral 方針を維持できます。


    推奨 Acceptance Criteria

    1. 通常経路不変
      Spark 指示なしでは main Terra、既存 Sol/Terra/Luna mapping、Native runtime が一切変わらない。

    2. session-local registration
      claude-gpt 起動時だけ spark-codex agent が登録され、共有 .claude/agents/** に Spark ID を追加しない。

    3. 明示 invocation
      current turn の正規 @agent-spark-codex 指定により、Spark SubAgent が exactly one 回起動する。

    4. 未指定時禁止
      未指定、quoted mention、過去 turn の指定、typo、別 agent 指定では Spark Agent tool call が拒否される。

    5. actual model binding
      Agent tool-use、SubagentStart/Stop、Claude resolved model、proxy-observed model が exact Spark ID で相関する。

    6. no fallback
      entitlement、quota、request、tool、context failure 時に他モデルへ代替されず、Spark delegated task の classified failure になる。

    7. main session survival
      Spark delegated task が失敗しても、同じ claude-gpt main session で次の ordinary turn を継続できる。

    8. context/tool policy
      128K-safe input、text-only、固定 tool allowlist、Agent nesting禁止、continuation policy が tests と runtime evidence で一致する。

    9. same-session sequence
      ordinary → Spark → ordinary → Spark を同一 Herdr session で実行し、authorization・child identity・continuation が混ざらない。

    10. causal evidence
      feat: worktree-agent-runtime-smoke に hook ID ベースの SubAgent causal evidence 判定を追加する #2220 の tool-use/agent-ID/transcript provenance と、feat: worktree-agent-runtime-smoke に claude-gpt 同一 session multi-turn / 複数 SubAgent lifecycle 判定を追加する #2222 の hook sink/multi-turn evidence を current main へ統合した形で利用する。


    Issue 起票・レビュー workflow の修正

    1. Required Skills を分割する

    一つの欄で全概念を扱わず、最低でも次に分けるべきです。

    ## Required Domain Knowledge
    
    - Claude Code custom SubAgent、model resolution、Agent hooks
    - claude-gpt launcher と claude-code-proxy の request-level model routing
    - GPT-5.3-Codex-Spark の 128K / text-only / entitlement 制約
    
    ## Required Repository Skills
    
    - worktree-agent-runtime-smoke
    
    ## Required Repository Assets
    
    - scripts/claude-gpt/launch.sh
    - scripts/claude-gpt/lib.sh
    - scripts/agent-ops/run_worktree_agent_runtime_smoke.py
    - .claude/skills/worktree-agent-runtime-smoke/
    
    ## Required External References
    
    - Claude Code subagents
    - Claude Code hooks
    - OpenAI Spark specification
    - claude-code-proxy model routing / Codex provider documentation

    なし は、変更対象 subsystem から capability inventory を生成し、要求 capability が本当にゼロの場合だけ許可すべきです。

    2. Human Intent Traceability を必須化する

    human_intent_traceability:
      authoritative_source:
        - issuecomment-5302207566
        - issuecomment-5302663494
    
      dimensions:
        interaction_mode: interactive
        trigger: explicit_current_turn_prompt
        execution_unit: subagent
        main_model_change: false
    
      mapped_acceptance_criteria:
        interaction_mode: AC1, AC9
        trigger: AC3, AC4
        execution_unit: AC3, AC5
        main_model_change: AC1

    次の semantic delta は自動修復せず、必ず human_judgment_required にしてください。

    • interactive → pre-start script
    • prompt trigger → CLI argument
    • subagent → main model
    • current turn → session-wide
    • optional task → mandatory profile
    • delegated-task failure → process-wide failure

    3. review checker に追加すべき判定

    • C14_authoritative_intent_traceability
    • C15_required_capability_closure
    • C16_dependency_freshness
    • C17_verification_property_alignment

    特に C17 は、「VC が通ったとき、Outcome の性質が本当に証明されるか」を検査する必要があります。今回なら runtime_smoke_test.sh --profile spark が PASS しても「prompt-triggered SubAgent」は証明されないため、hard fail です。

    4. semantic review の責務を一箇所に置く

    現在は、

    • structural checker は意味を評価しない
    • reviewer は checker を上書きしない
    • anchor domain judgment は orchestrator 責務
    • orchestrator は reviewer verdict を再評価しない

    という循環になっています。

    OWNER anchor を持つ refinement では、専用の semantic reviewer を復活させ、以下を最終 authority にする必要があります。

    human anchor snapshot
      ↔ Outcome
      ↔ In/Out of Scope
      ↔ AC
      ↔ VC
    

    どこか一箇所でも非同値なら approve を禁止してください。


    最終結論

    #2186 は、Spark の技術制約については有用な調査を含んでいます。特に以下は維持すべきです。

    • catalog と entitlement を分離する
    • actual inference を要求する
    • silent fallback を禁止する
    • 128K / text-only を通常 [1m] profile と分離する
    • credential、raw request、raw transcript を証跡に残さない
    • Native / normal claude-gpt の回帰を確認する

    ただし、中心となる execution model は破棄して組み直す必要があります。

    推奨 action は、#2186 を close/recreate するのではなく reframe_in_place し、通常 claude-gpt 内の explicit-only Spark SubAgent 実装へ置換することです。 --profile spark は #2186 の closure condition から外し、必要なら独立 follow-up に分離するのが妥当です。

  4. squne121 commented on Aug 17, 2026

    @squne121
    OwnerAuthor
    Issue #2186 の refinement loop は2回試行しましたが、いずれも環境要因でブロックされ、Issue本文には一切手を付けられていません。
    
    状況:
    - リポジトリで複数の並行 claude セッション(少なくとも5プロセス)が同時稼働しており、そのうちどれかが Issue #2231 向けの issue_content.update transaction を実行中でした。
    - preflight の unauthorized_write_path fail-closed ガードが、この並行書き込みや .pytest_cache の自己矛盾的挙動(preflight 自身が起動する pytest の出力を「未認可」と判定)を検知し、3回リトライしても STATUS すら返せませんでした。
    - これはガードが「意図通りに」安全側に倒れている状態であり、リトライを重ねてバイパスすべきものではないため、サブエージェントは正しく environment_failure として停止しています。
    - Issue #2186 の本文・コメントは未変更、リポジトリの追跡ファイルにも変更はありません。
    
    選択肢:
    1. 他の並行セッション(特に Issue #2231 を触っているもの)が落ち着くのを待ってから再試行する
    2. .pytest_cache の self-conflict と artifacts/ 共有ルートの write-path 監査範囲について、恒久対処の Issue を別途起票する(今回のスコープ外)
    
    どう進めますか。しばらく待ってから自動で再試行してもよいですし、今すぐもう一度試すこともできます。
    

    並列作業できないのであれば、それは設計ミスですし、実装ミスです。なぜGitHub Issueの起表示にその実装を許容してしまう作業計画のままにしてしまったのか、また実装時にそれをそのまま実装してしまったのか、検証で防げなかったのか検討してください。

    並列作業を妨げる実装は緊急性の高いバグです。急ぎ、優先的に実装イシューと改善実装を行ってください。

    あるいは、リバートによる実装の取り下げでもいいです。

  5. squne121 commented on Aug 17, 2026

    @squne121
    OwnerAuthor

    推奨は、#2186 を今すぐ同条件で再試行するのではなく、control-plane blocker を先に切り分けたうえで reframe_in_place を再開です。

    指定コメントは #2186 の仕様上の blocker ではなく、unauthorized_write_path が並行 mutation と .pytest_cache を検知して fail-closed したという運用停止記録です。本文 mutation は行われていません。

    特に .pytest_cache/v/cache/nodeids の誤帰属には既存 Issue #1526 があり、そこが依存していた #1502 はすでに completed です。したがって同じ内容の follow-up を新規起票するより、まず #1526 を canonical remediation として再評価すべきです。 一方、#2231 の refinement 自体はその後 approve まで到達していますが、privileged executor には .guard_shadow_log.jsonl の別問題も報告されています。#2186 では human-intent の意味反転そのものが問題なので、privileged preflight が失敗した際に弱い fallback lane で続行するのは避けるべきです。

    仕様面では前回レビューの方向が現在の公式仕様とも整合します。Claude Code は --agents でセッション限定 SubAgent を登録でき、@ mention は指定 SubAgent の実行を保証します。また PreToolUse は Agent tool を対象に deny 可能で、SubAgent lifecycle には agent_id 等の相関情報があります。 ([Claude]1) claude-code-proxy も model ID ごとの request routing を行うため、main session を通常モデルのままにして特定 SubAgent request だけ別モデルへ送る構成と整合します。 ([claude-code-proxy]2) Spark は現在も ChatGPT Pro 向け research preview、128K、text-only、独立 rate limit とされています。 ([OpenAI]3)

    また、#2186 の旧 dependency 記述は stale です。PR #2176、#2220、#2222 は現在すべて merged なので、これらを blocker ではなく current-main baseline として fresh collision review し直すべきです。

    Claude Code には次を渡すのがよいです。

    Issue #2186 の refinement を、安全側に fail-close したまま再開してください。

    対象:

    今回の目的は Issue #2186 の実装ではなく、Issue contract の正常な reframe_in_place と implementation-ready 判定までです。
    repository implementation / PR 作成にはまだ進まないでください。

    最重要の authority

    以下を混同しないこと。

    1. issuecomment-5302663494

      • OWNER の direct human intent。

      • normative authority として最優先する。

      • 要求の中心は以下。

        • 通常の claude-gpt 対話セッションを維持する
        • user が current turn で明示した場合だけ Spark を使用する
        • Spark は main model ではなく SubAgent として使用する
        • main session model を Spark に切り替えない
    2. issuecomment-5315233662

      • 上記 human intent と repository/current upstream implementation を照合した adversarial review。
      • REQUEST_CHANGES / reframe_in_place の入力として使う。
      • 内容は current main / current official docs で再 fact-check し、盲目的に転記しない。
    3. issuecomment-5315476801

      • refinement 実行時の environment failure の記録。
      • normative specification ではない。
      • このコメントを human intent anchor に昇格させない。

    Phase 0 — control-plane safety preflight

    最初に repository / local process / GitHub の current state を fresh に取得する。

    以下を確認すること。

    他セッションを kill したり、他 Issue の artifact を削除したり、guard を無効化したりして通過させてはならない。

    .pytest_cache を directory-wide allowlist に追加してはならない。
    単に cache を削除して一時的に preflight を通すことを恒久解決扱いしてはならない。

    #1526 の扱い

    .pytest_cache/v/cache/nodeids の unauthorized_write_path false positive については、既存 Issue #1526 を必ず確認する。

    #1526 がこの障害と semantic duplicate なら、新規 follow-up Issue を作らない。

    #1526 の旧 dependency #1502 が既に completed している場合、その dependency は現在 blocker ではないことを確認する。

    ただし #1526 の repository implementation をこの #2186 refinement session に混在させないこと。

    canonical privileged preflight が #1526 相当の既知障害によって再現性高く停止するなら、

    privileged lane の必須性

    今回 #2186 は、過去 refinement が direct human intent を
    interactive/current-turn/SubAgent
    から
    pre-start/profile/main-process
    へ意味反転させたこと自体が問題である。

    そのため human anchor classification を弱める fallback は使用しない。

    特に privileged preflight.run.with_human_context 相当が失敗した場合、

    • root から run_refinement_preflight.py を直接実行して mutation へ進む
    • anchor を ambiguous のまま代用する
    • guard の write-path check を迂回する

    ことは禁止する。

    環境が安全に canonical lane を実行できなければ fail-closed で終了する。

    Phase 1 — SubAgent による独立調査

    最低4体の read-only specialist SubAgent を並列で起動する。
    全 SubAgent の完了を必ず待ってから親 Agent が判断すること。
    途中結果だけで Issue mutation を開始しない。

    SubAgent A — human-intent / contract analyst

    調査対象:

    成果物:

    最低限、次を明示すること。

    human_intent:
      interaction_mode: interactive
      trigger: explicit_current_turn
      execution_unit: subagent
      main_session_model_change: false

    SubAgent B — Claude Code / claude-gpt architecture investigator

    current main の実装を読む。

    最低限:

    current official Claude Code documentationも確認する。

    確認事項:

    • session-local custom SubAgent registration の current supported mechanism
    • full model ID 指定可否
    • @agent-... explicit invocation semantics
    • UserPromptSubmit
    • PreToolUse on Agent
    • SubagentStart
    • SubagentStop
    • Stop / StopFailure
    • tool_use_id / agent_id / resolved model 等の現在利用可能な correlation surface

    推測で API / field 名を固定しないこと。

    SubAgent C — Spark / proxy compatibility investigator

    current official OpenAI informationと current claude-code-proxy implementation/docs を調査する。

    最低限:

    • GPT-5.3-Codex-Spark availability / entitlement
    • model ID
    • text-only
    • context ceiling
    • rate-limit/failure semantics
    • request-level model routing
    • reasoning effort
    • reasoning summary
    • previous response continuation
    • server compaction
    • fallback behavior
    • tool compatibility

    catalog に model ID が存在することと、
    当該 ChatGPT Pro account で actual inference が成功することを別物として扱う。

    SubAgent D — adversarial verifier

    A〜Cとは独立に current #2186 と予定 reframe を敵対的に評価する。

    特に以下を攻撃する。

    • explicit-only が description prose だけになっていないか
    • prior-turn authorization が漏れないか
    • quoted mention が authorization にならないか
    • Spark Agent の autonomous invocation が可能になっていないか
    • requested model と effective model を混同していないか
    • parent が marker を自己出力して PASS できないか
    • entitlement/quota failure 後に ordinary model fallback していないか
    • Spark failure が main session を殺さないか
    • continuation / resume で authorization が持ち越されないか
    • AC と Verification Commands が Outcome の性質を本当に証明するか
    • Required Skills / Required Assets が capability closure を満たすか

    全SubAgentの完了を待つこと。

    Phase 2 — current baseline の再計算

    PR #2176 / #2220 / #2222 の current state を fresh readback する。

    merged 済みなら、#2186 body の

    をそのまま残さない。

    current main を baseline として、

    • merged implementation
    • current file ownership
    • current Allowed Paths collision
    • current evidence API
    • current tests

    を再計算する。

    historical head の evidence を current-main evidence として流用しない。

    Phase 3 — #2186 reframe_in_place

    canonical preflight が正常に通り、SubAgent 調査も完了した場合だけ Issue body を in-place rewrite する。

    close/recreate はしない。

    タイトルの方向:

    実装: 通常 claude-gpt 対話中、明示 @ 指示時だけ GPT-5.3-Codex-Spark SubAgent を起動する

    中心 Outcome:

    • 通常 claude-gpt session の main model は現状維持
    • ordinary SubAgent mapping も現状維持
    • Native runtime 不変
    • claude-gpt session にだけ Spark custom SubAgent を登録
    • user が current turn で canonical @agent-spark-codex を明示した場合だけ起動
    • authorization は current turn / exactly-one invocation に限定
    • authorization の次 turn / resume への持越し禁止
    • automatic fallback 禁止
    • Spark delegated task failure は親へ明示的に返す
    • Spark task failure 後も main claude-gpt session は ordinary turn を継続可能
    • actual Spark model 使用を causal evidence で証明

    launch.sh --profile spark は #2186 の Outcome / closure condition から外す。
    独立した機能として必要なら別 scope だが、今回勝手に新 Issue を作成しない。

    explicit-only gate

    agent description の
    「明示時だけ使う」
    だけを enforcement として認めない。

    current Claude Code implementation を確認した上で、可能なら以下の fail-closed model を採用する。

    current UserPromptSubmit
      -> canonical Spark @mention authorization
      -> PreToolUse(Agent)
      -> subagent_type == spark-codex
      -> authorization consume
      -> SubagentStart(agent_id)
      -> exact Spark effective model
      -> SubagentStop(agent_id)
      -> parent receives result
    

    authorization が存在しない Spark Agent call は deny する。

    quoted text、code block、過去 turn、typo、別 agent mention を authorization として扱わない。

    current Claude Code hook semantics でこの deterministic gate が構築できない場合は、
    「description-only explicitness」に格下げせず Stop Condition とする。

    causal runtime verification

    current main の #2220 / #2222 evidence infrastructure を最大限 reuse する。

    少なくとも以下を相関する設計にする。

    requested_model: gpt-5.3-codex-spark
    agent_resolved_model: gpt-5.3-codex-spark
    proxy_observed_model: gpt-5.3-codex-spark
    models_used:
      - gpt-5.3-codex-spark
    fallback_observed: false

    model の自己申告や prompt output の model 名は証拠にしない。

    positive control:

    • ordinary → explicit Spark → ordinary → explicit Spark
    • same main claude-gpt session
    • Spark invocation ごとに fresh/expected child identity
    • actual model exact Spark
    • child completion
    • parent return
    • main session survival

    negative controls:

    • Spark 指示なし
    • previous turn にのみ Spark 指示
    • quoted mention
    • code block 内 mention
    • typo
    • 別 agent
    • unrelated SubAgent
    • parent-only marker
    • requested Spark / effective non-Spark
    • entitlement failure
    • quota failure
    • fallback attempt
    • resume stale authorization
    • duplicate invocation from one authorization

    Required knowledge / skills の修正

    Required Skills: なし をそのまま残さない。

    Issue を作業計画として見た際に必要な capability を明示的に分類する。

    少なくとも以下のように分離することを検討する。

    ## Required Domain Knowledge
    
    - Claude Code custom SubAgent / model resolution / hook lifecycle
    - claude-gpt launcher architecture
    - claude-code-proxy request-level model routing
    - GPT-5.3-Codex-Spark runtime constraints
    
    ## Required Repository Skills
    
    - worktree-agent-runtime-smoke
    - refinement / contract review に実際に必要な canonical repository skills
    
    ## Required Repository Assets
    
    - relevant scripts/claude-gpt assets
    - worktree-agent-runtime-smoke runner/tests
    - runtime verification policy
    - merged #2220 / #2222 evidence implementation
    
    ## Required External References
    
    - current official Claude Code subagent/hooks documentation
    - current official OpenAI Spark information
    - current claude-code-proxy model-routing / Codex documentation

    既存 Issue schema / checker がこの分割を現在許容しない場合は、
    勝手に schema を変更せず、その制約を明示して Stop Condition / follow-up candidate とする。

    Phase 4 — terminal review

    Issue body mutation 後は必ず live GitHub readback を取得する。

    • persisted body の hash
    • reviewer が評価した body hash
    • current live body hash

    を一致させる。

    stale pre-mutation artifact の approve を使わない。

    issue-refinement-loop の canonical terminal review を完了させ、
    その後 issue-contract-review を fresh に実行する。

    目標 terminal state:

    refinement:
      verdict: approve
      blockers: []
    
    contract_review:
      status: go
    
    human_intent_preserved: true
    implementation_started: false

    status: go が得られなければ実装へ進まない。

    禁止事項

    終了報告

    最後に以下だけを簡潔に報告する。

    1. current main SHA
    2. control-plane preflight の結果
    3. active peer mutation の有無
    4. 実装: runtime guard が peer pytest nodeids を child write と誤帰属しないようにする #1526 が blocker だったか
    5. 起動した SubAgent と各 verdict
    6. 全SubAgent完了を待ったこと
    7. 実装: 通常 claude-gpt 対話中、明示 @ 指示時だけ GPT-5.3-Codex-Spark SubAgent を起動する #2186 body mutation の有無
    8. reframe 後の human-intent dimensions
    9. refinement iteration 数
    10. final refinement verdict
    11. issue-contract-review status
    12. remaining blockers
    13. implementation-ready か否か

    環境 blocker が残る場合は無理に進めず、何が canonical lane を止めているかを再現可能な証拠付きで報告して終了すること。

    このプロンプトのポイントは、前回と同じ retry を命じず、#1526 を重複起票せずに既存 blocker として認識させることと、#2186 では human-intent classification を弱める fallback を明示的に禁止することです。成功した場合も今回は Issue contract の go までで止め、実装は別の impl-review-loop セッションに分離する方が境界が明確です。

  6. changed the title [-]実装: claude-gpt から GPT-5.3-Codex-Spark を明示 opt-in で選択利用できるようにする[/-] [+]実装: 通常 claude-gpt 対話中、明示 @ 指示時だけ GPT-5.3-Codex-Spark SubAgent を起動する[/+] on Aug 17, 2026
  7. squne121 commented on Aug 17, 2026

    @squne121
    OwnerAuthor

    Issue Refinement Loop 終了報告

    Iteration: 1(Step 2 review needs-fix → Step 4 rewrite → Step 2 final review approve)

    旧 body の needs-fix blockers(10件):

    • Runtime Verification Applicability の applicable_acs/execution_environment/skip_conditions/fallback_policy/artifact_requirements が markdown bullet prefix (- ) 付きで書かれており checker の ^\s*field\s*: 正規表現に一致しなかった(5件)
    • Verification Commands が scripts/claude-gpt/launch.sh --check-only / scripts/claude-gpt/runtime_smoke_test.sh --profile spark を直接呼んでおり VC preflight allowlist(rg/test/grep/uv run pytest/pnpm typecheck|lint|test|build 等のみ許可)に違反していた(4件)
    • Regression gate command failed(上記に連動、1件)

    reframe_in_place の内容:

    最終状態: VERDICT: approve、BLOCKERS: 0、REVIEWED_BODY_SHA256: sha256:72109e55bf02dba1837aa700959a08cf4daaf451ad133c08611fe1c28ae2f18f。

    Final Gate: issue_kind: implementation のため、本 Issue は通常の impl-review-loop handoff 対象である。ただし本セッションのスコープは reframe と implementation-ready 判定までであり、handoff の実行(impl-review-loop 起動・実装着手・PR作成)は行わない。

    schema: LOOP_HANDOFF_RESULT_V1
    issue_number: 2186
    repo: squne121/loop-protocol
    final_verdict: approve
    reviewed_body_sha256: "sha256:72109e55bf02dba1837aa700959a08cf4daaf451ad133c08611fe1c28ae2f18f"
    handoff_target: impl-review-loop
    handoff_executed: false
    note: "control-plane session scope ends at implementation-ready determination; PR/implementation not started in this session"
  8. squne121 commented on Aug 17, 2026

    @squne121
    OwnerAuthor

    推奨は、追加 refinement には戻らず、#2186 を専用 Claude Code セッションへ渡して impl-review-loop を開始することです。#2176・#2220・#2222 は現在すべて merged で、#2186 の現行 contract もこれらを再実装せず baseline として reuse する前提になっています。

    実装順序は risk-first が適切です。現在の Claude Code 公式仕様では、@agent-<name> は対象 SubAgent の実行を保証し、--agents は current session 限定なのに対し .claude/agents/ は project scope です。また hooks には prompt_id があり、PreToolUse(Agent) では subagent_type / model / tool_use_id、完了側では resolvedModel を観測できます。したがって、Native Claude に Spark 定義を露出させる project-level agent より、claude-gpt launcher が --agents で session-local Spark agent を注入し、UserPromptSubmit(session_id,prompt_id) → PreToolUse(Agent) で gate する構成を第一候補にすべきです。なお SubagentStart 自体は生成を block できないので、authorization enforcement は必ず PreToolUse より前/そこで完結させる必要があります。 ([Claude]1)

    特に先に実証すべきなのは model routing です。Claude Code は availableModels 等で指定モデルが許可されない場合、条件によって inherited model へ解決する仕様があるため、Spark を要求したのに ordinary model が動く silent fallback を絶対に PASS にしてはいけません。requested model → resolvedModel → proxy observed model の三点一致を live canary で最初に確認するのが重要です。OpenAI 側でも Spark は research preview、text-only、128K context、独立 rate limit とされています。 ([Claude]1)

    以下をそのまま Claude Code に渡せます。

    Claude Code 作業プロンプト — Issue #2186 impl-review-loop

    squne121/loop-protocol の Issue #2186 を実装してください。

    対象:

    Issue #2186 の current live body を SSOT とし、過去の launch.sh --profile spark 前提の旧設計へ戻さないでください。

    最終目標

    通常の claude-gpt 対話セッションについて、

    • main session model は変更しない
    • ordinary SubAgent mapping も変更しない
    • Native Claude runtime に影響させない
    • user が current turn で canonical @agent-spark-codex を明示した場合だけ
      gpt-5.3-codex-spark SubAgent を exactly once 起動する
    • authorization を次 turn / resume / duplicate invocation に持ち越さない
    • main / 他 SubAgent による自律的な Spark 起動を拒否する
    • Spark failure 後も同じ main session が ordinary turn を継続できる
    • ordinary model への automatic fallback を禁止する
    • 実際に Spark が使用されたことを causal evidence で証明する

    状態へ持っていってください。

    実行モード

    impl-review-loop を使用してください。

    Stop Conditions に該当しない限り、人間への途中承認を求めず、

    1. preflight / scope確認
    2. SubAgent 調査
    3. implementation
    4. deterministic tests
    5. live runtime verification
    6. Draft PR 作成または既存 PR 継続
    7. adversarial review
    8. REQUEST_CHANGES があれば fix_delta
    9. 再検証・再レビュー

    を反復し、merge-ready / reviewer APPROVE / blockers 0 のマージ直前まで進めてください。

    main への merge は実行しないでください。

    既存 PR / branch / worktree が #2186 用に存在する場合は重複作成せず再利用してください。

    必須: SubAgent を並列利用する

    実装を始める前に、最低4体の read-only 調査 SubAgent を並列起動してください。

    SubAgent A — contract / scope analyst

    調査対象:

    成果:

    • implementation contract
    • must / must-not
    • Allowed Paths
    • Stop Conditions
    • stale assumptions
    • related merged baseline

    を簡潔に整理する。

    SubAgent B — Claude Code runtime specialist

    最新の公式 Claude Code documentation とローカル installed Claude Code の挙動を確認する。

    特に確認:

    • --agents の current-session scope
    • .claude/agents/ の project scope
    • canonical @agent-<name> explicit invocation
    • UserPromptSubmit の session_id / prompt_id / prompt
    • PreToolUse(Agent) の tool_use_id, tool_input.subagent_type, tool_input.model
    • PreToolUse の deny / updatedInput semantics
    • SubagentStart / SubagentStop
    • PostToolUse(Agent).tool_response.resolvedModel
    • CLAUDE_CODE_SUBAGENT_MODEL
    • model resolution precedence
    • availableModels による substitution / fallback
    • installed Claude Code version が必要な hook fields/version gates を満たすか

    可能な限り一次資料を使用すること。

    SubAgent C — claude-gpt / proxy routing specialist

    current main の以下を調査:

    特に、

    gpt-5.3-codex-spark を特定 SubAgent の request だけに指定したとき、

    • parent claude-gpt main model が不変
    • ordinary SubAgent mapping が不変
    • Spark child request だけが Spark へ route
    • silent inherited-model fallback が発生しない

    ことを証明するための 最小 live canary を設計する。

    SubAgent D — adversarial evidence / test designer

    AC1-AC9 を敵対的に検討し、最低でも以下の negative controls を設計する:

    • Spark mention なし
    • previous turn にだけ mention
    • quoted mention
    • fenced code block 内 mention
    • typo
    • 別 agent mention
    • duplicate invocation
    • authorization replay
    • resume 後 stale authorization
    • main による autonomous Spark invocation
    • nested SubAgent → Spark delegation
    • requested_model=Spark / resolvedModel!=Spark
    • resolvedModel=Spark / proxy_observed_model!=Spark
    • parent が Spark marker を自己出力しただけ
    • unrelated child が完了しただけ
    • entitlement/catalog/quota/tool/context failure
    • failure 後 ordinary turn 継続
    • stale evidence / wrong head

    SubAgent completion barrier

    4体すべてが terminal state になるまで待ってください。

    一部の SubAgent の結果だけで実装を開始してはいけません。

    SubAgent が異常終了した場合は、必要なら一度 replacement を起動し、その完了も待ってください。取得できなかった調査結果を「問題なし」と推定して先へ進めないでください。

    全員の結果を親 session で統合してから実装方針を確定してください。

    risk-first feasibility gate

    大規模な実装を始める前に、次の2点を実証してください。

    Gate 1 — session-local registration

    第一候補は launcher-owned --agents registration としてください。

    Claude Code 公式仕様上、--agents は current session scope です。一方 .claude/agents/ は project scope です。

    したがって、

    • claude-gpt session だけ Spark agent を持つ
    • Native Claude session には Spark agent を追加しない

    という #2186 の contract を満たすため、原則として launcher から --agents で spark-codex を注入してください。

    .claude/agents/spark-codex.md は Allowed Path であっても、project-level discovery により Native runtime に Spark agent を露出させるなら使用しないでください。

    Allowed Path は「変更必須」を意味しません。

    Gate 2 — exact Spark model resolution

    最小 live canary で、

    • requested model
    • Claude Code resolved model
    • proxy observed model

    の三点がすべて exact:

    gpt-5.3-codex-spark

    になることを確認してください。

    Claude Code が unsupported / blocked model を inherited main model 等へ substitute する場合、その実行を PASS にしてはいけません。

    post-hoc に「fallback だった」と記録するだけで AC を満たしたことにもしないでください。

    exact Spark routing を安全に成立させられない場合は、Issue の Stop Conditions に従って停止し、再現可能な証拠を報告してください。contract を弱めて先へ進めてはいけません。

    authorization gate

    実装は fail-closed としてください。

    基本 correlation key は current Claude Code が提供する:

    • session_id
    • prompt_id

    を利用してください。

    独自 turn identity を発明する前に live hook payload を確認してください。

    想定フロー:

    UserPromptSubmit
    → current prompt に canonical Spark invocation が存在することを確認
    → (session_id, prompt_id) keyed single-use authorization 作成
    → PreToolUse(Agent)
    → tool_input.subagent_type == spark-codex を確認
    → 同一 (session_id, prompt_id) authorization を確認
    → nested subagent origin でないことを確認
    → authorization を atomic consume
    → allow
    → SubagentStart
    → SubagentStop / PostToolUse(Agent)
    → causal evidence 検証

    authorization の保存物に raw prompt、credential、token、raw auth を残さないでください。

    必要なのは最小限の digest / nonce / identifiers / boolean state のみです。

    重要

    SubagentStart は監査・相関に使ってよいですが、authorization enforcement を SubagentStart まで遅らせてはいけません。

    Spark creation の deny は PreToolUse(Agent) で完了させてください。

    canonical @ mention の検証

    UserPromptSubmit.prompt の単純 substring match だけで実装を完成扱いしないでください。

    実機で少なくとも:

    1. picker または canonical @agent-spark-codex
    2. quoted text
    3. fenced code block
    4. previous turn mention
    5. typo
    6. unrelated agent

    を比較し、Claude Code 自身の actual mention resolution / Agent invocation と deterministic に相関できるか確認してください。

    もし current hook/API surface だけでは「実 invocation mention」と「文字列として記述された mention」を pre-execution に区別できず、AC2 の quoted/code negative control を fail-closed に保証できないなら、曖昧な parser を実装して APPROVE に持っていかず、fixed contract を満たせない Stop Condition として終了してください。

    model override / fallback safety

    以下を明示的に確認してください。

    • CLAUDE_CODE_SUBAGENT_MODEL が Spark agent frontmatter/model selection を横取りしない
    • Agent per-invocation model が Spark 以外へ override されない
    • 必要なら PreToolUse(Agent).updatedInput を使って exact model を固定することの妥当性を検討する
    • availableModels 等による inherited-model substitution を検出する
    • requested / resolved / proxy-observed の不一致は fail-closed
    • quota / entitlement / catalog unavailable は fallback せず exit 77 / blocked
    • ordinary model fallback を成功扱いしない

    merged baseline の reuse

    以下は current main の merged baseline として reuseし、再設計しないでください。

    特に既存の:

    • subagent_causal_evidence_verdict()
    • extract_claude_hook_lifecycle_events()
    • hook ID / tool_use_id / agent_id correlation
    • agent transcript verification
    • child-only marker provenance
    • multi-turn / multi-child lifecycle
    • stale evidence protection
    • independent cleanup verification

    を可能な限りそのまま利用してください。

    #1526 の扱い

    Issue #1526 の .pytest_cache/v/cache/nodeids unauthorized-write attribution 問題は #2186 の Out of Scope です。

    もし impl-review-loop / runtime guard がこの既知問題に遭遇しても、

    でください。

    #2186 の実装と独立した control-plane blocker であれば、証拠を残して Stop Condition として報告してください。

    tests / runtime verification

    Issue #2186 current body に記載された Verification Commands を canonical command として実行してください。

    少なくとも:

    • AC1 operator journey
    • AC2 mention authorization
    • AC3 single-use authorization
    • AC4 causal evidence
    • AC5 nested delegation forbidden
    • AC6 failure isolation
    • AC7 no-fallback / skip-blocked
    • AC8 claude-gpt hermetic matrix
    • AC9 baseline regression

    を満たしてください。

    さらに Runtime Verification Applicability が immediate なので、pytest のみで closure してはいけません。

    worktree-agent-runtime-smoke を利用して live claude-gpt session を検証してください。

    最終 live sequence:

    1. ordinary turn
    2. explicit Spark turn
    3. ordinary turn — Spark が起動していないこと
    4. explicit Spark turn — fresh child identity

    を同一 main session で確認すること。

    証拠は sanitized structured evidence とし、credential / token / raw auth / raw request-response / raw transcript を GitHub に投稿しないでください。

    external network

    必要な範囲で外部ネットワーク利用を許可します。

    使用してよい対象:

    • GitHub live state
    • Claude Code 公式 documentation
    • OpenAI 公式 Spark documentation
    • claude-code-proxy upstream documentation / source
    • entitlement/catalog の安全な runtime probe
    • package/version metadata

    ただし:

    • credential/token を表示・保存・投稿しない
    • auth方式を勝手に変更しない
    • deliberate quota exhaustion を行わない
    • raw request/response を evidence として公開しない

    review loop

    implementation 完了後は必ず独立 reviewer SubAgent を使用してください。

    reviewer には Issue #2186 current body、OWNER intent、PR diff、tests、live evidence を渡し、敵対的に:

    • intent inversion
    • Native/runtime leakage
    • stale authorization
    • replay
    • nested delegation
    • silent fallback
    • weak model evidence
    • quoted/code false positive
    • failure isolation
    • stale-head evidence
    • secret leakage
    • Allowed Paths deviation

    を検査させてください。

    REQUEST_CHANGES の場合は blocker ごとに fix_delta を実装し、該当 tests/live verification を再実行して reviewer を再起動してください。

    reviewer が APPROVE / blockers: [] になるまで反復してください。

    Stop Conditions

    Issue #2186 current body の Stop Conditions を厳守してください。

    特に以下では勝手に contract を変更せず停止してください。

    • Allowed Paths 外の変更が必要
    • fixed In Scope contract の変更が必要
    • 新規 Issue が必要
    • 別 Phase へ波及
    • Native / ordinary claude-gpt mapping に影響
    • no-fallback を維持できない
    • exact Spark routing を証明できない
    • quoted/code negative controls を deterministic に保証できない
    • sanitized evidence safety を保証できない
    • runtime VC が exit 77 / SKIP
    • fallback 経由でしか成功しない

    最終報告

    終了時に以下を報告してください。

    • Issue 実装: 通常 claude-gpt 対話中、明示 @ 指示時だけ GPT-5.3-Codex-Spark SubAgent を起動する #2186
    • PR URL / number
    • final head SHA
    • starting main SHA / current main SHA
    • changed files
    • impl-review-loop iteration 数
    • SubAgent 一覧と各調査結果
    • requested_model
    • agent_resolved_model
    • proxy_observed_model
    • current-turn authorization evidence
    • duplicate / stale / nested negative controls
    • 4-turn live sequence 結果
    • failure isolation 結果
    • no-fallback 証明
    • test results
    • CI status
    • reviewer final verdict
    • unresolved review threads
    • mergeability
    • blockers
    • Stop Condition の有無

    merge は実行せず、merge-ready で停止してください。

    この形なら、refinement で最も重要になった 「explicit current turn / SubAgent / main model unchanged」 を実装中に再び反転させる可能性をかなり抑えられます。特に --agents の session scope と prompt_id / resolvedModel が現行 Claude Code に存在することは、今回の reframe を実装へ落とす上で有利な更新です。 (Claude)

  9. self-assigned this
    on Aug 18, 2026
  10. added 2 commits that reference this issue on Aug 18, 2026
  11. added 2 commits that reference this issue on Aug 24, 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/implementationtriage-required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions