従量課金モデルがプロジェクトの雰囲気を損なう?ローカル AI コーディングエージェントを自作する方法
クラウドベースの AI コーディングツールの価格高騰と制限強化に対し、Qwen3.6-27B などのローカルモデルを活用してコストを抑えつつ開発を継続する具体的な実装ガイドが提示された。
キーポイント
クラウド依存からの脱却動向
Anthropic や Microsoft が利用ベース課金へ移行し、価格が高騰・制限強化される中、ローカル環境での AI コーディングエージェント構築が現実的な代替案として浮上している。
小規模モデルの能力向上
「推論(Reasoning)」機能や混合専門家モデル(MoE)、ツール呼び出し能力の進化により、以前より遥かに高性能になった小規模ローカルモデルが、大規模モデルに匹敵するコード生成を可能にしている。
具体的なハードウェア要件と実装
Qwen3.6-27B などのモデルを実行するには、Mac では 32GB 以上の統一メモリ、または GPU で 24GB 以上の VRAM が推奨され、Llama.cpp や LM Studio などの推論エンジンを用いたセットアップ手順が解説されている。
影響分析・編集コメントを表示
影響分析
この記事は、開発者がクラウド依存から脱却し、自社のハードウェアリソースを活用して AI コーディングコストを最適化する具体的な道筋を示しており、業界全体における「オンプレミス AI」の実用化加速に寄与する。特に、価格高騰が深刻化する中で、技術的な代替案を即座に実行可能なレベルで提示している点は、開発者コミュニティにとって極めて重要な示唆となる。
編集コメント
クラウドサービスの価格転換という外部環境の変化に対し、ローカル環境での実装技術に焦点を当てた実用的な解決策を提供しており、開発者のコスト意識と技術選定の幅を広げる内容です。
モデル開発者がより厳しいレート制限を課したり、価格を引き上げたり、あるいはサブスクリプションから使用量ベースの料金体系へ移行したりする中、その「雰囲気」で楽しむ趣味プロジェクトは、一気に高価なものになりそうです。幸いなことに、コスト削減のための選択肢が全くないわけではありません。ここ数週間で、Anthropic が最も手頃なプランから Claude Code を外すことを検討している様子や、Microsoft が水面下でのテストを飛ばして GitHub Copilot を純粋な使用量ベースモデルへ移行したことが報じられました。この一連の騒動により、私たちは考えさせられました。果たして Anthropic や OpenAI の最上位モデルが必要なのか、それともより小さなローカルモデルで済ませられるのか?確かに、処理速度は遅く、能力も劣り、作業に少しイライラすることもあるかもしれませんが、無料という価格には勝るものはありません……もちろん、すでに必要なハードウェアを所有しているという前提ですが。ちょうど Alibaba が最近、Qwen3.6-27B をリリースしました。このクラウドおよび電子商取引の巨人は、このモデルが「フラッグシップ級のコーディング能力」を、32 GB の M シリーズ Mac や 24 GB の GPU で動作させるのに十分な小さなパッケージに詰め込んだと自慢しています。
何が変化したのか
これはローカルコードアシスタントを検討した初めての試みではありません。以前は、Continue の VS Code 拡張機能を使用して、コード補完や生成などのタスクに取り組んだことがあります。その当時、モデルやソフトウェアスタックはまだかなり未熟で、有用なツールではありましたが、大規模な最先端モデルと競合するには必ずしも十分ではありませんでした。それ以来、モデルアーキテクチャやエージェントハネス(枠組み)は劇的に改善されました。「推論」機能により、小規模なモデルでもより長く「思考」することでそのサイズを補うことが可能になり、エキスパート混合モデル(Mixture-of-Experts)により、対話型体験のために毎秒テラバイト単位のメモリ帯域幅が必要ではなくなりました。さらに、関数呼び出しやツール呼び出しの能力が大幅に向上したことで、これらのモデルは実際にコードベース、シェル環境、そしてウェブと相互作用できるようになりました。
レート制限なしで雰囲気を楽しむ
この実践ガイドでは、Qwen3.6-27B などのローカルモデルをコンピュータ上でコーディング用にデプロイおよび設定する方法や、それらと併用できるいくつかのエージェントフレームワークについて探ります。必要なもの:
中規模の LLM(大規模言語モデル)を実行可能なマシン。Nvidia、AMD、または Intel の GPU で VRAM が少なくとも 24 GB あるものを推奨します。メモリが少し足りない場合は、システムメモリと GPU メモリをプールする方法についても解説します。最新の Mx-Max シリーズ Mac をお使いの方は、統合メモリが少なくとも 32 GB あることをお勧めします。本ガイドでは Llama.cpp を使用してモデルを実行しますが、LM Studio、Ollama、または MLX を使いたい場合でも、セットアッププロセスは同様です。システムへの Llama.cpp のインストールに困っている場合は、包括的なセットアップガイドをこちらで見つけることができます。
注意:古い M シリーズ Mac では、エージェントコーディングに必要な長いコンテキスト長に対応するのが困難な場合があります。Apple のハードウェアアクセラレータをより効果的に活用できる推論エンジンである oMLX を使用した方がうまくいく可能性がありますが、結果は環境によって異なります。
モデルの起動
現在、LLM をローカルで実行するのは非常に簡単なプロセスです。お気に入りの推論エンジンをインストールし、モデルをダウンロードして、API を介してアプリに接続するだけです。ただし、コードアシスタントの場合、いくつかのパラメータを調整する必要があります。そうしないと、モデルはゴミや壊れたコードを生成してしまう恐れがあります。一部のモデルでは、異なるアプリケーションで適切に機能させるために特定のハイパーパラメータが必要であり、Qwen3.6-27B も例外ではありません。Qwen3.6-27B を「雰囲気コーディング」に使用する際、Alibaba は以下のパラメータを設定することを推奨しています:
temperature=0.6
top_p=0.95
top_k=20
min_p=0.0
presence_penalty=0.0
repetition_penalty=1.0
また、モデルのコンテキストウィンドウ(文脈窓)をメモリに収まる限り大きく設定する必要があります。ご存じない方のために説明すると、モデルのコンテキストウィンドウは、特定の要求に対してモデルが追跡できるトークンの数を定義します。数千行のコードを含む大規模なコードベースを扱う場合、これはすぐに膨らんでしまいます。さらに、多くのエージェントフレームワークで使用されるシステムプロンプトも非常に大きくなる可能性があるため、コンテキストウィンドウは可能な限り高く設定したいものです。Qwen3.6-27B は 262,144 トークンのコンテキストウィンドウをサポートしていますが、ハイエンドの Mac やワークステーション GPU をお持ちでない限り、少なくとも 16 ビット精度ではそのすべてを活用するためのメモリは十分ではないでしょう。幸いなことに、モデルの状態を追跡するキーバリューキャッシュを 16 ビットで保存する必要はありません。パフォーマンスや品質の低下があまりない範囲で、より低い精度でも十分に機能します。コンテキストウィンドウを最大化するために、キーバリューペアを 8 ビットに圧縮します。最後に、プレフィックスキャッシング(先頭部分のキャッシュ)を有効にする必要があります。システムプロンプトやコードベースのように、プロンプトの大きな部分が何度も再処理されるワークロードでは、新しいトークンのみを処理することで推論速度が向上します。Llama.cpp の最新ビルドではこれがデフォルトで有効になっているはずですが、念のためフラグを指定しておきます。
これで準備は整いました。以下は 24 GB の Nvidia RTX 3090 TI を使用する場合の起動コマンドですが、AMD または Intel GPU をお使いの方や、Mac で Llama.cpp を実行している場合でも、同じコマンドが問題なく機能するはずです。メモリ量の多いマシンで実行する場合は、コンテキストウィンドウを 131,072 または 262,144 に引き上げることをお勧めします。Llama.cpp を実行して別のマシンからアクセスする予定の場合は、--host 0.0.0.0 をコマンドに追加してローカルエリアネットワークに公開する必要があります。Llama.cpp が VPC(仮想プライベートクラウド)上で動作している場合は、セキュリティのためにこのフラグを渡す前にファイアウォールルールを設定してください。
エージェントフレームワークの選択
モデルが起動・実行されたら、次はそれをコーディング用のエージェントハネスに接続する必要があります。単独ではモデルもコードを生成できますが、アクティブな開発環境がないと、実装、テスト、デバッグを行う手段がありません。「雰囲気コーディング」が他の AI 事業が struggling(苦戦)する中で成功した理由の一つは、コードが検証可能である点にあります。実行するかコンパイルされるか、あるいはそうでないかのどちらかです。
シンプルに保つために、3 つの一般的なオプションを見てみましょう:Claude Code、Pi Coding Agent、そして Cline です。まずは Claude Code から始めます。ご想像とは異なり、Claude Code を Anthropic のモデルと併用する必要はありません。このフレームワークは、十分なリソースがあればローカルモデルとも正常に機能します。通常通り Claude Code をインストールしてください。Anthropic によるワンライナー(一行コマンド)はこちらで見つけることができます。次に、Claude Code に、Anthropic のアカウントや API サービスではなく、マシン上でローカルで実行されているモデルを使用したいことを伝える必要があります。これは、Claude Code を起動する前にいくつかのシェル変数を設定することで行います。これらの設定は、新しいセッションから Claude を起動するたびに実行する必要があります。これで Claude を起動すると、直接ローカルモデルに接続されます。Claude Code 自体は通常どおり機能し続けます。
Pi Coding Agent
ご自身のローカルモデルを使用したいだけでなく、オープンソースのハネスも希望する場合もあります。Claude Code が好きなら、Pi Coding Agent も気に入るでしょう。Claude Code と同様に、使用するモデルを選ばないのが特徴です。Pi Coding Agent の主な魅力の一つは、その軽量さです。長い入力シーケンスは、低スペックまたは古い GPU やアクセラレータにとって非常に負担になります。Claude Code と Cline はどちらも、能力の低いハードウェアを停止させるほど重いシステムプロンプトを持つ可能性があります。それと比較すると、Pi Coding Agent のデフォルトのシステムプロンプトは短く、特にプロンプトキャッシングが有効な場合は動作も軽快です。ただし、その速度には、他のコーディングエージェントで見られる多くのガードレールやセキュリティ機能とのトレードオフがあります。これはおそらく仮想マシン、コンテナ、あるいは Raspberry Pi 上で起動するべきものです。Claude と同様、Pi Coding Agent もシステムに応じたワンライナーを使用してインストールできます。その後、必要なことは、エージェントハネスにモデルの場所を指示する少しの JSON データだけです。これまでの手順に従っていれば、セットアップは比較的簡単です。お好みのテキストエディタを使用して、以下のファイルを作成してください:
Windows:
Linux / Mac:
次に、以下のテンプレートを貼り付けます。API キーを設定している場合は、no_API_key_required を実際のキーに置き換えてください。残りの設定は、使用するモデルとポートによって異なります。また、Llama.cpp で設定した値に合わせて contextWindowSize も調整してください。
これで準備が整いましたので、作業ディレクトリに移動し、Pi Coding Agent を起動して、次の趣味プロジェクトの「雰囲気コーディング」に取り掛かりましょう。
Cline
Claude Code は VS Code などの人気のある統合開発環境(IDE)と直接統合されていますが、このルートを選ぶ場合は、もう一つのオープンソースアプリである Cline もチェックすることをお勧めします。Cline のインストールは、VS Code または対応する IDE の拡張機能マネージャーで Cline を見つけてライブラリに追加するだけという簡単なものです。次に、Cline に Llama.cpp サーバーを指し示し、温度(temperature)やコンテキストサイズなどのいくつかのハイパーパラメータを調整します:
Base URL: http://localhost:8080/v1
Model ID: unsloth/Qwen3.6-27B-GGUF:Q4_K_M
Context Window Size: 65536(または Llama.cpp で設定した値)
Temperature: 0.6
設定が完了したら、チャットインターフェースを通じて Cline と対話できます。生成されるファイルや編集内容は、VS Code に反映されます。Cline のより有用な機能の一つは、純粋な計画モードとアクションモードを切り替えることができる点です。Claude が質問を行動の呼びかけとして解釈し、実際には問題の検討を行いたい場合にイライラした経験がある方にとって、これは大きな助けになります。
ローカルモデルはついに十分なのか?
では、Qwen3.6-27B は Opus 4.7 や GPT-5.5 を置き換えることができるのでしょうか?残念ながら、完全にはできません。おそらく予想される通り、270 億パラメータの LLM が、数兆パラメータ規模の最先端モデルを代替するものではありません。しかし、最近のローカルモデルでどれほどまでできるかについては、驚くべき結果が得られるかもしれません。私たちのテストでは、Qwen3.6-27B はインタラクティブな太陽系 Web アプリをワンショット(一度の試み)で完成させ、既存のコードベース内のバグを正確に特定して修正することもできました。正直に言って、これらはかなり単純なプロジェクトです。モデルのパフォーマンスをよりよく把握するために、私は同僚の Thomas Claburn に任せて、Claude Code との比較を試してもらいました。彼はこう書いています:
これらのエージェントは本当に安全なのか?
OpenClaw として知られるセキュリティの悪夢をめぐる騒ぎの中で、これは良い質問です。幸いなことに、ここで議論したフレームワークの多くは、自律性において比較的制限されています。デフォルトでは、Claude Code と Cline は、コードの変更やシェルコマンドの実行を承認するために「人間がループ内(ヒューマン・イン・ザ・ループ)」にいることを前提としています。特定の命令をホワイトリストに登録していない限り、またはエージェントが何をしているかを理解する時間もなく、読む前にエンターキーを連打している場合を除き、被害の範囲は管理可能であるはずです。「〜すべき」と強調したのは、プログラミング言語と一般的な CLI コマンドに関する基本的な理解がここでは非常に重要だからです。もしモデルが、作業ディレクトリ外のファイルやフォルダに対して rm -rf を実行することを要求し始めたら、何かがおかしくなっている可能性があります。これは Pi Coding Agent の場合は当てはまりません。Pi Coding Agent はデフォルトで YOLO モード(You Only Live Once=無茶をするモード)で動作するため、アクセスできるあらゆるものを自由に読み書きする権限を与えられます。仮想マシンや Raspberry Pi といった専用の開発環境であれば、このリスクは許容範囲かもしれません。しかし、そうでない場合は、エージェントを適切なサンドボックス内で実行することを検討すべきです。コンテナ化はこのための簡単な手段を提供します。Docker コンテナを簡単に起動し、作業ディレクトリをそこに渡すのは比較的簡単です。Docker 自体はまた別の大きな問題を抱えていますが、以下の起動コマンドは、サンドボックス環境の合理的な出発点となるはずです。お好みの OS への Docker のインストール手順はこちらで見つけることができます。
これは新しい Ubuntu Docker コンテナを起動し、作業ディレクトリをコンテナに渡します。変更はそのフォルダ内またはコンテナ内に限定されます。エージェントサンドボックスの構築に関する包括的なガイドをご覧になりたい場合は、コメント欄でお知らせください。®
原文を表示
With model devs pushing more aggressive rate limits, raising prices, or even abandoning subscriptions for usage-based pricing, that vibe-coded hobby project is about to get a whole lot more expensive. Fortunately, you're not without cost-saving options. Over the past few weeks, we've seen Anthropic toy with dropping Claude Code from its most affordable plans while Microsoft has skipped testing the waters and moved GitHub Copilot to a purely usage-based model. The whole debacle got us thinking. Do we even need Anthropic or OpenAI's top models, or can we get away with a smaller local model? Sure, it might be slower, less capable, and a little more frustrating to work with, but you can't beat the price of free... Well, assuming you've already got the hardware that is. It just so happens that Alibaba recently dropped Qwen3.6-27B, which the cloud and e-commerce giant boasts packs "flagship coding power" into a package small enough to run on a 32 GB M-series Mac or 24 GB GPU. What's changed This isn't the first time we've looked at local code assistants. Previously we explored using Continue's VS Code extension for tasks such as code completion and generation. At the time, the models and software stack were quite immature, making them useful tools, but not necessarily good enough to compete with larger frontier models. Since then, model architectures and agent harnesses have improved dramatically. "Reasoning" capabilities allow small models to make up for their size by "thinking" for longer, mixture-of-experts models mean you don’t need terabytes a second of memory bandwidth for an interactive experience, and vastly improved function and tool calling capabilities mean that these models can actually interact with code bases, shell environments, and the web. All vibes, no rate limits In this hands on, we'll be looking at how to deploy and configure local models like Qwen3.6-27B, for coding on your computer, and explore some of the agent frameworks you can use with them. What you'll need: A machine capable of running medium-sized LLMs. We recommend an Nvidia, AMD or Intel GPU with at least 24 GB of VRAM. If you're a little short on memory, we'll also discuss how to pool your system and GPU memory. For those on newer Mx-Max series Macs, we recommend at least 32 GB of unified memory. For this guide, we'll be using Llama.cpp to run our model, but if you prefer to use LM Studio, Ollama, or MLX, the set up process is similar. If you need help getting Llama.cpp installed on your system, you can find our comprehensive setup guide here. Note: Older M-series Macs may struggle with the large context lengths required for agentic coding. You may have better luck with an inference engine like oMLX, which can take better advantage of Apple's hardware accelerators, but your mileage may vary. Spinning up the model Running LLMs locally is a dead simple process these days. Install your favorite inference engine. Download the model, and connect your app via the API. However, for code assistants in particular, there are a couple of parameters we need to dial in, otherwise the model is apt to churn out garbage and broken code. Some models require specific hyper-parameters to function properly in different applications, and Qwen3.6-27B is no exception. When using Qwen3.6-27B for vibe coding, Alibaba recommends setting the following parameters: temperature=0.6 top_p=0.95 top_k=20 min_p=0.0 presence_penalty=0.0 repetition_penalty=1.0 We also need to set the model's context window as large as we can fit in memory. If you're not familiar, a model's context window defines how many tokens the model can keep track of for any given request. When working with large code bases containing thousands of lines of code, this adds up quickly. What's more, the system prompts used by many agent frameworks can be quite large, so we want to set our context window as high as possible. Qwen3.6-27B supports a 262,144 token context window, but unless you have a high-end Mac or a workstation GPU, you probably don't have enough memory to take advantage of all of that, at least not at 16-bit precision. The good news is that we don't need to store the key-value caches, which track the model state, at 16-bits. We can get away with lower precisions without too much performance and quality degradation. To maximize our context window, we'll be compressing the key value pairs to 8-bits. Finally, we'll want to make sure prefix caching is turned on. For workloads where large sections of the prompt are going to be reprocessed over and over again, like a system prompt or code base, this will speed up inference by ensuring only new tokens are processed. In newer builds of Llama.cpp this should be enabled by default, but we'll call those flags just in case. With all that out of the way, here's the launch command we're using for a 24GB Nvidia RTX 3090 TI, but the same code command should work just fine if you're using an AMD or Intel GPU or are running Llama.cpp on a Mac. If you're running this on a machine with more memory, try bumping up the context window to 131,072 or 262,144. If you're planning on running Llama.cpp and accessing it on another machine, you'll also want to add --host 0.0.0.0 to the command, which will expose it to your local area network. If Llama.cpp is running in a VPC, you'll want to configure your firewall rules before passing this flag for the sake of security. Choosing an agent framework Now that our model is up and running, we need to connect it to an agentic coding harness. On their own, models can generate code, but they have no way to implement, test, or debug it without an active development environment. Part of what has helped vibe coding take off where other AI ventures have struggled, is that code is verifiable. It either runs or compiles, or it doesn't. To keep things simple we'll be looking at three popular options: Claude Code, Pi Coding Agent, and Cline. We'll kick things off with Claude Code. Despite what you might think, you don't have to use Claude Code with Anthropic's models. The framework works just fine with local models, assuming you've got enough resources to run them. Install Claude Code as you normally would. You can find Anthropic's one-liner here. Next, we'll need to tell Claude Code we want to use the model running locally on our machine rather than a Claude account or Anthropic's API services. This is done by setting a few shell variables before launching Claude Code. These will need to be run each time you launch Claude from a new session. Now when you start Claude, it'll connect directly to your local model. Claude Code itself continues to function as it normally would. Pi Coding Agent Let's say you not only want to use your own local models, but would prefer an open source harness as well. If you like Claude Code, you'll probably like the Pi Coding Agent. And just like Claude Code, it's not picky about what model you use with it. One of the main attractions of Pi Coding Agent is how lightweight it is. Long input sequences can be extremely taxing on lower end or older GPUs or accelerators. Claude Code and Cline both have system prompts that can bring less capable hardware to a crawl. By comparison, Pi Coding Agent's default system prompt is short enough to keep things snappy, especially with prompt-caching enabled. However, that speed comes at the expense of many of the guardrails and safety features we see on other coding agents. This is one you'll probably want to spin up in a virtual machine, container, or even a Raspberry Pi. Much like Claude, the Pi Coding Agent can be installed using the appropriate one liner for your system. After that, all that's required is a little bit of JSON telling the agent harness where to find your model. If you've been following along, the setup is fairly simple. Using your preferred text editor, create the following file: Windows: Linux / Mac: Next, paste in the following template. If you've set an API key, replace no_API_key_required with your key. The rest of these will depend on what model and port you're using. You'll also want to adjust the contextWindowSize to match what you set in Llama.cpp. With that out of the way, we can navigate to our working directory, launch Pi Coding Agent, and get to work vibe coding our next hobby project. Cline Claude Code integrates directly with popular integrated development environments (IDEs) like VS Code, but if you're going this route, we also recommend checking out another open source app called Cline. Installing Cline is as simple as finding it in VS Code's — or a supported IDE's — extension manager and adding it to your library. Next, we'll point Cline at our Llama.cpp server and adjust a few hyperparameters like temperature and context size: Base URL: http://localhost:8080/v1 Model ID: unsloth/Qwen3.6-27B-GGUF:Q4_K_M Context Window Size: 65536 (Or whatever you set in Llama.cpp) Temperature: 0.6 Once it is configured, you can interact with Cline through its chat interface. Any files or edits will appear in VS Code as they're generated. One of Cline's more useful features is the ability to switch between a pure planning mode and an action mode. If you've ever gotten frustrated because Claude interpreted a question as a call to action when what you really want to do is workshop a problem, this is a huge help. Are local models finally good enough? So can Qwen3.6-27B replace Opus 4.7 or GPT-5.5? Not exactly. As you probably guessed, a 27B LLM isn't a replacement for a multi-trillion parameter frontier model. However, you might be surprised with just how far you can get with local models these days. In our testing, Qwen3.6-27B easily one shot an interactive solar system web app and was able to accurately identify and patch bugs in an existing code base. Admittedly, these are fairly trivial projects. To get a better sense of how well the model performs, I handed it over to fellow vulture Thomas Claburn to see how it compares to his recent experience with Claude Code. He writes: Are these agents even safe? With all the hullabaloo over the security nightmare known as OpenClaw, it's a good question. Thankfully, most of the frameworks we've discussed here are fairly limited in their autonomy. By default, Claude Code, and Cline rely on having a human-in-the-loop to approve code changes and execute shell commands. Unless you've whitelisted a set of commands or are spamming the enter key before reading without taking the time to understand what it is that the agent is trying to do, the blast radius should be manageable. We emphasize "should be" because a basic understanding of the programming language and common CLI commands goes a long way here. If the model starts asking to run rm -rf on files or folders outside your working directory, something probably has gone wrong. This isn't the case with Pi Coding Agent, which operates in YOLO mode out of the box, which gives it free rein to read and modify anything it has access to. In a dedicated development environment like a virtual machine or Raspberry Pi, this might be an acceptable risk, but if it's not, you may want to consider running the agent in a proper sandbox. Containerization offers an easy avenue for this. It's fairly simple to spin up a Docker container and pass your working directory through to it. Docker is a whole can of worms on its own, but the following run command should give you a reasonable starting point for a sandboxed environment. You can find instructions on installing Docker on your preferred OS here. This will spin up a new Ubuntu docker container and pass through our working directory to the container. Any changes will be limited to that folder or the container. If you'd like to see a comprehensive guide on building agent sandboxes, let us know in the comments section. ®
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み