CursorのエージェントをOpenAI Codexモデル向けに改善
CursorはOpenAIの最新コーディングモデルGPT-5.1-Codex-Max向けにエージェントハーネスを更新し、シェル指向のワークフローに適応させつつツール呼び出しを促進する改良を加えた。
キーポイント
OpenAI Codexモデル向けエージェントハーネスの更新
CursorはOpenAIと協力して最新のGPT-5.1-Codex-Maxモデルに対応するため、エージェントハーネスを更新し、モデルの出力品質向上とツール呼び出しの効率化を図った。
シェル指向アプローチへの適応
OpenAIのCodex CLIがシェル指向ワークフローに焦点を当てているため、Cursorはツール名と定義をシェル相当のものに近づけ、ツール呼び出しを優先させるように設計を調整した。
セキュリティとユーザー体験の向上
サンドボックス機能により未承認のファイルアクセスやネットワーク活動を防止し、モデルがシェルコマンドを実行する場合でもセキュリティを確保するとともに、ツール呼び出しによる編集作業のユーザー体験を改善した。
モデル評価と最適化プロセス
Cursorは内部評価スイート「Cursor Bench」を使用してモデルの成功率、ツール呼び出し能力、ユーザー採用率を測定し、各モデルに最適な指示とツールを統合している。
Reasoning Tracesの重要性
Codexモデルはreasoning traces(推論トレース)に特に依存しており、これが失われるとパフォーマンスが30%低下する。Cursorではreasoning tracesを常に保存・転送するアラートを追加し、エージェントの内部計画を維持している。
ツール使用のバイアス調整
Codexモデルにツール定義だけ提供してもread_lintsツールを呼び出す傾向が弱いため、具体的な指示(実質的な編集後に最近編集したファイルのlinterエラーをチェックするなど)を追加して行動を促している。
エージェントの行動原則
ユーザーが明示的に計画やコード不要の意図を示さない限り、コード変更やツール実行で問題解決を実施すべきであり、提案だけでなく実際に実装する必要がある。
影響分析・編集コメントを表示
影響分析
この記事は、AIコーディングツールの実用化において、基盤モデルとエージェントフレームワークの連携が重要であることを示している。特定のモデル特性に合わせたハーネスの最適化が、開発者体験とセキュリティの両立を可能にする実践的なアプローチを提供している。
編集コメント
AIコーディングツールの進化において、基盤モデルとエージェントフレームワークの緊密な連携が性能向上の鍵となることを示す具体例。実用性とセキュリティのバランスを考慮した設計思想が参考になる。
Cursorは、コーディング用のあらゆる最先端AIモデルと統合しています。
各モデルは、出力品質の向上、モデルの「怠惰」の防止、ツールの効率的な呼び出しなどを実現するために、当社のエージェントハーネスに対し、固有の指示と調整を必要とします。
当社は、開発者がCursorのエージェントを通じてOpenAIモデルを利用できるよう、OpenAIと連携してきました。本記事では、彼らの最新の最先端コーディングモデルGPT-5.1-Codex-Maxをサポートするため、エージェントハーネスをどのように更新したかについて説明します。
#堅牢なエージェントハーネスの構築
Cursorのエージェントハーネス内の各モデルには、Cursor環境下でそのモデルの性能を最適化するために用意された、固有の指示とツールがあります。
AI研究所は、多様な指示とツールを用いて新モデルを学習させます。コーディングのような特定領域では、モデルは学習時に見たパターンに近い形式を好む傾向があります。新モデルをCursorに統合する際、当社の役割は、Cursor固有の指示・ツールと、モデルにとって馴染み深い指示・ツールとを組み合わせ、さらに内部評価スイートであるCursor Benchに基づいて調整することです。
当社は、モデルの品質と堅牢性を、成功率、ツール呼び出し能力、ユーザー全体での採用状況に基づいて測定しています。以下は、Codex向けにエージェントハーネスに行った更新の一部です。
#最新Codexモデルへの対応
OpenAIのCodexモデルは、エージェント型コーディング向けに特別に学習された、彼らの最新最先端モデルのバリエーションです。
OpenAIチームは、ツールとプロンプトをCodex CLIハーネスに適合させるため、当社と緊密に協力しました。以下が当社が実施した変更の一部です:
#よりシェル指向のアプローチ
OpenAIのCodex CLIは、シェル中心のワークフローに重点を置いています。その結果、Codexモデルは学習中に限られたツールセットのみを与えられ、代わりにシェルを使って検索、ファイル読み込み、編集を行うことを学びます。
モデルが難しい編集に苦戦する場合、インラインPythonスクリプトを使ってファイルを書き出すことに頼ることがあります。これらのスクリプトは強力ですが、Cursor内での編集においては、ツール呼び出しの方がより安全で、ユーザー体験も優れています。
ツール呼び出しを促すため、当社はCursor内のツール名と定義を、rgなどのシェルにおける同等の操作に近づけました。
ある操作に対応するツールが存在する場合は、シェルコマンド(例: cat)ではなく、ツール(例: read_file)の使用を優先してください。
Cursorのサンドボックス化(ユーザーによる個別のコマンド承認を必要とせず、不正なファイルアクセスやネットワーク活動を防止する)も、モデルが依然としてシェルコマンドの実行を選択した場合のセキュリティ向上に寄与します。
主力のGPT-5シリーズのモデルとは異なり、Codexモデルファミリーは現在、作業中のユーザーへの進捗報告に推論サマリーを使用します。これは1行の見出し形式でも、完全なメッセージ形式でもあり得ます。
これらの推論サマリーについては、ユーザーがエージェントの進捗を追え、不適切な方向性を早期に察知できる一方で、煩雑すぎてユーザーが無視するほど大量にならない、バランスの取れた表現を目指しました。当社はモデルに対し、推論サマリーを1〜2文に制限し、新情報を発見した時や新たな戦術を開始する時にのみ記述し、自身のコミュニケーション行為についての言及(「ユーザーに説明しています…」など)を避けるようガイドラインを与えました。
Codexモデルはエージェントターンが終了するまで通常の「会話」ができないため、ターン途中でのユーザーとのコミュニケーションに関連する記述をすべてプロンプトから削除しました。これにより、モデルの最終的なコード出力の品質が向上することが確認されました。
Cursorは、リンターエラー(例: ESLint、Biome)を読み取り、エージェントが自動的に修正できるツールを、ハーネス内の全モデルに提供しています。
当社は、Codexに単にツール定義を提供するだけでは、read_lintsツールを呼び出す傾向が十分に生まれないことを発見しました。
実質的な編集を行った後は、read_lintsツールを使用して、最近編集したファイルにリンターエラーがないか確認してください。エラーを導入してしまった場合は、簡単に修正方法が分かるのであれば修正してください。
#推論トレースの保持
OpenAIの推論モデルは、ツール呼び出しの合間に内部推論トレースを出力します。これは、モデルが各アクションを選択する理由を説明する「思考の連鎖」に相当します。Responses APIは、これらの推論アイテム(または機密コンテキストでは暗号化された推論アイテム)を捕捉・伝達するように設計されており、モデルがターンを跨いで一貫性を保ち、計画を一から再構築する必要がなくなります。
Codexは特にこの一貫性に依存しています。推論トレースが失われると、モデルは自身の以前の思考プロセスを推測しなければならず、その結果、サブゴールの見失い、計画の質の低下、ツール呼び出し順序の誤り、あるいは以前のステップの繰り返し再導出が頻繁に発生します。当社のCursor Bench実験では、GPT-5-Codexから推論トレースを除去すると、パフォーマンスが30%低下しました。比較として、OpenAIは、推論トレースが省略された場合のGPT-5のSWE-benchにおける性能低下は3%のみであったと報告しています。
この影響の大きさを考慮し、当社は推論トレースが常に正しく保持・転送されることを保証するアラート機能を追加しました。これにより、エージェントの内部計画が維持され、モデルがツール呼び出し間の「空白を埋めねばならない」状況で生じるパフォーマンスの後退を防ぎます。
#モデルに積極的な行動を促す
Cursorのデフォルトエージェントモードでは、エージェントがユーザーの要求に基づき自律的にファイルを読み書きすることをユーザーは期待します。タブを離れた後に戻ると、エージェントが進行許可を待機していただけだったと気付くのは、苛立たしい体験です。
当社は、Codexを導くため、より具体的な指示を用いた実験を進めています:
ユーザーが明示的に計画の提示を求めたり、コードを書くべきでない意図を明確に示したりしない限り、ユーザーはコード変更やツール実行によって問題を解決してほしいと想定してください。このような場合、提案された解決策を単にメッセージとして出力するのは望ましくなく、実際に変更を実装すべきです。困難や障害に遭遇した場合は、自身で解決を試みてください。
非同期リモートワークフローであるCloud Agentsでは、この指示をさらに強くしています。
#メッセージ順序
OpenAIモデルは、メッセージの順序を尊重し、優先するように学習されています。例えば、システムプロンプトは常にユーザーメッセージよりも優先されます。
これは有用ですが、Cursorが提供するプロンプトが、ユーザーメッセージと矛盾する可能性のある指示を含まないよう、ハーネスを調整する必要があることを意味します。そうしないと、Codexはユーザー要求に従うことを躊躇う可能性があります。
例えば、ある時点で当社はCodexに対し、トークンを節約し無駄遣いしないよう注意するよう伝えました。しかし、このメッセージがモデルの野心的なタスクへの取り組みや大規模な探索の実行意欲に影響を与えていることに気付きました。時折、モデルは停止し、「トークンを無駄にするべきではないので、このタスクを続ける価値はないと思います!」と頑なに主張することがありました。
#今後の展望
モデルリリースのペースは加速しています。当社の目標は、Cursorエージェントハーネス内で、あらゆる最先端モデルから最大の価値を引き出すことです。やるべきことはまだ多くあり、Cursorに対して行っている改良について、これからも共有を続けていきます。
原文を表示
Cursor integrates with all frontier AI models for coding.
Each model requires specific instructions and tweaks to our agent harness to improve output quality, prevent laziness, efficiently call tools, and more.
We’ve been partnering with OpenAI to make their models available to developers with Cursor’s agent. This post will cover how we’ve updated our agent harness to support their latest frontier coding model GPT-5.1-Codex-Max
#Building a robust agent harness
Every model in Cursor’s agent harness has specific instructions and tools made available to optimize that model inside the Cursor environment.
AI labs train new models on a variety of different instructions and tools. In specific domains like coding, models may favor patterns that are more similar to what they’ve already seen in training. When adding new models into Cursor, our job is to integrate familiar instructions and tools alongside Cursor-specific ones, and then tune them based on Cursor Bench, our internal suite of evals.
We measure the quality and robustness of models based on their success rate, ability to call tools, and overall adoption across users. Here are some of the updates we made to our agent harness for Codex.
#Updating for the latest Codex model
OpenAI’s Codex models are versions of their latest frontier model, trained specifically for agentic coding.
The OpenAI team collaborated closely with us to align the tools and prompts with the Codex CLI harness. Here are some of the changes we’ve made:
#A more shell-forward approach
OpenAI’s Codex CLI is focused on shell-oriented workflows. As a result, the Codex model receives a limited set of tools during training and learns instead to use the shell to search, read files, and make edits.
If the model is struggling with a difficult edit, it sometimes falls back to writing files using an inline Python script. These scripts are powerful, but tool calling is both safer and a better user experience for edits in Cursor.
To encourage tool calling, we made the names and definitions of tools in Cursor closer to their shell equivalents like rg
If a tool exists for an action, prefer to use the tool instead of shell commands (e.g. read_file over cat).
Sandboxing in Cursor, which prevents unauthorized file access and network activity without requiring users to manually approve every command, also helps improve security here if the model does still choose to run a shell command.
Unlike the mainline GPT-5 series of models, the Codex model family currently uses reasoning summaries to communicate user updates as it’s working. These can be in the form of one-line headings or a full message.
For these reasoning summaries, we wanted to strike a balance that would let users follow along with the agent’s progress and identify bad trajectories early, without spamming them to the point that they tune out. We gave the model guidelines to limit reasoning summaries to 1 or 2 sentences, note when discovering new information or initiating a new tactic, and to avoid commenting on its own communication (“I’m explaining to the user…”).
Since Codex models cannot “talk” normally until the end of an agent turn, we removed all language in the prompt related to communicating with the user mid-turn. We found that this improved the performance of the model’s final code output.
Cursor makes tools available to all models in our harness for reading linter errors (e.g. ESLint, Biome) and allowing the agent to automatically fix them.
We found that providing Codex with the tool definition alone is not enough to make it inclined to call our read_lints
After substantive edits, use the read_lints tool to check recently edited files for linter errors. If you've introduced any, fix them if you can easily figure out how.
#Preserving reasoning traces
OpenAI’s reasoning models emit internal reasoning traces between tool calls, which are effectively a “chain of thought” explaining why the model chooses each action. The Responses API is designed to capture and pass along these reasoning items (or encrypted reasoning items in sensitive contexts) so the model can maintain continuity across turns rather than having to reconstruct its plan from scratch.
Codex is especially dependent on this continuity. When reasoning traces are dropped, the model has to infer its previous thought process, which often leads to lost subgoals, degraded planning, misordered tool calls, or repeatedly re-deriving earlier steps. In our Cursor Bench experiments, removing reasoning traces from GPT-5-Codex caused a 30% performance drop. In comparison, OpenAI observed a smaller 3% degradation for GPT-5 on SWE-bench when reasoning traces were omitted.
Given the scale of that impact, we added alerting to ensure that reasoning traces are always preserved and forwarded correctly. This keeps the agent’s internal plan intact and prevent the performance regressions that occur when models are forced to “fill in the blanks” between tool calls.
#Biasing the model to take action
In Cursor's default agent mode, you want the agent to autonomously read and edit files based on the user request. It can be frustrating when you tab away only to find that the agent was waiting to ask for your permission to proceed.
We’ve been experimenting with more specific instructions to help guide Codex:
Unless the user explicitly asks for a plan or some other intent that makes it clear that code should not be written, assume the user wants you to make code changes or run tools to solve the user's problem. In these cases, it's bad to output your proposed solution in a message, you should go ahead and actually implement the change. If you encounter challenges or blockers, you should attempt to resolve them yourself.
In Cloud Agents, our async remote workflow, we make this language even stronger.
#Message ordering
OpenAI models are trained to respect and prioritize message ordering. For example, the system prompt always takes precedence over user messages and tool results.
While this is helpful, it means we need to tune our harnesses to ensure the Cursor-provided prompt does not include instructions which could accidentally contradict user messages. Otherwise, Codex could get into a state where it does not want to comply with the user request.
For example, at one point we told Codex that it should take care to preserve tokens and not be wasteful. But we noticed that this message was impacting the model’s willingness to perform more ambitious tasks or large-scale explorations. Sometimes it would stop and stubbornly say, I’m not supposed to waste tokens, and I don’t think it’s worth continuing with this task!
#Looking forward
The pace of model releases is increasing. Our goal is to get the most out of every frontier model inside the Cursor agent harness. There’s more work to be done, and we’ll continue to share improvements we’re making to Cursor.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み