openai/openai-agents-js

A lightweight, powerful framework for multi-agent workflows and voice agents

openai/openai-agents-js

What it does LLM を呼び出力の呼び出し、ツールの使用、セーフティルールの適用、エージェント間の作業引き継ぎ、会話履歴の保持が可能なマルチエージェントワークフローを構築するための JavaScript/TypeScript SDK を提供します。OpenAI API と連携し、プロバイダーに依存しない仕組みです。

How it works (core concepts)

  • Agent – 指示、ツール、ガードレール、ハンドオフを設定した LLM。
  • Sandbox Agent – ファイルシステムのワークスペースとペアになったエージェント(ベータ)。長時間実行タスクに使用。
  • Realtime Agent – ブラウザでの音声インタラクション向け低レイテンシエージェント。
  • Agents as tools / Handoffs – サブタスクを他のエージェントに委任。
  • Tools – エージェントがアクションを実行できる関数、MCP、またはホスト型ツール。
  • Guardrails – 入力と出力に対する設定可能な安全チェック。
  • Human in the loop – 実行中に人間を関与させる組み込みメカニズム。
  • Sessions – 会話履歴の自動管理。
  • Tracing – 各実行を追跡し、デバッグと最適化に利用。

Key features

  • テキスト、サンドボックス、リアルタイムエージェントの種類。
  • ツール統合、ガードレール、ハンドオフ、セッション、トレース。
  • Node.js ≥ 22、Deno、Bun で動作;Cloudflare Workers の実験的サポート。
  • @openai/agentszod がスキーマ検証に必要。

Supported environments

  • Node.js 22 以降
  • Deno
  • Bun
  • 実験的:nodejs_compat が有効な Cloudflare Workers

Getting started

npm install @openai/agents zod

Text agent example

import { Agent, run } from '@openai/agents';
const agent = new Agent({ name: 'Assistant', instructions: 'You are a helpful assistant.' });
const result = await run(agent, 'Write a haiku about recursion in programming.');
console.log(result.finalOutput);

Sandbox agent example (macOS/Linux)

import { run } from '@openai/agents';
import { gitRepo, SandboxAgent } from '@openai/agents/sandbox';
import { UnixLocalSandboxClient } from '@openai/agents/sandbox/local';

const agent = new SandboxAgent({
  name: 'Workspace Assistant',
  model: 'gpt-5.5',
  instructions: 'Inspect the repo before changing files.',
  defaultManifest: { entries: { repo: gitRepo({ repo: 'openai/openai-agents-js' }) } },
});

const result = await run(
  agent,
  'Inspect the repo README and summarize what this project does.',
  { sandbox: { client: new UnixLocalSandboxClient() } }
);
console.log(result.finalOutput);

Realtime agent example (browser)

import { RealtimeAgent, RealtimeSession } from '@openai/agents/realtime';
const agent = new RealtimeAgent({ name: 'Assistant', instructions: 'You are a helpful assistant.' });
const session = new RealtimeSession(agent);
await session.connect({ apiKey: '<client-api-key>' });

Set OPENAI_API_KEY for text/sandbox agents; for browser realtime agents obtain a short‑lived token from your server.

Limitations (as noted in README)

  • Sandbox Agents はベータ版です;Windows では DockerSandboxClient またはホスト型サンドボックスクライアントを使用する必要があります。
  • Realtime agents はブラウザ/WebRTC のセットアップが必要です。
  • Cloudflare Workers のサポートは実験的で、nodejs_compat が必要です。
  • README にはパフォーマンスベンチマークや記載されている機能を超える本番環境での保証については言及されていません。

関連

  • プロジェクト
  • プロジェクト
  • Dispatch
  • プロジェクト
  • プロジェクト