GPT-5.6のProgrammatic Tool Callingとは?function callingとの違い・使い方・注意点
GPT-5.6のProgrammatic Tool Callingを初心者向けに解説。通常のfunction callingとの違い、isolated V8 runtime、allowed_callers、MCP・shell対応、ZDR、向く処理、承認が必要な操作で使わない理由を整理します。
公開 2026.07.10 / 更新 2026.07.10
この記事のポイント
- modelがisolated V8でJavaScriptを実行し、parallel call・loop・condition・中間結果処理を組み立てる
- direct / programmatic / bothをallowed_callersでtoolごとに制御する
- write・approval-sensitive action・citation・native artifactの最終確認はdirectを基本にし、代表taskでbaseline比較する
一言でいうと:toolの呼び出し手順を、modelがJavaScriptで組み立てる
Programmatic Tool Callingは、Responses API request内でmodelがJavaScriptを生成・実行し、複数toolの呼び出し、parallel処理、loop、condition、中間結果の絞り込みを組み立てる仕組みです。通常のfunction callingを無条件に置き換えるものではなく、予測可能なcontrol flowを小さなstructured resultへ縮約できるstageで使います。
| API model ID | 位置づけ | 入力 / 1M tokens | 出力 / 1M tokens | 主な選び方 |
|---|---|---|---|---|
| gpt-5.6-sol(alias: gpt-5.6) | flagship | $5 | $30 | 難しい推論・coding・品質優先 |
| gpt-5.6-terra | 性能と費用の均衡 | $2.50 | $15 | 日常のproduction workflow |
| gpt-5.6-luna | 高速・低コスト | $1 | $6 | 大量・低遅延・費用重視 |
direct tool callingとの違い
| task形状 | 推奨 | 理由 |
|---|---|---|
| 単発lookup / action | direct | programを挟む必要がない |
| filter・join・rank・dedupe・aggregate・validate | programmatic | 大量の中間結果を小さくできる |
| 予測可能な依存call | programmatic | 後続argumentと停止条件をcodeで表せる |
| 検索結果ごとに意味判断 | direct | 各結果をmodelが読み直す必要がある |
| write / approval-sensitive action | directを基本 | 明確なauthorization boundaryを残す |
| citation / native artifactの最終確認 | directを基本 | 元のevidenceやartifactを保つ |
isolated V8 runtimeでできること・できないこと
| できる | できない | 外部へ触る方法 |
|---|---|---|
| JavaScript、top-level await、parallel、loop、condition、中間結果処理 | Node.js、package install、direct network、general filesystem、subprocess、console、persistent JS state | requestで許可されたtoolsだけを使う |
| text(...) / image(...)で出力 | 任意の環境変数やlocal fileへ直接アクセス | function、custom、MCP、apply_patch、shell、code_interpreterなど対応tool経由 |
programmatic_tool_callingとallowed_callers
| allowed_callers | 動作 | 使いどころ |
|---|---|---|
| 省略 / ["direct"] | modelがtoolを直接call | 単発、承認、意味判断 |
| ["programmatic"] | program item内のcodeだけがcall | boundedな集約stage |
| ["direct", "programmatic"] | どちらからもcall可能 | stageごとのroutingをpromptで明確にする |
const response = await client.responses.create({
model: "gpt-5.6-terra",
input: "複数店舗の在庫を比較し、欠品候補だけをJSONで返してください。",
tools: [
{
type: "function",
name: "get_inventory",
description: "店舗別の在庫数を返す",
parameters: {
type: "object",
properties: { store_id: { type: "string" } },
required: ["store_id"],
additionalProperties: false
},
output_schema: {
type: "object",
properties: { store_id: { type: "string" }, units: { type: "number" } },
required: ["store_id", "units"],
additionalProperties: false
},
allowed_callers: ["programmatic"]
},
{ type: "programmatic_tool_calling" }
]
});この例は最小構成です。application側はclient-owned function callを実行し、call_idとcallerの関係を保って結果を返し、program_outputまたは最終messageまで継続する必要があります。generated JavaScriptを自分のNode.js processで実行する設計ではありません。
supported tools・MCP approval・ZDR
- programmatic callerに対応する主なtool typeはfunction / custom、MCP、apply_patch、local / hosted shell、code_interpreter
- MCPのrequire_approvalはprogramを停止して人間承認を待てる
- ZDRはorganizationまたはprojectで有効化が必要で、store: falseだけではZDRにならない
- model、tools、third-party servicesを含むrequest全体のretention条件を確認する
- OpenAI-hosted toolも個別のdata retentionとsecurity guidanceを見る
multi-agentとの違い
Programmatic Tool Callingは一つのmodel response内でcodeがtoolをorchestrateする仕組みです。Responses APIのmulti-agent betaは、複数subagentを並列に動かして結果を統合する仕組みです。ultraに近い並列分担と、toolのfilter・join処理を同じものとして扱わないでください。
retry・stop条件と安全境界
- programを使うbounded stageと利用toolを明示する
- 必要なresult shapeとevidenceを定義する
- stop conditionとretry上限を先に決める
- 完了済みcallを繰り返さない
- side effectをprogrammatic stageへ混ぜない
- 高影響actionはapplication-level approvalを必須にする
- argumentとpermissionをapplication側でも検証する
baseline比較で見る指標
Programmatic Tool Callingは中間tool出力をmodel contextへ戻す量を減らせますが、token削減や高速化をすべてのtaskで断定できません。direct tool callingをbaselineにし、代表taskで正確性、完全性、evidence、input / total tokens、latency、cost、tool call、retry、安全性を比較します。
prompt cachingとの費用境界
GPT-5.6以降はcache writeがuncached inputの1.25倍、cache readは90%割引です。explicit cache breakpointと最低30分のcache lifeを使えますが、1回しか再利用しない長文を毎回writeすると得とは限りません。Programmatic Tool Callingの効果とcachingの効果を分けて計測します。
Programmatic Tool Calling FAQ
通常のfunction callingより常に優れていますか?
いいえ。単発call、意味判断、write、承認、citationやnative artifactの最終確認はdirectが向きます。予測可能な集約stageで比較します。
generated JavaScriptはNode.jsで動きますか?
いいえ。OpenAIがfresh isolated V8 runtimeで実行し、Node.js、package install、direct network、general filesystem、subprocess、console、persistent stateは提供されません。
store: falseならZDRですか?
それだけではZDRになりません。organization / projectでZDRが有効か、model・tool・third-party serviceを含むrequest全体が対象か確認します。
MCP toolも呼べますか?
対応します。allowed_callersでprogrammaticを許可し、require_approvalが設定されたMCP callは承認待ちでprogramを停止できます。
tokenは必ず減りますか?
必ずとは言えません。directをbaselineにし、代表taskで品質、evidence、token、latency、cost、retry、安全性を比較します。
関連記事
- GPT-5.6 Sol・Terra・Lunaの料金比較|API・Work・Codexのモデル選び
GPT-5.6はSolだけを見ると高く見えますが、TerraとLunaを作業別に分けると設計しやすくなります。重要なのは1回の単価より、出力量、再試行、キャッシュ、検証コストです。
- MCPとは?AIエージェントに外部ツールをつなぐ仕組みと注意点
MCPとは、AIエージェントに外部ツールやデータソースへの窓口を持たせる仕組みです。便利になるほど、渡す権限の設計が重要になります。
- MCPの権限はどこまで許可する?AIエージェント連携を安全に始める最小権限ガイド
MCPはAIが使える道具を増やす仕組みです。便利さの前に、読み取り・書き込み・削除・外部送信を分けます。
- AI API料金はなぜ増える?トークン・長文コンテキスト・リトライ・ループの基本
AI API料金は実行回数だけではありません。長文コンテキスト、履歴、リトライ、ループで増える仕組みを初心者向けに整理します。
- AI API課金事故を防ぐチェックリスト|APIキーを入れる前に見る料金・上限・ログ
APIキーを貼る前に、料金ページ、usage、limits、billing、ログを確認するための実用チェックリストです。