概要
OpenCode が Claude Code に対して持つ最大の競争優位性はマルチモデル・マルチプロバイダー対応。
Claude Code は Codex delegation gates (7本のhook) で Codex CLI にタスクをルーティングするが、OpenCode はそれを超えて、異なるプロバイダー(Anthropic, OpenAI, Google, ZAI, OpenRouter)の異なるモデルをエージェントごとに最適配置できる。
技術的背景
packages/opencode/src/agent/agent.ts:39-43 — Agent.Info に model: { modelID, providerID } フィールド
packages/opencode/src/tool/task.ts:108 — タスク委任時に agent.model ?? parent.model で解決
packages/opencode/src/config/config.ts:894 — small_model で軽量タスク用モデル分離
@opencode-ai/plugin — chat.params, permission.ask, tool.execute.before hookが利用可能
実装する delegation gates (guardrail.ts に追加)
1. agent-model-mapping (chat.params)
エージェントタイプに基づく最適モデル推奨・強制
- review/explore → 安価モデルOK
- implement/security → 高性能モデル推奨
- 設定:
opencode.json の agent 設定から読み取り
2. delegation-budget-gate (tool.execute.before for task)
タスク委任の予算管理
- セッション内の累計コスト追跡
- 並列タスク数の上限制御(provider別)
- 高コストモデルの使用回数制限
3. provider-routing-advisory (chat.params)
プロバイダー特性に基づくルーティング助言
- コードタスクに特化したモデル検出
- コスト効率の良い代替モデル提案
4. parallel-execution-gate (tool.execute.before for task)
並列実行の安全制御
- 同時タスク数をプロバイダー/モデル別に制限
- rate limit 超過の事前検出
5. cost-tracking (tool.execute.after for task)
コスト追跡と可視化
- プロバイダー別・エージェント別のコスト記録
- セッション終了時のコストサマリー
Claude Code の Codex delegation gates との対応
| Claude Code hook |
OpenCode 対応 |
進化点 |
| codex-task-gate |
delegation-budget-gate |
単一Codex → 任意プロバイダー |
| codex-model-gate |
agent-model-mapping |
Codex固定 → エージェント別モデル |
| codex-parallel-gate |
parallel-execution-gate |
同等 + プロバイダー別制限 |
| codex-cost-gate |
cost-tracking |
Codex API → 全プロバイダーコスト |
| codex-timeout-gate |
(not needed) |
OpenCode のタスクには組み込みタイムアウトあり |
| codex-output-gate |
verify-agent-output (Issue別) |
同等 |
| codex-error-gate |
tool-failure-recovery (Issue別) |
同等 |
受入基準
関連
概要
OpenCode が Claude Code に対して持つ最大の競争優位性はマルチモデル・マルチプロバイダー対応。
Claude Code は Codex delegation gates (7本のhook) で Codex CLI にタスクをルーティングするが、OpenCode はそれを超えて、異なるプロバイダー(Anthropic, OpenAI, Google, ZAI, OpenRouter)の異なるモデルをエージェントごとに最適配置できる。
技術的背景
packages/opencode/src/agent/agent.ts:39-43— Agent.Info にmodel: { modelID, providerID }フィールドpackages/opencode/src/tool/task.ts:108— タスク委任時にagent.model ?? parent.modelで解決packages/opencode/src/config/config.ts:894—small_modelで軽量タスク用モデル分離@opencode-ai/plugin—chat.params,permission.ask,tool.execute.beforehookが利用可能実装する delegation gates (guardrail.ts に追加)
1. agent-model-mapping (chat.params)
エージェントタイプに基づく最適モデル推奨・強制
opencode.jsonの agent 設定から読み取り2. delegation-budget-gate (tool.execute.before for task)
タスク委任の予算管理
3. provider-routing-advisory (chat.params)
プロバイダー特性に基づくルーティング助言
4. parallel-execution-gate (tool.execute.before for task)
並列実行の安全制御
5. cost-tracking (tool.execute.after for task)
コスト追跡と可視化
Claude Code の Codex delegation gates との対応
受入基準
007-multi-model-delegation-gates.md関連