@openai/agents 0.5.2 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,35 +1,27 @@
1
1
  # OpenAI Agents SDK (JavaScript/TypeScript)
2
2
 
3
+ [![npm version](https://badge.fury.io/js/@openai%2Fagents.svg)](https://badge.fury.io/js/@openai%2Fagents)
4
+ [![CI](https://github.com/openai/openai-agents-js/actions/workflows/test.yml/badge.svg)](https://github.com/openai/openai-agents-js/actions/workflows/test.yml)
5
+
3
6
  The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows in JavaScript/TypeScript. It is provider-agnostic, supporting OpenAI APIs and more.
4
7
 
5
8
  <img src="https://cdn.openai.com/API/docs/images/orchestration.png" alt="Image of the Agents Tracing UI" style="max-height: 803px;">
6
9
 
10
+ > [!NOTE]
11
+ > Looking for the Python version? Check out [OpenAI Agents SDK Python](https://github.com/openai/openai-agents-python).
12
+
7
13
  ## Core concepts
8
14
 
9
- 1. **Agents**: LLMs configured with instructions, tools, guardrails, and handoffs.
10
- 2. **Handoffs**: Specialized tool calls for transferring control between agents.
11
- 3. **Guardrails**: Configurable safety checks for input and output validation.
12
- 4. **Tracing**: Built-in tracking of agent runs, allowing you to view, debug, and optimize your workflows.
13
-
14
- Explore the [`examples/`](examples/) directory to see the SDK in action.
15
-
16
- ## Supported Features
17
-
18
- - [x] **Multi-Agent Workflows**: Compose and orchestrate multiple agents in a single workflow.
19
- - [x] **Tool Integration**: Seamlessly call tools/functions from within agent responses.
20
- - [x] **Handoffs**: Transfer control between agents dynamically during a run.
21
- - [x] **Structured Outputs**: Support for both plain text and schema-validated structured outputs.
22
- - [x] **Streaming Responses**: Stream agent outputs and events in real time.
23
- - [x] **Tracing & Debugging**: Built-in tracing for visualizing and debugging agent runs.
24
- - [x] **Guardrails**: Input and output validation for safety and reliability.
25
- - [x] **Parallelization**: Run agents or tool calls in parallel and aggregate results.
26
- - [x] **Human-in-the-Loop**: Integrate human approval or intervention into workflows.
27
- - [x] **Realtime Voice Agents**: Build realtime voice agents using WebRTC or WebSockets
28
- - [x] **Local MCP Server Support**: Give an Agent access to a locally running MCP server to provide tools
29
- - [x] **Separate optimized browser package**: Dedicated package meant to run in the browser for Realtime agents.
30
- - [x] **Broader model support**: Use non-OpenAI models through the Vercel AI SDK adapter
31
- - [ ] **Long running functions**: Suspend an agent loop to execute a long-running function and revive it later <img src="https://img.shields.io/badge/Future-lightgrey" alt="Future" style="width: auto; height: 1em; vertical-align: middle;">
32
- - [ ] **Voice pipeline**: Chain text-based agents using speech-to-text and text-to-speech into a voice agent <img src="https://img.shields.io/badge/Future-lightgrey" alt="Future" style="width: auto; height: 1em; vertical-align: middle;">
15
+ 1. [**Agents**](https://openai.github.io/openai-agents-js/guides/agents): LLMs configured with instructions, tools, guardrails, and handoffs
16
+ 1. **[Agents as tools](https://openai.github.io/openai-agents-js/guides/tools/#4-agents-as-tools) / [Handoffs](https://openai.github.io/openai-agents-js/guides/handoffs/)**: Delegating to other agents for specific tasks
17
+ 1. [**Tools**](https://openai.github.io/openai-agents-js/guides/tools/): Various Tools let agents take actions (functions, MCP, hosted tools)
18
+ 1. [**Guardrails**](https://openai.github.io/openai-agents-js/guides/guardrails/): Configurable safety checks for input and output validation
19
+ 1. [**Human in the loop**](https://openai.github.io/openai-agents-js/guides/human-in-the-loop/): Built-in mechanisms for involving humans across agent runs
20
+ 1. [**Sessions**](https://openai.github.io/openai-agents-js/guides/sessions/): Automatic conversation history management across agent runs
21
+ 1. [**Tracing**](https://openai.github.io/openai-agents-js/guides/tracing/): Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows
22
+ 1. [**Realtime Agents**](https://openai.github.io/openai-agents-js/guides/voice-agents/quickstart/): Build powerful voice agents with full features
23
+
24
+ Explore the [`examples/`](https://github.com/openai/openai-agents-js/tree/main/examples) directory to see the SDK in action.
33
25
 
34
26
  ## Get started
35
27
 
@@ -39,7 +31,7 @@ Explore the [`examples/`](examples/) directory to see the SDK in action.
39
31
  - Deno
40
32
  - Bun
41
33
 
42
- Experimental support:
34
+ #### Experimental support:
43
35
 
44
36
  - Cloudflare Workers with `nodejs_compat` enabled
45
37
 
@@ -51,7 +43,7 @@ Experimental support:
51
43
  npm install @openai/agents zod
52
44
  ```
53
45
 
54
- ## Hello world example
46
+ ### Run your first agent
55
47
 
56
48
  ```js
57
49
  import { Agent, run } from '@openai/agents';
@@ -73,130 +65,7 @@ console.log(result.finalOutput);
73
65
 
74
66
  (_If running this, ensure you set the `OPENAI_API_KEY` environment variable_)
75
67
 
76
- ## Functions example
77
-
78
- ```js
79
- import { z } from 'zod';
80
- import { Agent, run, tool } from '@openai/agents';
81
-
82
- const getWeatherTool = tool({
83
- name: 'get_weather',
84
- description: 'Get the weather for a given city',
85
- parameters: z.object({ city: z.string() }),
86
- execute: async (input) => {
87
- return `The weather in ${input.city} is sunny`;
88
- },
89
- });
90
-
91
- const agent = new Agent({
92
- name: 'Data agent',
93
- instructions: 'You are a data agent',
94
- tools: [getWeatherTool],
95
- });
96
-
97
- async function main() {
98
- const result = await run(agent, 'What is the weather in Tokyo?');
99
- console.log(result.finalOutput);
100
- }
101
-
102
- main().catch(console.error);
103
- ```
104
-
105
- ## Handoffs example
106
-
107
- ```js
108
- import { z } from 'zod';
109
- import { Agent, run, tool } from '@openai/agents';
110
-
111
- const getWeatherTool = tool({
112
- name: 'get_weather',
113
- description: 'Get the weather for a given city',
114
- parameters: z.object({ city: z.string() }),
115
- execute: async (input) => {
116
- return `The weather in ${input.city} is sunny`;
117
- },
118
- });
119
-
120
- const dataAgent = new Agent({
121
- name: 'Data agent',
122
- instructions: 'You are a data agent',
123
- handoffDescription: 'You know everything about the weather',
124
- tools: [getWeatherTool],
125
- });
126
-
127
- // Use Agent.create method to ensure the finalOutput type considers handoffs
128
- const agent = Agent.create({
129
- name: 'Basic test agent',
130
- instructions: 'You are a basic agent',
131
- handoffs: [dataAgent],
132
- });
133
-
134
- async function main() {
135
- const result = await run(agent, 'What is the weather in San Francisco?');
136
- console.log(result.finalOutput);
137
- }
138
-
139
- main().catch(console.error);
140
- ```
141
-
142
- ## Voice Agent
143
-
144
- ```js
145
- import { z } from 'zod';
146
- import { RealtimeAgent, RealtimeSession, tool } from '@openai/agents-realtime';
147
-
148
- const getWeatherTool = tool({
149
- name: 'get_weather',
150
- description: 'Get the weather for a given city',
151
- parameters: z.object({ city: z.string() }),
152
- execute: async (input) => {
153
- return `The weather in ${input.city} is sunny`;
154
- },
155
- });
156
-
157
- const agent = new RealtimeAgent({
158
- name: 'Data agent',
159
- instructions: 'You are a data agent',
160
- tools: [getWeatherTool],
161
- });
162
-
163
- // Intended to run in the browser
164
- const { apiKey } = await fetch('/path/to/ephemeral/key/generation').then(
165
- (resp) => resp.json(),
166
- );
167
- // Automatically configures audio input/output — start talking
168
- const session = new RealtimeSession(agent);
169
- await session.connect({ apiKey });
170
- ```
171
-
172
- ## The agent loop
173
-
174
- When you call `Runner.run()`, the SDK executes a loop until a final output is produced.
175
-
176
- 1. The agent is invoked with the given input, using the model and settings configured on the agent (or globally).
177
- 2. The LLM returns a response, which may include tool calls or handoff requests.
178
- 3. If the response contains a final output (see below), the loop ends and the result is returned.
179
- 4. If the response contains a handoff, the agent is switched to the new agent and the loop continues.
180
- 5. If there are tool calls, the tools are executed, their results are appended to the message history, and the loop continues.
181
-
182
- You can control the maximum number of iterations with the `maxTurns` parameter.
183
-
184
- ### Final output
185
-
186
- The final output is the last thing the agent produces in the loop.
187
-
188
- 1. If the agent has an `outputType` (structured output), the loop ends when the LLM returns a response matching that type.
189
- 2. If there is no `outputType` (plain text), the first LLM response without tool calls or handoffs is considered the final output.
190
-
191
- **Summary of the agent loop:**
192
-
193
- - If the current agent has an `outputType`, the loop runs until structured output of that type is produced.
194
- - If not, the loop runs until a message is produced with no tool calls or handoffs.
195
-
196
- ### Error handling
197
-
198
- - If the maximum number of turns is exceeded, a `MaxTurnsExceededError` is thrown unless it is handled.
199
- - If a guardrail is triggered, a `GuardrailTripwireTriggered` exception is raised.
68
+ Explore the [`examples/`](https://github.com/openai/openai-agents-js/tree/main/examples) directory to see the SDK in action.
200
69
 
201
70
  ## Acknowledgements
202
71
 
@@ -210,4 +79,4 @@ We'd like to acknowledge the excellent work of the open-source community, especi
210
79
 
211
80
  We're committed to building the Agents SDK as an open source framework so others in the community can expand on our approach.
212
81
 
213
- For more details, see the [documentation](https://openai.github.io/openai-agents-js) or explore the [`examples/`](examples/) directory.
82
+ For more details, see the [documentation](https://openai.github.io/openai-agents-js) or explore the [`examples/`](https://github.com/openai/openai-agents-js/tree/main/examples) directory.
package/dist/metadata.js CHANGED
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.METADATA = void 0;
5
5
  exports.METADATA = {
6
6
  "name": "@openai/agents",
7
- "version": "0.5.2",
7
+ "version": "0.5.4",
8
8
  "versions": {
9
- "@openai/agents": "0.5.2",
9
+ "@openai/agents": "0.5.4",
10
10
  "@openai/agents-core": "workspace:*",
11
11
  "@openai/agents-openai": "workspace:*",
12
12
  "@openai/agents-realtime": "workspace:*",
package/dist/metadata.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  // This file is automatically generated
2
2
  export const METADATA = {
3
3
  "name": "@openai/agents",
4
- "version": "0.5.2",
4
+ "version": "0.5.4",
5
5
  "versions": {
6
- "@openai/agents": "0.5.2",
6
+ "@openai/agents": "0.5.4",
7
7
  "@openai/agents-core": "workspace:*",
8
8
  "@openai/agents-openai": "workspace:*",
9
9
  "@openai/agents-realtime": "workspace:*",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@openai/agents",
3
3
  "repository": "https://github.com/openai/openai-agents-js",
4
4
  "homepage": "https://openai.github.io/openai-agents-js/",
5
- "version": "0.5.2",
5
+ "version": "0.5.4",
6
6
  "description": "The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.",
7
7
  "author": "OpenAI <support@openai.com>",
8
8
  "main": "dist/index.js",
@@ -27,9 +27,9 @@
27
27
  "dependencies": {
28
28
  "debug": "^4.4.0",
29
29
  "openai": "^6.20.0",
30
- "@openai/agents-core": "0.5.2",
31
- "@openai/agents-realtime": "0.5.2",
32
- "@openai/agents-openai": "0.5.2"
30
+ "@openai/agents-core": "0.5.4",
31
+ "@openai/agents-realtime": "0.5.4",
32
+ "@openai/agents-openai": "0.5.4"
33
33
  },
34
34
  "keywords": [
35
35
  "openai",