LangChain がコーディングエージェントの予測可能性を高める方法
LangChain は、コーディングエージェントの予測可能性を高める手法を開発し、開発プロセスにおけるエージェントの挙動制御を可能にした。
キーポイント
予測可能な動作の実現
LangChain が新たに開発した手法により、コーディングエージェントが以前よりも安定して予測可能な結果を生み出せるようになった。
挙動制御の確立
この技術導入により、開発プロセス全体においてエージェントの振る舞いを意図通りに制御・管理することが可能となった。
開発プロセスへの影響
エージェントの信頼性向上が、ソフトウェア開発ワークフローにおける自動化の精度と効率を底上げする基盤となる。
影響分析・編集コメントを表示
影響分析
この進展は、AI を活用したコーディング支援ツールの実用化において最も課題とされていた「予測不能な出力」の問題に対する重要な解決策を示しています。開発者がエージェントを本格的に生産環境や複雑なプロジェクトに組み込む際の心理的・技術的ハードルが下がることで、AI による自動コード生成の普及速度が加速すると予想されます。
編集コメント
エージェントの挙動が予測不能であることは、実務導入における最大の障壁の一つでした。この手法は、単なる性能向上ではなく「信頼性」を担保する重要な転換点と言えます。
ここ数年、予算において AI の利用は無視しやすいものでした。LangChain では、モデルの利用は限られたチームに主に限定されており、利用量は予測可能で、毎月の請求額も管理可能な範囲内でした。
しかし、過去 1 年間で、いくつかの出来事が重なったことで、この状況は変わりました:
- AI の利用が数チームから全社規模へと拡大した
- 最良のモデルのコストが増加した
- エージェントが十分に強力になり、単一のタスクを完了するために容易に数十回のモデル呼び出しを実行できるようになった
その結果、AI への支出は理解しにくくなり、リアルタイムでの制御も困難になりました。
この問題が最も顕著に現れたのがエンジニアリング部門です。コーディングエージェントを集中的に使用する開発者 1 人によって、誰も気づく前に週間で数千ドルの支出が発生することがありました。経営陣には、発生している支出を可視化し、チームやユーザーごとに制限を設定し、生産的な作業を妨げずに誤った使いすぎを防ぐ方法が必要でした。
LLM ゲートウェイの実装
コスト追跡を念頭に置き、LangSmith LLM Gateway を毎日使用する製品に直接実装しました。最初の目標は単純でした:コーディングエージェントによる偶発的な支出の暴走を防ぎ、エンジニアリング担当副社長と財務責任者の両者に安心感をもたらすことです。
LangSmith LLM Gateway では、予算を複数の次元で設定できます:
- 組織全体
- ワークスペース
- ユーザー
- API キー
すべての従業員が月次、週次、日次、時間単位で適用できるデフォルトの予算があり、より高い利用が必要なプロジェクトに取り組む人々に対して例外を設定する機能も備えています。
私たちは、中央集権的に実施可能な場所であればどこでも、Claude Code、Codex、または LangChain Deep Agents を通じたコーディングエージェントにゲートウェイ(LLM Gateway)を適用しました。社内のすべての対象となるコーディングエージェントの呼び出しは LLM ゲートウェイを経由し、エンジニアリングリーダーシップには会社全体の支出を分単位で把握できる鳥瞰図が提供されます。また、実装を容易にするため、MDM(Mobile Device Management)を通じて中央集権的にオーケストレーションを行い、各ユーザーが自らセットアップ処理を行う必要がないようにしました。
「ゲートウェイの利点は、中央集権的な制御により確実性が高まることです。ダッシュボードを開いて予期せぬ数千ドルの請求書が表示される心配がありません。制限と支出を、中央のシャットダウン/管理ポイントを通じて可視化できます。」— Alex Lunev, LangChain 技術担当バイスプレジデント
LangSmith スタック全体へのコスト制御の統合
ゲートウェイは、コストデータを AI システムの他の部分と接続した際に最も有用です。
LangSmith LLM ゲートウェイは LangSmith の一部であるため、支出管理機能はすでに AI アプリケーションを管理するために使用しているシステムと連携しています。ゲートウェイの実行はトレーサビリティが可能で、ユーザーやキーに帰属付けられ、本番データとともに分析できます。
つまり、コストデータは月次請求書に限定されません。特定のエージェント、モデル呼び出し、トレース、および失敗モードに支出を接続できます。また、スタンドアロンのプロキシの周りでこれらのワークフローを再構築するのではなく、既存の LangSmith の OAuth、モデル管理、ユーザー管理の制御機能を活用できます。
これにより、Gateway データはより実用的なものになります。コーディングエージェントの消費量が予想を超えた場合、トレースを検査して何が起きたかを理解し、評価データや観測性データを活用して、基盤となるエージェントの動作を改善できます。
社内展開から得た教訓と製品への影響
まず自社の Gateway で運用を開始したことで、紙面上の請求・ルーティングと実際の挙動との間にギャップがあることが浮き彫りになりました。今後の投資先を決める上で重要な 3 つの教訓があります:
- モデルの価格設定は、単なる静的なテーブルよりも複雑です。参照用テーブルはすぐに陳腐化するため、正確な原価計算にはキャッシュの有無やトークン階層の微妙な違い、そして頻繁に変わるプロバイダーの価格変動をすべて反映させる必要があります。この課題により、私たちはモデル価格設定を定数ではなくシステムとして扱うようになり、信頼性の高いコストを維持するために計算ロジックの監査と、より厳格な更新パスの実装を進めています。
- すべてのクライアントがゲートウェイを介してきれいにルーティングされるわけではなく、サポートはアプリケーションやその管理方法によって異なります。私たちの展開において、Cursor は Chat 機能のみを対象としたユーザーごとの設定としてベース URL の置換のみを提供しており、これはプラットフォーム全体で MDM を通じて強制できるものではありませんでした。Claude Desktop は管理された構成としてゲートウェイを介して提供することは可能でしたが、これを有効にすると、標準的なチャットではなくローカルエージェントとして動作するアプリに切り替わってしまい(その機能は開発初期段階です)、ゲートウェイのサポート待ちをするのではなく、ゲートウェイがキャプチャするものと、残りのエンタープライズプロバイダー設定(つまり月次 Claude プランなど)がキャプチャするものの差分を測定するというアプローチを採用しました。これにより、トラフィックが直接ゲートウェイを通過できない場合でも支出の把握が可能になります。
- 厳格な制限には、それを取り巻くワークフローが必要です。対策のない上限は単に作業をブロックするだけです。エンジニアたちは、制限に達するずっと前に早期警告を受け取り、迅速かつ監査可能な方法でその上限を引き上げることを望んでいました。このフィードバックにより、制限は静的なガードレールからワークフローへと進化しました。しきい値の手前での段階的なアラート機能の追加と、紙(またはデジタル記録)による予算増額リクエストフローの検討を進めており、支出管理がビジネスを保護しつつ、業務の妨げにならないようにしています。
Dogfooding(社内製品活用)により、抽象的なエッジケースが具体的な製品の優先事項へと変化しました。具体的には、価格の正確性、ゲートウェイを介してルーティングできないクライアントへの優雅な対応、および支出制限の管理です。
結果
LangSmith LLM Gateway を社内で導入して以来、LLM の利用コストは予算内に収まっています。
より大きな変化は、支出が月末になって初めて把握できるものではなくなった点です。エンジニアリングのリーダーたちは、使用状況をリアルタイムで確認でき、適切なレベルで制限を設定し、予期せぬ請求書が発生することなくチームにコーディングエージェントを利用する柔軟性を与えることができます。
LangSmith LLM Gateway は現在、クローズドベータ版として提供されています。アクセスを希望される方は こちら からサインアップしてください。
原文を表示
For the last few years, AI usage was easy to ignore in a budget. At LangChain, model usage was largely confined to a few teams, usage was predictable, and monthly bills were manageable.
However, in the last year that stopped being true with a few things happening at once:
- AI usage went from a few teams to the whole company
- The best models got more expensive
- Agents got powerful enough to easily fire off dozens of model calls to finish a single task.
As a result, AI spend became harder to understand and harder to control in real time.
The sharpest version of this showed up in engineering. One developer using coding agents heavily could generate thousands of dollars in weekly spend before anyone noticed. Our leadership needed a way to see spend as it was happening, set limits by team and user, and prevent accidental runaway usage without blocking productive work.
Implementing an LLM Gateway
With cost tracking in mind, we built LangSmith LLM Gateway straight into the product we use every day. The immediate goal was simple: prevent accidental runaway spend by coding agents to bring peace of mind to both the VP of Engineering and Head of Finance.
In LangSmith LLM Gateway, budgets can be set across several dimensions:
- Organization-wide
- Workspace
- User
- API key
We have default budgets that every employee can hit on monthly, weekly, daily, and hourly windows, with the ability to set exceptions for people working on projects that need higher usage.
We applied the Gateway everywhere in the company where it was possible to do so centrally: coding agents through Claude Code, Codex, or LangChain Deep Agents. Every eligible coding agent call at the company runs through the LLM Gateway, giving our engineering leadership a bird’s eye view of company-wide spend to the minute. And we made sure it was easy to implement, orchestrating it centrally through our MDM so each user wouldn’t have to process the setup themselves.
“The upside of Gateway is that there is more certainty with centralized control that I won’t open my dashboard and see a surprise multi-thousand dollar bill. I have visibility into limits and spend with a central shutoff/control point.” - Alex Lunev, VP of Engineering, LangChain
Connecting Cost Controls to the Rest of the LangSmith Stack
Gateway is most useful when cost data is connected to the rest of the AI system.
Because LangSmith LLM Gateway is part of LangSmith, spend controls are connected to the systems we already use to manage AI applications. Gateway runs can be traced, attributed to users or keys, and analyzed alongside production data.
That means cost data is not limited to a monthly bill. We can connect spend to specific agents, model calls, traces, and failure modes. We can also use existing LangSmith controls for OAuth, model management, and user management, instead of rebuilding those workflows around a standalone proxy.
This also makes Gateway data more actionable. When a coding agent spends more than expected, we can inspect the trace, understand what happened, and use evaluations and observability data to improve the underlying agent behavior.
What our internal rollout taught us and how it shaped the product
Running the Gateway on ourselves first surfaced the gap between how billing and routing look on paper and how they behave live. Three lessons that shaped where we invested next:
- Model pricing is more complex than a static table. A lookup table goes stale quickly, so accurate cost accounting has to absorb caching, token-tier nuances and frequent provider prices changes. This pushed us to treat model pricing as a system than a constant: we’re auditing our calculation logic and building in a more rigorous update path in order to maintain trustworthy costs.
- Not every client routes cleanly through Gateway, and support varies by app and by how it is managed. In our rollout, Cursor only exposed base-url swap as a per-user setting covering only Chat, and not something that we could push through our MDM across the platform. Claude Desktop could only be passed through the gateway as a managed config, but turning it on shifted the app into a local agent in place of standard Chat (and the capability is early in development). Rather than wait on provider support, this shaped our approach to measure the delta of what gateway captures versus what the rest of our enterprise provider settings capture (i.e. monthly Claude plans) in order to have spend accounted for even when traffic can’t flow through Gateway directly.
- Hard limits need a workflow around them. A cap with no runway just blocks work. Engineers told us that they want early warning well before they hit a limit and a fast, auditable way to raise it. That feedback turned limits from static guardrails into a workflow: we’re adding tiered alerting ahead of a threshold and exploring a paper-trailed budget-increase request flow so spend controls protect the business without getting in the way.
Dogfooding turned abstract edge cases into concrete product priorities including price accuracy, graceful handling of clients who can’t route through Gateway, and managing limits on spend.
The result
Since rolling out LangSmith LLM Gateway internally, our LLM costs have stayed within budget.
The bigger change is that spend is no longer something we only understand at the end of the month. Engineering leaders can see usage as it happens, set limits at the right level, and give teams the flexibility to use coding agents without creating surprise bills.
LangSmith LLM Gateway is currently in private beta. Sign up here to request access.
関連記事
Fireworks を活用した 100 倍安価なトレース判定器の構築
LangChain が Fireworks の技術を活用し、従来の 100 分の 1 のコストで動作するトレース判定器を開発したと発表した。
Align Evals の紹介:LLM アプリケーション評価の効率化
LangChain が、大規模言語モデル(LLM)を用いたアプリケーションの評価プロセスを簡素化する新ツール「Align Evals」を発表した。
LangSmith を用いたペア評価の実装
LangChain が提供する LangSmith ツールにおいて、モデルの出力を比較するペア評価手法を紹介し、開発者が評価プロセスを効率化する方法を解説している。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み