@openai/agents 0.5.2 → 0.5.3

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,17 +1,23 @@
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
15
  1. **Agents**: LLMs configured with instructions, tools, guardrails, and handoffs.
10
- 2. **Handoffs**: Specialized tool calls for transferring control between agents.
16
+ 2. **Agents as tools / Handoffs**: Delegating to other agents for specific tasks.
11
17
  3. **Guardrails**: Configurable safety checks for input and output validation.
12
18
  4. **Tracing**: Built-in tracking of agent runs, allowing you to view, debug, and optimize your workflows.
13
19
 
14
- Explore the [`examples/`](examples/) directory to see the SDK in action.
20
+ Explore the [`examples/`](https://github.com/openai/openai-agents-js/tree/main/examples) directory to see the SDK in action.
15
21
 
16
22
  ## Supported Features
17
23
 
@@ -39,7 +45,7 @@ Explore the [`examples/`](examples/) directory to see the SDK in action.
39
45
  - Deno
40
46
  - Bun
41
47
 
42
- Experimental support:
48
+ #### Experimental support:
43
49
 
44
50
  - Cloudflare Workers with `nodejs_compat` enabled
45
51
 
@@ -51,7 +57,7 @@ Experimental support:
51
57
  npm install @openai/agents zod
52
58
  ```
53
59
 
54
- ## Hello world example
60
+ ### Run your first agent
55
61
 
56
62
  ```js
57
63
  import { Agent, run } from '@openai/agents';
@@ -73,130 +79,7 @@ console.log(result.finalOutput);
73
79
 
74
80
  (_If running this, ensure you set the `OPENAI_API_KEY` environment variable_)
75
81
 
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.
82
+ Explore the [`examples/`](https://github.com/openai/openai-agents-js/tree/main/examples) directory to see the SDK in action.
200
83
 
201
84
  ## Acknowledgements
202
85
 
@@ -210,4 +93,4 @@ We'd like to acknowledge the excellent work of the open-source community, especi
210
93
 
211
94
  We're committed to building the Agents SDK as an open source framework so others in the community can expand on our approach.
212
95
 
213
- For more details, see the [documentation](https://openai.github.io/openai-agents-js) or explore the [`examples/`](examples/) directory.
96
+ 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.3",
8
8
  "versions": {
9
- "@openai/agents": "0.5.2",
9
+ "@openai/agents": "0.5.3",
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.3",
5
5
  "versions": {
6
- "@openai/agents": "0.5.2",
6
+ "@openai/agents": "0.5.3",
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.3",
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.3",
31
+ "@openai/agents-openai": "0.5.3",
32
+ "@openai/agents-realtime": "0.5.3"
33
33
  },
34
34
  "keywords": [
35
35
  "openai",