
VS CodeのCodexでLuna / Terra / Solを自動で使い分ける ― AGENTS.mdとSubagentでモデルルーティングを作るThis article explains how to build a model-routing setup in VS Code Codex that…
匿名の公開いいねです。記事の保存・お気に入りではなく、Featured、Top 3、重要度、掲載順位には影響しません。仕組みとプライバシーAnonymous public likes are reactions, not saved articles or bookmarks. They do not affect Featured, Top 3, importance, or listing order.How it works and privacy
- AGENTS.mdとSubagent機能を活用し、タスクの複雑さに応じてCodexのLuna・Terra・Solを自動選択するモデルルーティング構成を解説した記事。
- コスト管理と処理効率の両立を目的としており、従量課金への影響も注意点として挙げられている。
This article explains how to build a model-routing setup in VS Code Codex that automatically selects among Luna, Terra, and Sol based on task complexity using AGENTS.md and Subagent features, with attention to cost implications from pay-as-you-go pricing.
本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (qiita.com) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (qiita.com).
要約と収集メタデータに基づく AI 解説。元記事全文の転載・翻訳ではありません。AI explainer based on the summaries and collected metadata, not a copy or translation of the full source article.
VS Code上で使うCodexにおいて、複数のモデルをタスクの難度に応じて自動的に切り替える「モデルルーティング」の構成手法を解説したブログ記事が、Qiita上で公開された。設定ファイルのAGENTS.mdとSubagent機能を組み合わせ、Luna・Terra・Solという3つのモデルを使い分けることで、処理効率とコストの両立を狙う内容だ。
記事は2026年8月25日時点のCodex / GPT-5.6系の仕様に基づくとされ、モデル名や設定項目、Subagentの仕様は今後変更される可能性があると注記されている。
そもそもAGENTS.mdは、エージェントへの指示や制約をプロジェクト単位で記述しておく設定ファイルとして広く使われつつある。ここにモデル選択のルールを書き込み、Subagent機能と連携させることで、タスクの複雑さを判定して適切なモデルへ振り分ける仕組みを作れるという発想だ。単純な編集や定型処理には軽量なモデルを、複雑な設計や横断的なコード変更には高性能なモデルを、といった具合に役割を分担させる想定と見られる。
この手法の背景には、AIコーディング支援における従量課金の存在がある。高性能モデルは応答品質が高い一方で単価も上がりやすく、あらゆるタスクに最上位モデルを使えばコストがかさみやすい。逆に軽量モデルだけでは難しいタスクに対応しきれない。そこで難度に応じて自動でモデルを選ぶことで、無駄な支出を抑えつつ必要な場面で性能を確保しようという狙いがある。記事自身も、選ぶモデル次第で従量課金の金額が変わる点を注意点として挙げている。
モデルルーティングという考え方自体は、Codexに限らず各種のAIエージェントやAPI利用の現場で関心を集めるテーマだ。用途ごとに最適なモデルを割り当てる発想は、コスト最適化と品質担保を両立する現実的なアプローチとして今後も広がる可能性がある。ただし本記事の内容は特定時点の仕様に依存するため、導入時は最新の仕様や料金体系を確認したうえで、自己責任で扱うことが求められる。
Developers working with AI coding assistants increasingly face a trade-off between capability and cost: the most powerful models tend to produce better results but charge more, while lighter models are cheaper yet can stumble on complex work. A recent walkthrough published on Qiita describes a practical way to manage this inside VS Code Codex, using configuration files and delegation features to automatically route tasks to one of three models — Luna, Terra, and Sol — depending on how demanding each request is.
The central concept is model routing. Rather than manually switching models for every request, the setup lets Codex select which model to invoke based on task complexity. Simple edits, formatting, or boilerplate generation can be handled by a lighter model, while architectural reasoning, multi-file refactoring, or debugging that spans a codebase can be escalated to a heavier one. The article frames this as a way to balance cost management with processing efficiency, since the amount billed under pay-as-you-go pricing changes depending on which model ends up doing the work.
Two mechanisms make the routing possible. The first is AGENTS.md, a markdown file placed in a project that gives an AI agent standing instructions about how to behave. In this configuration, AGENTS.md carries the routing rules — the guidance that tells the agent when to reach for Luna, Terra, or Sol. The second is the Subagent feature, which lets a primary agent spin up specialized sub-agents to handle delegated portions of a task. By pairing routing rules with subagents, the main agent can hand off subtasks to whichever model suits them, keeping the more expensive calls reserved for the parts that genuinely need them.
The article is explicit that it reflects the state of Codex and the GPT-5.6 series as of August 25, 2026, and it cautions that model names, configuration options, and the Subagent specification may change. That disclaimer matters because tooling in this space has moved quickly, and a routing setup that works today could require adjustment as models are renamed, retired, or repriced. Readers are advised to treat the configuration as a starting point and to verify current behavior against their own environment, and the author notes that use of the described approach is at the reader's own risk.
Some background helps explain why this pattern is gaining traction. AGENTS.md has emerged as a loose convention across several coding-agent tools for supplying repository-specific instructions, similar in spirit to how a README orients human contributors or how linter configuration standardizes code style. The Subagent, or sub-agent, pattern reflects a broader industry shift toward orchestration — decomposing a large request into smaller, specialized units of work rather than relying on a single monolithic prompt. Comparable ideas appear in other agent frameworks that route between models or split reasoning and execution across components, so the technique described here is best understood as one implementation of a wider trend rather than a wholly novel invention.
For teams, the appeal is straightforward. If most routine coding tasks can be served by a cheaper model, the aggregate bill under usage-based pricing can fall while a stronger model remains available for the minority of hard problems. The naming of Luna, Terra, and Sol appears to correspond to distinct tiers within the GPT-5.6 lineup, each with its own capability and price profile, though the exact characteristics are subject to the same caveat about changing specifications.
The trade-off is added configuration complexity and the need to tune routing rules carefully. If the rules are poorly calibrated, tasks may be under-served by a model that is too weak, forcing retries, or over-charged by one that is stronger than necessary. In principle, aggressive escalation could even raise costs rather than lower them, so the value of the approach depends heavily on how well the thresholds match a team's actual workload.
For those already using Codex in VS Code, the walkthrough offers a concrete template for combining declarative instructions in AGENTS.md with delegated execution through subagents. As with any usage-based AI tooling, the practical advice is to start small, monitor billing closely, and revisit the routing logic whenever the underlying models or their pricing change. The concept is likely to remain relevant even if the specific model names do not, given the persistent tension between quality and cost that motivates it.
ポコとTECHガイドPoko & TECH Guide
ポコと当サイトのTECHガイドが、記事の要約と収集した情報から読みどころを語るAI生成の対話です。Poko and TECH Dashboard's own TECH Guide discuss the article's highlights in an AI-generated conversation based on its summary and collected source details.
- ポコPokoLuna・Terra・Solを自動で使い分ける「モデルルーティング」って何?What does “model routing” mean when Codex automatically switches among Luna, Terra, and Sol?
- TECHガイドTECH Guide簡単に言うとじゃな、記事ではAGENTS.mdとSubagentを使い、タスクの複雑さに応じて選ぶモデルを切り替える構成じゃよ。Put simply, the article uses AGENTS.md and Subagents to choose a different model depending on how complex the task is.
- ポコPokoそれって何が嬉しいの?全部同じモデルに任せるより効率がいいのかな。What’s the benefit? Could that be more efficient than giving every task to the same model?
- TECHガイドTECH Guide記事の狙いは、処理効率とコスト管理の両立じゃ。必要に応じてモデルを選び分ける構成にしておる。According to the article, the goal is to balance processing efficiency with cost control by selecting models according to each task.
- ポコPokoなるほど!タスクの複雑さを見て、自動で担当モデルを振り分ける仕組みなんだね。Got it! It’s a setup that automatically assigns a model based on the task’s complexity.
- TECHガイドTECH Guideそうじゃな。ただし選択次第で従量課金額が変わり、2026年8月25日時点の仕様も今後変わる可能性がある点には注意じゃよ。Exactly. But model choices can affect pay-as-you-go charges, and the specifications documented as of August 25, 2026 may change later.



