Repository navigation
Closed
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: 293
goal_ref: "claude/AI 運用の usage コスト削減(#295 軽量化後の runtime 計測検証)"
change_kind: workflow
closure_mode: pr-mergedParent Issue
Depends On
Parent Goal Ref
- Goal: perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 で導入された
issue-refinement-loop軽量化(max_iterations=1 デフォルト / investigation_policy / web_research_policy / NEEDS_SECOND_PASS)が、実際の/usageホットスポット削減につながっているかを runtime 観測で検証する - Desired Destination: 3 代表 Issue(small / medium / large)で
issue-refinement-loopを実走した before/after 計測が記録され、/usagesnapshot・agent_spawn_count・iteration_count・各 step の skip_reason が比較可能な形で残っている
Preconditions
- perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 / PR perf(#295): issue-refinement-loop の SubAgent spawn 上限を軽量化 — max_iterations=1 + policy state 化 #388 merged:
.claude/skills/issue-refinement-loop/SKILL.mdに max_iterations=1 / investigation_policy / web_research_policy / NEEDS_SECOND_PASS が反映済み。本 Issue は merge 後にのみ着手可能(Depends on #295)。 - before baseline は origin/main の perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 merge 直前 commit(SKILL.md 1226 行・max_iterations=3 prose)を参照する。
In Scope
- 3 代表 Issue を選定(small = docs-only 軽微修正、medium = workflow 中規模、large = same-file 衝突 / external claim ありの高負荷)
- 各 Issue に対し以下を 2 回実走:
- before:
git checkout <pre-#295-merge-commit>で SKILL.md を baseline に戻してissue-refinement-loopを実走 - after: 現行 main(perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 merged)で
issue-refinement-loopを実走
- before:
- 各 run で記録するメトリクス:
/usagesnapshot(tokens / cost)agent_spawn_count(SubAgent 起動回数)iteration_count(実イテレーション数)- 各 step(Step 1 / Step 1b)の
skip_reason - 総 wall-clock time
- 計測結果を新規 docs(
docs/dev/measurements/issue-refinement-loop-295-cost-reduction.md)に before/after 比較表として保存 - 本 Issue は SKILL.md を変更しない(計測のみ)
Out of Scope
SKILL.mdの改修(Stop Condition: SKILL.md に手を入れる必要が出たら別 Issue)- 他の skill / SubAgent の cost 計測(perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293 の別 follow-up)
- runtime 計測ツールの新規実装(既存
/usage/ 手動 SubAgent カウントを使用) - ゲーム本体への変更
Outcome
docs/dev/measurements/issue-refinement-loop-295-cost-reduction.mdが存在する- 同ドキュメントに 3 代表 Issue × before/after の比較表(
/usagetokens、agent_spawn_count、iteration_count、各 step skip_reason、wall-clock time)が記録されている - cost reduction の方向性(増加 / 維持 / 削減)が明示的に結論されている
- 結論が「削減」でない場合、原因仮説と次の改善 Issue 候補が記録されている
Acceptance Criteria
- AC1:
docs/dev/measurements/issue-refinement-loop-295-cost-reduction.mdが存在する - AC2: 同ドキュメントに
## Before/After Summaryセクションがあり、3 代表 Issue × before/after の比較表が含まれる(各セルに数値 orN/Aが入っている) - AC3: 同ドキュメントに各 run の
agent_spawn_count/iteration_count/skip_reason列が含まれる - AC4: 同ドキュメントに
## Conclusionセクションがあり、cost reduction の方向性(削減 / 維持 / 増加)が明示されている - AC5:
pnpm typecheck && pnpm lint && pnpm test && pnpm buildが PASS する(docs-only 変更だが既定品質ゲートは通す)
Verification Commands
# AC1: 計測ドキュメントが存在
$ test -f docs/dev/measurements/issue-refinement-loop-295-cost-reduction.md && echo PASS || echo FAIL # AC1
# AC2: Before/After Summary セクション
$ rg -n "^## Before/After Summary" docs/dev/measurements/issue-refinement-loop-295-cost-reduction.md # AC2
# AC2: 3 代表 Issue 番号が記載
$ rg -c "small|medium|large" docs/dev/measurements/issue-refinement-loop-295-cost-reduction.md # AC2
# AC3: メトリクス列の存在
$ rg -n "agent_spawn_count|iteration_count|skip_reason" docs/dev/measurements/issue-refinement-loop-295-cost-reduction.md # AC3
# AC4: Conclusion セクション
$ rg -n "^## Conclusion" docs/dev/measurements/issue-refinement-loop-295-cost-reduction.md # AC4
# AC5: 既定品質ゲート
$ pnpm typecheck && pnpm lint && pnpm test && pnpm build # AC5Allowed Paths
docs/dev/measurements/(新規ディレクトリ + ファイル作成可)
Stop Conditions
.claude/skills/issue-refinement-loop/SKILL.mdに手を入れる必要が出た場合 → 別 Issue- 既存 LOOP_STATE フィールドの schema 変更が必要になった場合 → 別 Issue
- 計測対象 Issue を実走中に環境問題(gh API 不可・gemini auth 不可等)で 3 件揃わない場合 → 取得可能件数で停止し、残件は本 Issue に追記で人間判断
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格が必要になった場合
pnpm既定ゲートが FAIL する場合
Runtime Verification Applicability
decision: not_applicable
reason: AI 運用観測(cost measurement)のみ。ゲーム runtime に影響しない。
Required Skills
issue-refinement-loopを 3 代表 Issue に対して before/after で実走できる権限/usagesnapshot を session-local に保存できる仕組み
Delivery Rule
1 Issue = 1 PR- Draft PR 既定
- rebase 要件: perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295 の merge commit を base に rebase
Related
- Parent: perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293
- Depends on: perf(claude): issue-refinement-loop を軽量化する(max_iterations=1 デフォルト / SubAgent 条件付き) #295(軽量化施策の本体)
- Source PR review: perf(#295): issue-refinement-loop の SubAgent spawn 上限を軽量化 — max_iterations=1 + policy state 化 #388 (review)
Source
- parent_issue: perf(claude): AI 運用コスト削減施策 — refinement-loop 軽量化 / Haiku 化 / output budget / SKILL.md 分割 #293
- dedupe_key:
follow-up:loop-protocol:pr-388:ac6-runtime-measurement - spawned_from: PR perf(#295): issue-refinement-loop の SubAgent spawn 上限を軽量化 — max_iterations=1 + policy state 化 #388 review (REQUEST_CHANGES → Option A 採用)
Metadata
Metadata
Assignees
Labels
No labels
Activity
squne121 commentedon May 25, 2026
人間からのコメントです。
計測方法が記載されていないため、適切な効果が測定できるのか不明です。そのため、このGitHub Issueはクローズにしたいと思います。
squne121 commentedon May 25, 2026
結論
#389 は現状のままならクローズで妥当です。
人間コメントの「計測方法が記載されていないため、適切な効果が測定できるのか不明」は、敵対的に見ても正当な blocker です。
理由は、#389 が「何を測るか」は列挙している一方で、「どう測るか」「何を同一条件として固定するか」「
/usageの session-global な値から対象 run の差分をどう切り出すか」を定義していないためです。#389 は 3 代表 Issue、before/after、/usagesnapshot、agent_spawn_count、iteration_count、skip_reason、wall-clock time を要求していますが、測定プロトコルそのものは未定義です。敵対的レビュー
#389 の一番の問題は、「計測ドキュメントを作る Issue」なのに、計測方法の正本がないことです。
特に危険なのは以下です。
/usagesnapshot の差分算出方法がないClaude Code 公式 docs では、
/usageは current session の token 使用統計を出すもので、ドル額は token count からローカル計算された推定値であり、実請求とは異なり得るとされています。つまり、単に before/after の/usage画面を貼るだけでは、対象 run だけの効果とは言えません。([Claude API Docs]1)session 境界が定義されていない
PR perf(#295): issue-refinement-loop の SubAgent spawn 上限を軽量化 — max_iterations=1 + policy state 化 #388 の時点でも、runtime
/usageは session-global で PR-local artifact として再現可能性に乏しいため、3 代表 Issue の選定基準・再現可能性が独立 contract を要すると明記されています。perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 はその follow-up ですが、独立 contract と呼べるほどの測定設計にはなっていません。before/after の比較条件が固定されていない
model、effort、Claude Code version、作業ディレクトリ、session reset、cache/compaction、同一プロンプト、同一 Issue snapshot、GitHub/API 状態、SubAgent 起動ログの取得方法が未定義です。Claude Code docs も、挙動や cost reporting は変更され得るため version 確認が必要としています。([Claude API Docs]1)
manual count と自動計測の境界が曖昧
perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 は runtime 計測ツールの新規実装を Out of Scope にし、既存
/usageと手動 SubAgent カウントを使うとしています。しかし、手動カウントではagent_spawn_count、Step 1/1b skip_reason、iteration_count の漏れ・解釈差を防げません。perf(claude): issue-refinement-loop を script-first / thin entrypoint 化し OPEN 改善 Issue を段階統合する #391/実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392/実装: issue-refinement-loop SKILL.md を thin entrypoint + references 構成へ分割する #393 と順序が悪い
perf(claude): issue-refinement-loop を script-first / thin entrypoint 化し OPEN 改善 Issue を段階統合する #391 は perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 を measurement follow-up として参照しつつ、issue-refinement-loop を script-first / thin entrypoint / SubAgent-owned contract へ段階移行する親 Issue です。実装: issue-refinement-loop の deterministic planner/checker script を抽出する #392 では policy 判定を deterministic planner/checker script + JSON evidence に移す計画があります。これがない状態で perf(claude): #295 軽量化後の runtime /usage 計測(3 代表 Issue) #389 を実走すると、「LLM の prose 判定揺れ」を含んだ noisy な測定になります。
WEB 調査込みの判断
Claude Code の公式 docs 上、より信頼できる計測には
/usage画面より OpenTelemetry が適しています。Claude Code はclaude_code.cost.usageとclaude_code.token.usageを export でき、さらに cost/token を skill、plugin、agent で分解できるとされています。([Claude Code]2) ([Claude Code]2)また、Skill の設計としては、
SKILL.mdは使用時に context に入り、その後 session 内に残ります。公式 docs はSKILL.mdを 500 行未満に保ち、詳細は supporting files に逃がすことを推奨しています。#295/PR #388 後のissue-refinement-loop/SKILL.mdは 1262 行であり、#393 の thin entrypoint 化が先にある方が、固定 token cost の測定対象として筋が良いです。([Claude API Docs]3)推奨アクション
推奨: #389 は
not plannedでクローズ。ただし「計測そのものを不要」とするのではなく、理由は measurement protocol 不備による premature issue とするのが適切です。
その後、必要なら以下のいずれかに分けるべきです。
案 A: #392/#393 後に再起票
タイトル案:
最低限入れるべき AC:
案 B: #389 を閉じずに全面 rewrite
これは可能ですが、既存 body の構造をかなり変える必要があります。単に AC を足す程度では不十分です。
runtime 計測ツール新規実装は Out of Scopeという制約も、OTel 採用を妨げるなら緩和が必要です。クローズコメント案
そのまま GitHub に貼れる文面です。
最終判定
APPROVE close.
#389 は「効果測定 Issue」ではなく「測定したい項目のリスト」に留まっています。現状で実装 PR を作ると、もっともらしい表は作れますが、削減効果の証明にはなりません。
squne121 commentedon May 27, 2026
CLOSE_DECISION_V1
squne121 commentedon May 27, 2026
CLOSE_DECISION_V1_CORRECTION
訂正理由: 前回コメントの
decision: completedは不正確。docs/dev/measurements/ディレクトリが存在せず measurement artifact が未作成。GitHub の stateReason: COMPLETED は Issue の close 操作を表すに過ぎず、measurement の実施完了を意味しない。