AIエージェントが大規模言語モデルから最良の結果を得るための検索を支援
MIT CSAILとAsari AIは、LLMを用いたAIエージェントのコード生成エラー時に自動でバックトラックし並列実行による最適解探索を行うフレームワーク「EnCompass」を開発した。
キーポイント
EnCompassフレームワークの概要
MIT CSAILとAsari AIが共同開発したEnCompassは、LLM呼び出しエラー時に自動でバックトラックし、プログラムのランタイムクローンを作成して並列実行することで最良の解を検索する仕組みを提供する。
開発コストの削減と自動化
従来の手法ではバックトラックロジックの実装に多大なコード変更が必要だったが、EnCompassを使用することで開発者はバックトラックやクローン化の位置を注釈するだけでよく、検索戦略はフレームワーク側が自動処理またはカスタム指定可能になる。
LLM出力の多様なパス探索
EnCompassは、LLM呼び出しの異なる出力結果に伴うエージェントの取り得るすべての実行パスを探索し、LLMが最適なソリューションを見つけるパスを選択する汎用的な検索機能を持つ。
自動バックトラックと並列探索
EnCompassはLLMの誤りを自動でバックトラックし、プログラムのクローンを作成して並列に複数の試行を行うことで、最適な実行パスを検索する。
検索戦略とワークフローの分離
フレームワークにより、エージェントの基本動作から検索戦略が分離され、開発者は異なる戦略を容易に実験してパフォーマンスを最適化できる。
コーディング負荷の大幅な削減
LLM呼び出し箇所を「ブランチポイント」として注釈付けるだけで済み、検索実装にかかるコーディング努力は最大80%削減された。
柔軟な検索戦略の実装
EnCompassはモンテカルロ木探索やビームサーチなどの標準的な戦略をすぐに利用可能にし、ユーザーが独自のカスタム戦略を定義することも可能にする。
影響分析・編集コメントを表示
影響分析
この技術は、LLMの非確実性を補完するエージェント開発のパラダイムシフトを示唆しており、特にコード生成や複雑なタスク自動化の現場において、開発者の負担軽減とシステムの信頼性向上に寄与する。MITという権威ある研究機関の成果であり、実用化への期待が高まる重要な進展である。
編集コメント
LLMのハルシネーションやエラーを前提とした「自己修正・探索型」エージェントの実現に向けた具体的なフレームワークの提示は、実務レベルでのAI活用において極めて重要なステップである。
プレスお問い合わせ 連絡先:
クローズ
キャプション: EnCompassがプログラムを実行する際、LLMがミスを犯した場合には自動的にバックトラックします。また、プログラムのランタイムを複製して、最良の解決策を探すために複数の試行を並列で行うことも可能です。
クレジット: 画像: Alex Shipps/MIT CSAIL 前の画像 次の画像
研究者が研究アイデアをブレインストーミングするにせよ、CEOが人事や財務のタスクを自動化したいと望むにせよ、人工知能ツールは、自分が必要とさえ知らなかったアシスタントになりつつあります。特に、多くの専門家が、AIエージェントと呼ばれる半自律的なソフトウェアシステムの能力を活用しています。これは、問題解決やタスク完了のために特定のポイントでAIを呼び出すことができるものです。AIエージェントは、大規模言語モデル(LLM)を利用する場合に特に効果的です。なぜなら、それらのシステムは強力で効率的、かつ適応性が高いからです。このような技術をプログラムする一つの方法は、システムに何をしてほしいか(「ワークフロー」)、そしてLLMをいつ使用すべきかをコードで記述することです。もしあなたが、より最適化と安全性のために、古いコードベースをより現代的なプログラミング言語を使用するよう刷新しようとしているソフトウェア会社なら、LLMを使ってコードベースを一度に一つのファイルずつ翻訳し、各ファイルをテストしながら進めるシステムを構築するかもしれません。しかし、LLMがミスを犯したらどうなるでしょうか?エージェントには、過去のミスから学んだ教訓を活かして、別の試みを行うためにバックトラックしてほしいでしょう。これをコード化するには、元のエージェントを実装するのと同程度の労力がかかります。もしコードベースを翻訳するシステムが何千行ものコードを含んでいれば、LLMがミスをしたときのバックトラックのロジックをサポートするために、何千行ものコード変更や追加を行うことになるでしょう。
プログラマーの時間と労力を節約するために、MITのコンピュータ科学・人工知能研究所(CSAIL)およびAsari AIの研究者たちは、「EnCompass」というフレームワークを開発しました。
EnCompassを使えば、これらの変更を自分で行う必要はもうありません。代わりに、EnCompassがあなたのプログラムを実行するとき、LLMがミスを犯せば自動的にバックトラックします。EnCompassはまた、プログラムのランタイムを複製して、最良の解決策を探すために複数の試行を並列で行うこともできます。完全に一般化して言えば、EnCompassは、すべてのLLM呼び出しの異なる可能な出力結果に起因してあなたのエージェントが取り得る、異なる可能な経路を検索し、LLMが最良の解決策を見つける経路を探します。そして、あなたがしなければならないのは、バックトラックしたりプログラムランタイムを複製したりしたい可能性のある場所に注釈を付け、さらに、エージェントの異なる可能な実行経路を検索するために使用される戦略(検索戦略)に有用な情報を記録することだけです。その後、検索戦略を個別に指定できます。EnCompassが提供する既製の戦略を使うことも、必要に応じて独自のカスタム検索戦略を実装することもできます。
「EnCompassでは、AIエージェントの基礎となるワークフローから検索戦略を分離しました」と、筆頭著者でMIT電気工学・コンピュータ科学(EECS)の博士課程学生、CSAIL研究員、Asari AIのリサーチコンサルタントでもあるZhening Li ’25, MEng ’25は言います。「私たちのフレームワークは、プログラマーがさまざまな検索戦略を簡単に試して、AIエージェントのパフォーマンスを最高にする戦略を見つけられるようにします。」 EnCompassは、LLMを呼び出すPythonプログラムとして実装されたエージェントに使用され、顕著なコード削減を示しました。EnCompassは、コードリポジトリを翻訳するエージェントやデジタルグリッドの変換規則を発見するエージェントなどにおいて、検索を実装するためのコーディング作業を最大80%削減しました。将来的には、EnCompassは、大規模なコードライブラリの管理、科学実験の設計と実行、ロケットやその他のハードウェアの設計図の作成など、大規模なタスクにエージェントが取り組むことを可能にするかもしれません。
エージェントをプログラミングする際、結果が変動する可能性のある特定の操作(LLMへの呼び出しなど)に印を付けます。これらの注釈は「分岐点」と呼ばれます。もしあなたのエージェントプログラムが物語の単一の筋書きを生成すると想像するなら、分岐点を追加することは、その物語を「自分で選ぶアドベンチャー」ゲームに変えることです。分岐点は、筋書きが複数の将来の筋書きに分岐する場所です。
その後、EnCompassがその物語ゲームをナビゲートし、可能な限り最良の結末を探すために使用する戦略を指定できます。これには、実行の並列スレッドを起動したり、行き詰まったときに前の分岐点にバックトラックしたりすることが含まれます。ユーザーはまた、EnCompassが提供するいくつかの一般的な検索戦略をそのままプラグアンドプレイで使用したり、独自のカスタム戦略を定義したりできます。例えば、探索と活用のバランスを取りながら探索木を構築するモンテカルロ木探索や、各ステップで最良の数個の出力を保持するビームサーチを選択できます。EnCompassは、タスクを成功裏に完了する可能性を最大化する最良の戦略を見つけるために、異なるアプローチを簡単に試すことを可能にします。
EnCompassのコーディング効率
では、エージェントプログラムに検索を追加する際のEnCompassのコード効率はどれほどなのでしょうか?研究者たちの調査結果によると、このフレームワークは、プログラマーがエージェントプログラムに検索を追加するために追加する必要があったコード量を大幅に削減し、最良のパフォーマンスを発揮する戦略を見つけるために異なる戦略を試すのを助けました。例えば、研究者たちはEnCompassを、アプリや企業ソフトウェアのプログラミングによく使われるJavaプログラミング言語からPythonへのコードリポジトリ翻訳エージェントに適用しました。その結果、EnCompassによる検索の実装(主に分岐点注釈と各ステップの良し悪しを記録する注釈の追加を含む)は、手動で実装するよりも348行少ないコード(約82%削減)で済むことを発見しました。また、EnCompassが異なる検索戦略を簡単に試すことを可能にし、最良の戦略が二段階のビームサーチアルゴリズムであることを特定したことも示しました。これは、検索を行わないエージェントが行うLLM呼び出しの16倍の検索予算で、5つの異なるリポジトリにわたって15%から40%の精度向上を達成しました。
「LLMが日常的なソフトウェアのより不可欠な部分になるにつれて、その長所を活用し、限界を回避するソフトウェアを効率的に構築する方法を理解することがより重要になります」と、共著者でMITのEECS教授およびCSAIL主任研究員であるArmando Solar-Lezamaは言います。「EnCompassはその方向への重要な一歩です。」
研究者たちはさらに、EnCompassは、プログラムが高レベルのワークフローのステップを指定するエージェントを対象としていると付け加えています。彼らのフレームワークの現在のイテレーションは、LLMによって完全に制御されるエージェントにはあまり適用できません。「それらのエージェントでは、ステップを指定するプログラムを持ち、その後LLMを使ってそれらのステップを実行する代わりに、LLM自体がすべてを決定します」とLiは言います。「基礎となるプログラム的なワークフローがないので、LLMがその場で発明するものに対して推論時の検索を実行できます。この場合、検索とバックトラックでプログラムの実行方法を変更するEnCompassのようなツールの必要性は低くなります。」
Liと彼の同僚たちは、EnCompassをAIエージェントのより一般的な検索フレームワークに拡張することを計画しています。また、企業を含む実世界での使用に向けて洗練させるために、より複雑なタスクで彼らのシステムをテストする予定です。さらに、EnCompassが、ハードウェア設計のブレインストーミングやはるかに大規模なコードライブラリの翻訳などのタスクで、エージェントが人間と協力するのをどれだけよく助けるかを評価しています。今のところ、EnCompassは、人間がAIエージェントをより簡単に調整し、そのパフォーマンスを向上させることを可能にする強力な構成要素です。
「AI駆動のエージェントと検索ベースの技術がソフトウェアエンジニアリングのワークフローを変え始めているちょうどその時、EnCompassはタイムリーに登場します」と、この研究に関与していないカーネギーメロン大学のYiming Yang教授は言います。
原文を表示
Press Inquiries Press Contact:
Close
Caption: When EnCompass runs a program, it will automatically backtrack if LLMs make mistakes. EnCompass can also make clones of the program runtime to make multiple attempts in parallel in search of the best solution. Credits: Image: Alex Shipps/MIT CSAIL Previous image Next image
Whether you’re a scientist brainstorming research ideas or a CEO hoping to automate a task in human resources or finance, you’ll find that artificial intelligence tools are becoming the assistants you didn’t know you needed. In particular, many professionals are tapping into the talents of semi-autonomous software systems called AI agents, which can call on AI at specific points to solve problems and complete tasks. AI agents are particularly effective when they use large language models (LLMs) because those systems are powerful, efficient, and adaptable. One way to program such technology is by describing in code what you want your system to do (the “workflow”), including when it should use an LLM. If you were a software company trying to revamp your old codebase to use a more modern programming language for better optimizations and safety, you might build a system that uses an LLM to translate the codebase one file at a time, testing each file as you go. But what happens when LLMs make mistakes? You’ll want the agent to backtrack to make another attempt, incorporating lessons it learned from previous mistakes. Coding this up can take as much effort as implementing the original agent; if your system for translating a codebase contained thousands of lines of code, then you’d be making thousands of lines of code changes or additions to support the logic for backtracking when LLMs make mistakes.
To save programmers time and effort, researchers with MIT’s Computer Science and Artificial Intelligence Laboratory (CSAIL) and Asari AI have developed a framework called “EnCompass.”
With EnCompass, you no longer have to make these changes yourself. Instead, when EnCompass runs your program, it automatically backtracks if LLMs make mistakes. EnCompass can also make clones of the program runtime to make multiple attempts in parallel in search of the best solution. In full generality, EnCompass searches over the different possible paths your agent could take as a result of the different possible outputs of all the LLM calls, looking for the path where the LLM finds the best solution. Then, all you have to do is to annotate the locations where you may want to backtrack or clone the program runtime, as well as record any information that may be useful to the strategy used to search over the different possible execution paths of your agent (the search strategy). You can then separately specify the search strategy — you could either use one that EnCompass provides out of the box or, if desired, implement your own custom search strategy.
“With EnCompass, we’ve separated the search strategy from the underlying workflow of an AI agent,” says lead author Zhening Li ’25, MEng ’25, who is an MIT electrical engineering and computer science (EECS) PhD student, CSAIL researcher, and research consultant at Asari AI. “Our framework lets programmers easily experiment with different search strategies to find the one that makes the AI agent perform the best.” EnCompass was used for agents implemented as Python programs that call LLMs, where it demonstrated noticeable code savings. EnCompass reduced coding effort for implementing search by up to 80 percent across agents, such as an agent for translating code repositories and for discovering transformation rules of digital grids. In the future, EnCompass could enable agents to tackle large-scale tasks, including managing massive code libraries, designing and carrying out science experiments, and creating blueprints for rockets and other hardware.
When programming your agent, you mark particular operations — such as calls to an LLM — where results may vary. These annotations are called “branchpoints.” If you imagine your agent program as generating a single plot line of a story, then adding branchpoints turns the story into a choose-your-own-adventure story game, where branchpoints are locations where the plot branches into multiple future plot lines.
You can then specify the strategy that EnCompass uses to navigate that story game, in search of the best possible ending to the story. This can include launching parallel threads of execution or backtracking to a previous branchpoint when you get stuck in a dead end. Users can also plug-and-play a few common search strategies provided by EnCompass out of the box, or define their own custom strategy. For example, you could opt for Monte Carlo tree search, which builds a search tree by balancing exploration and exploitation, or beam search, which keeps the best few outputs from every step. EnCompass makes it easy to experiment with different approaches to find the best strategy to maximize the likelihood of successfully completing your task.
The coding efficiency of EnCompass
So just how code-efficient is EnCompass for adding search to agent programs? According to researchers’ findings, the framework drastically cut down how much programmers needed to add to their agent programs to add search, helping them experiment with different strategies to find the one that performs the best. For example, the researchers applied EnCompass to an agent that translates a repository of code from the Java programming language, which is commonly used to program apps and enterprise software, to Python. They found that implementing search with EnCompass — mainly involving adding branchpoint annotations and annotations that record how well each step did — required 348 fewer lines of code (about 82 percent) than implementing it by hand. They also demonstrated how EnCompass enabled them to easily try out different search strategies, identifying the best strategy to be a two-level beam search algorithm, achieving an accuracy boost of 15 to 40 percent across five different repositories at a search budget of 16 times the LLM calls made by the agent without search.
“As LLMs become a more integral part of everyday software, it becomes more important to understand how to efficiently build software that leverages their strengths and works around their limitations,” says co-author Armando Solar-Lezama, who is an MIT professor of EECS and CSAIL principal investigator. “EnCompass is an important step in that direction.”
The researchers add that EnCompass targets agents where a program specifies the steps of the high-level workflow; the current iteration of their framework is less applicable to agents that are entirely controlled by an LLM. “In those agents, instead of having a program that specifies the steps and then using an LLM to carry out those steps, the LLM itself decides everything,” says Li. “There is no underlying programmatic workflow, so you can execute inference-time search on whatever the LLM invents on the fly. In this case, there’s less need for a tool like EnCompass that modifies how a program executes with search and backtracking.”
Li and his colleagues plan to extend EnCompass to more general search frameworks for AI agents. They also plan to test their system on more complex tasks to refine it for real-world uses, including at companies. What’s more, they’re evaluating how well EnCompass helps agents work with humans on tasks like brainstorming hardware designs or translating much larger code libraries. For now, EnCompass is a powerful building block that enables humans to tinker with AI agents more easily, improving their performance.
“EnCompass arrives at a timely moment, as AI-driven agents and search-based techniques are beginning to reshape workflows in software engineering,” says Carnegie Mellon University Professor Yiming Yang, who wasn’t involved in the research. “By cleanly separating an agent’s programming logic from its inference-time search strategy, the framework offers a principled way to explore how structured search can enhance code generation, translation, and analysis. This abstraction provides a solid foundation for more systematic and reliable search-driven approaches to software development.”
Li and Solar-Lezama wrote the paper with two Asari AI researchers: Caltech Professor Yisong Yue, an advisor at the company; and senior author Stephan Zheng, who is the founder and CEO. Their work was supported by Asari AI. The team’s work was presented at the Conference on Neural Information Processing Systems (NeurIPS) in December.
Share this news article on:
Paper: “EnCompass: Enhancing Agent Programming with Search Over Program Execution Paths” Related Links
Armando Solar-Lezama
Computer Science and Artificial Intelligence Laboratory (CSAIL)
Department of Electrical Engineering and Computer Science (EECS)
School of Engineering
MIT Schwarzman College of Computing
Human-computer interaction
Programming languages
Artificial intelligence
Machine learning
Computer science and technology
Electrical engineering and computer science (EECS)
Computer Science and Artificial Intelligence Laboratory (CSAIL)
School of Engineering
MIT Schwarzman College of Computing
Related Articles
Enabling small language models to solve complex reasoning tasks

関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み