Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
Parent Issue
なし(単独改善)
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "人間が自然言語で明示的にGPT-5.3-Codex-Spark SubAgentの使用を要求した場合に、genericへsilent downgradeせず構造化directiveで起動可能にする"
change_kind: codeParent Goal Ref
- Goal: 人間が自然言語で明示的にGPT-5.3-Codex-Spark SubAgentの使用を要求した場合に、genericへsilent downgradeせず構造化directiveで起動可能にする
- Desired Destination: なし(単独改善、parent issue なし)
Current Validated Scope
- scripts/claude-gpt/launch.sh の UserPromptSubmit / PreToolUse(Agent) hook に構造化 delegation directive(DELEGATION_REQUEST_V1)のパース・authorization発行ロジックを追加
- scripts/claude-gpt/lib.sh の関連 helper 拡張
- 対応するユニット/統合テストの追加・更新
Remaining Parent Gaps
なし(単独改善のため parent tracker なし)
Outcome
scripts/claude-gpt/launch.sh の UserPromptSubmit hookが、既存の @agent-spark-codex canonical mention検出に加えて、mode: required|preferred を含む構造化delegation directiveを解釈できるようになり、mode: required で明示要求されたSpark起動が失敗する場合はgenericへsilent fallbackせず構造化failureとして停止する状態にする。既存 @agent-spark-codex の挙動は完全に後方互換で維持される。成果物は scripts/claude-gpt/launch.sh / scripts/claude-gpt/lib.sh の更新、対応するテストの追加、および全 Acceptance Criteria が Verification Commands で PASS することをもって完了とする。
Runtime Verification Applicability
- decision: immediate
- reason: 実 Claude-GPT + 実 proxy + 実 GPT-5.3-Codex-Spark を使った起動検証が必要(unit testのみで完了扱いにしない)
In Scope
scripts/claude-gpt/launch.shのUserPromptSubmit/PreToolUse(Agent)hookに、構造化directive(YAML/JSON形式、schema: DELEGATION_REQUEST_V1、agent_id: spark-codex、model: gpt-5.3-codex-spark、mode: required|preferred、fallback: forbidden|allowed、wait: true、authorization_source: explicit_directive)のパース・authorization発行ロジックを追加するmode: requiredかつ Spark起動不可(launch失敗、quota、availability等)の場合、genericへのsilent downgradeを禁止し、構造化failureとしてAgent呼び出し自体を停止する仕組みを追加するmode: preferredの場合のfallback許可ロジックを追加する- exactly-once consume(既存のnonce single-use consume機構を再利用)
- malformed directive・quoted/fenced/inline-code/blockquote内言及・typo/case・stale/resumeを全てnegativeとして扱うロジックとテスト
- 対応するユニット/統合テスト
Out of Scope
- Codex CLIネイティブの
.codex/agents/spark-*.toml経路の変更 - native(非claude-gpt)Claude Codeセッションへのgate拡張
- 既存canonical
@agent-spark-codexmentionの意味論変更 - model routing自体の変更
- merge実行
Acceptance Criteria
- AC1: 構造化directive(
schema: DELEGATION_REQUEST_V1,mode: required)が正しくパースされ、Spark起動authorizationが発行される(exact-positive)。 - AC2:
mode: preferredの場合、Spark起動不可でもgenericへのfallbackが許可され、fallback発生がログ/結果に明示される。 - AC3:
mode: requiredでSpark起動不可の場合、genericへのsilent fallbackが発生せず、構造化failure(terminal stop)としてAgent呼び出しが停止する。 - AC4: quoted文字列・fenced code block・inline code・blockquote内に directive相当の文字列が出現しても authorization が発行されない(negative)。
- AC5: typo/case違い(例:
Required,requiredd)を含むdirectiveはmalformedとして拒否され、silent downgradeでもauthorization発行でもない明示的なエラーになる。 - AC6: stale/resume(別turn/別sessionのauthorization record)を現在turnのauthorizationとして再利用できない。
- AC7: exactly-once consume: 同一directiveから複数回Agent起動を試みても、2回目以降は新規authorizationなしには許可されない。
- AC8: 既存
@agent-spark-codexcanonical mention の既存挙動(PR #2244のAC)が全て回帰なく通過する。 - AC9: terminal task invariant:
mode: requiredのSpark起動が完了する(成功またはterminal failure)までwaitし、途中で親タスクが誤って完了扱いにならない。
Verification Commands
# AC1
$ uv run --locked pytest scripts/claude-gpt/tests/test_delegation_directive.py -k required_authorization -v# AC2
$ uv run --locked pytest scripts/claude-gpt/tests/test_delegation_directive.py -k preferred_fallback -v# AC3
$ uv run --locked pytest scripts/claude-gpt/tests/test_delegation_directive.py -k required_terminal_failure -v# AC4
$ uv run --locked pytest scripts/claude-gpt/tests/test_delegation_directive.py -k non_authorizing_context -v# AC5
$ uv run --locked pytest scripts/claude-gpt/tests/test_delegation_directive.py -k malformed_directive -v# AC6
$ uv run --locked pytest scripts/claude-gpt/tests/test_delegation_directive.py -k stale_authorization_rejected -v# AC7
$ uv run --locked pytest scripts/claude-gpt/tests/test_delegation_directive.py -k exactly_once_consume -v# AC8
$ uv run --locked pytest scripts/claude-gpt/tests/ -v# AC9
$ uv run --locked pytest scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py -vAllowed Paths
- scripts/claude-gpt/launch.sh
- scripts/claude-gpt/lib.sh
- scripts/claude-gpt/tests/
- scripts/agent-ops/run_worktree_agent_runtime_smoke.py
- scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py
- docs/dev/workflow.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- Codex CLIネイティブ経路(
.codex/agents/spark-*.toml)への拡張が必要と判明した場合 - native session拡張が必要と判明した場合
- 既存canonical mention挙動の後方互換が壊れる場合
Required Skills
なし
Required Design References
- docs/dev/workflow.md
Scope Delta(任意)
N/A
Background
人間が明示的に「GPT-5.3-Codex-Spark モデルのSubAgentを使って」と要求しても、現状 Spark を試行せず generic Agent へ silent downgrade される問題がある。
現行実装(Issue #2186 / PR #2244、MERGED):
spark-codexSubAgent定義とtrigger認識機構はscripts/claude-gpt/launch.sh経由で起動したisolated claude-gpt session専用のephemeral hook chain(UserPromptSubmit→PreToolUse(Agent matcher)→SubagentStart/SubagentStop)としてのみ存在する。- native(通常)Claude Codeセッションの
.claude/settings.jsonにはAgent matcher/UserPromptSubmit hookが一切登録されておらず、.claude/agents/配下12ファイルにもspark-codex.mdは存在しない。したがってnative sessionでは「Spark使って」という自然言語要求を認識する層自体が存在しない。 - claude-gpt session内であっても、認識できるのは
MENTION_RE(scripts/claude-gpt/launch.sh:310、正規表現(?<![\w-])@agent-spark-codex(?![\w-]))にexact matchするcanonical mentionのみ。strip_non_authorizing()(317-327行)がfenced/inline-code/quote/blockquoteを除去してから照合するため、単純substringマッチではないが、逆に「Sparkを使って」「GPT-5.3-Codex-Sparkで調べて」等の自然言語directiveは一切authorizeされず、silent generic downgradeが発生する。 - モデルID
gpt-5.3-codex-spark自体は正確であり単一箇所定義(scripts/claude-gpt/lib.sh:583のCLAUDE_GPT_SPARK_MODEL)。問題はmodel IDの誤りではなくinvocation contract(誰が・どうトリガーするか)の側にある。 - 重要:
.codex/agents/spark-worker.toml(およびspark-deep.toml,spark-skim.toml)という、Codex CLIネイティブの並行Spark起動経路が別途存在する(model = "gpt-5.3-codex-spark"、developer_instructions内に"manual invocation only"と明記)。これは@agent-spark-codexmention gate やLAUNCH_NONCE機構とは完全に別の認可経路であり、本Issueのスコープでは対象としない(Out of Scopeに明記)。混同して両経路を同一directiveスキーマで扱おうとすると設計が破綻するため、本Issueは@agent-spark-codex(claude-gpt launcher hook chain経由)に限定する。 DELEGATION_REQUEST_V1のような構造化directiveスキーマはリポジトリに存在しない(grep 0件)。
絶対に避けるべき修正方向
gpt-5.3-codex-sparkという文字列が自然言語中に単に出現しただけで authorization する緩いsubstring gate- quoted/fenced/inline-code/blockquote内の言及を誤って authorization すること
- 既存canonical
@agent-spark-codexの後方互換を壊すこと - Codex CLIネイティブの
.codex/agents/spark-*.toml経路と混同して同一スキーマで扱おうとすること(scope外)
Refs
- 実装: 通常 claude-gpt 対話中、明示 @ 指示時だけ GPT-5.3-Codex-Spark SubAgent を起動する #2186
- PR 実装: claude-gpt session内でexplicit @agent-spark-codex明示時だけGPT-5.3-Codex-Spark SubAgentを起動する #2244
Notes for Reviewer
Codex CLIネイティブの .codex/agents/spark-worker.toml 等の並行Spark起動経路が存在することをNon-goalsとして明記済み。混同しないこと。
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
squne121 commentedon Aug 19, 2026
Scope Collision (C1) advisory: related_issue=#2257, #2251, #2231, #2192, #2153, #1009, #1007, #420, #237, #225, #213, #205, #202; overlapping_paths=docs/dev/workflow.md, scripts/agent-ops/run_worktree_agent_runtime_smoke.py, scripts/agent-ops/tests/test_run_worktree_agent_runtime_smoke_spark_explicit_gate.py, scripts/claude-gpt/launch.sh, scripts/claude-gpt/lib.sh, scripts/claude-gpt/tests。non_conflict_reason: 重複は docs/dev/workflow.md(共有広域ドキュメント、追記のみ想定)と scripts/agent-ops/run_worktree_agent_runtime_smoke.py(#2231/#2153、テスト検証ハーネス共有、本 Issue は新規テストファイル追加のみで既存テストの意味論を変更しない)、scripts/claude-gpt/launch.sh・lib.sh(#2251、same-UID toolchain root/CWE-427 security concern であり本 Issue の delegation directive スコープとは独立した懸念)。同一ファイルへの並行編集は merge 時に個別解消する。
fix: PR #2263 レビュー指摘 fix_delta を DELEGATION_REQUEST_V1 gate に適用する (#2258