openai-agents 0.3.2__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
Potentially problematic release.
This version of openai-agents might be problematic. Click here for more details.
- agents/__init__.py +37 -1
- agents/_run_impl.py +252 -26
- agents/exceptions.py +35 -0
- agents/extensions/memory/__init__.py +21 -0
- agents/extensions/memory/advanced_sqlite_session.py +1285 -0
- agents/extensions/memory/redis_session.py +267 -0
- agents/extensions/memory/sqlalchemy_session.py +12 -3
- agents/extensions/models/litellm_model.py +123 -3
- agents/items.py +100 -4
- agents/mcp/server.py +43 -11
- agents/mcp/util.py +17 -1
- agents/memory/openai_conversations_session.py +2 -2
- agents/models/chatcmpl_converter.py +50 -20
- agents/models/openai_chatcompletions.py +27 -26
- agents/models/openai_responses.py +31 -29
- agents/realtime/handoffs.py +1 -1
- agents/result.py +55 -11
- agents/run.py +225 -27
- agents/strict_schema.py +14 -0
- agents/tool.py +80 -3
- agents/tool_guardrails.py +279 -0
- {openai_agents-0.3.2.dist-info → openai_agents-0.4.0.dist-info}/METADATA +14 -3
- {openai_agents-0.3.2.dist-info → openai_agents-0.4.0.dist-info}/RECORD +25 -22
- {openai_agents-0.3.2.dist-info → openai_agents-0.4.0.dist-info}/WHEEL +0 -0
- {openai_agents-0.3.2.dist-info → openai_agents-0.4.0.dist-info}/licenses/LICENSE +0 -0
agents/tool.py
CHANGED
|
@@ -15,24 +15,26 @@ from openai.types.responses.response_output_item import LocalShellCall, McpAppro
|
|
|
15
15
|
from openai.types.responses.tool_param import CodeInterpreter, ImageGeneration, Mcp
|
|
16
16
|
from openai.types.responses.web_search_tool import Filters as WebSearchToolFilters
|
|
17
17
|
from openai.types.responses.web_search_tool_param import UserLocation
|
|
18
|
-
from pydantic import ValidationError
|
|
18
|
+
from pydantic import BaseModel, TypeAdapter, ValidationError
|
|
19
19
|
from typing_extensions import Concatenate, NotRequired, ParamSpec, TypedDict
|
|
20
20
|
|
|
21
21
|
from . import _debug
|
|
22
22
|
from .computer import AsyncComputer, Computer
|
|
23
23
|
from .exceptions import ModelBehaviorError
|
|
24
24
|
from .function_schema import DocstringStyle, function_schema
|
|
25
|
-
from .items import RunItem
|
|
26
25
|
from .logger import logger
|
|
27
26
|
from .run_context import RunContextWrapper
|
|
28
27
|
from .strict_schema import ensure_strict_json_schema
|
|
29
28
|
from .tool_context import ToolContext
|
|
29
|
+
from .tool_guardrails import ToolInputGuardrail, ToolOutputGuardrail
|
|
30
30
|
from .tracing import SpanError
|
|
31
31
|
from .util import _error_tracing
|
|
32
32
|
from .util._types import MaybeAwaitable
|
|
33
33
|
|
|
34
34
|
if TYPE_CHECKING:
|
|
35
35
|
from .agent import Agent, AgentBase
|
|
36
|
+
from .items import RunItem
|
|
37
|
+
|
|
36
38
|
|
|
37
39
|
ToolParams = ParamSpec("ToolParams")
|
|
38
40
|
|
|
@@ -47,6 +49,72 @@ ToolFunction = Union[
|
|
|
47
49
|
]
|
|
48
50
|
|
|
49
51
|
|
|
52
|
+
class ToolOutputText(BaseModel):
|
|
53
|
+
"""Represents a tool output that should be sent to the model as text."""
|
|
54
|
+
|
|
55
|
+
type: Literal["text"] = "text"
|
|
56
|
+
text: str
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class ToolOutputTextDict(TypedDict, total=False):
|
|
60
|
+
"""TypedDict variant for text tool outputs."""
|
|
61
|
+
|
|
62
|
+
type: Literal["text"]
|
|
63
|
+
text: str
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class ToolOutputImage(BaseModel):
|
|
67
|
+
"""Represents a tool output that should be sent to the model as an image.
|
|
68
|
+
|
|
69
|
+
You can provide either an `image_url` (URL or data URL) or a `file_id` for previously uploaded
|
|
70
|
+
content. The optional `detail` can control vision detail.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
type: Literal["image"] = "image"
|
|
74
|
+
image_url: str | None = None
|
|
75
|
+
file_id: str | None = None
|
|
76
|
+
detail: Literal["low", "high", "auto"] | None = None
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class ToolOutputImageDict(TypedDict, total=False):
|
|
80
|
+
"""TypedDict variant for image tool outputs."""
|
|
81
|
+
|
|
82
|
+
type: Literal["image"]
|
|
83
|
+
image_url: NotRequired[str]
|
|
84
|
+
file_id: NotRequired[str]
|
|
85
|
+
detail: NotRequired[Literal["low", "high", "auto"]]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class ToolOutputFileContent(BaseModel):
|
|
89
|
+
"""Represents a tool output that should be sent to the model as a file.
|
|
90
|
+
|
|
91
|
+
Provide one of `file_data` (base64), `file_url`, or `file_id`. You may also
|
|
92
|
+
provide an optional `filename` when using `file_data` to hint file name.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
type: Literal["file"] = "file"
|
|
96
|
+
file_data: str | None = None
|
|
97
|
+
file_url: str | None = None
|
|
98
|
+
file_id: str | None = None
|
|
99
|
+
filename: str | None = None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class ToolOutputFileContentDict(TypedDict, total=False):
|
|
103
|
+
"""TypedDict variant for file content tool outputs."""
|
|
104
|
+
|
|
105
|
+
type: Literal["file"]
|
|
106
|
+
file_data: NotRequired[str]
|
|
107
|
+
file_url: NotRequired[str]
|
|
108
|
+
file_id: NotRequired[str]
|
|
109
|
+
filename: NotRequired[str]
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
ValidToolOutputPydanticModels = Union[ToolOutputText, ToolOutputImage, ToolOutputFileContent]
|
|
113
|
+
ValidToolOutputPydanticModelsTypeAdapter: TypeAdapter[ValidToolOutputPydanticModels] = TypeAdapter(
|
|
114
|
+
ValidToolOutputPydanticModels
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
50
118
|
@dataclass
|
|
51
119
|
class FunctionToolResult:
|
|
52
120
|
tool: FunctionTool
|
|
@@ -80,7 +148,9 @@ class FunctionTool:
|
|
|
80
148
|
1. The tool run context.
|
|
81
149
|
2. The arguments from the LLM, as a JSON string.
|
|
82
150
|
|
|
83
|
-
You must return a
|
|
151
|
+
You must return a one of the structured tool output types (e.g. ToolOutputText, ToolOutputImage,
|
|
152
|
+
ToolOutputFileContent) or a string representation of the tool output, or a list of them,
|
|
153
|
+
or something we can call `str()` on.
|
|
84
154
|
In case of errors, you can either raise an Exception (which will cause the run to fail) or
|
|
85
155
|
return a string error message (which will be sent back to the LLM).
|
|
86
156
|
"""
|
|
@@ -94,6 +164,13 @@ class FunctionTool:
|
|
|
94
164
|
and returns whether the tool is enabled. You can use this to dynamically enable/disable a tool
|
|
95
165
|
based on your context/state."""
|
|
96
166
|
|
|
167
|
+
# Tool-specific guardrails
|
|
168
|
+
tool_input_guardrails: list[ToolInputGuardrail[Any]] | None = None
|
|
169
|
+
"""Optional list of input guardrails to run before invoking this tool."""
|
|
170
|
+
|
|
171
|
+
tool_output_guardrails: list[ToolOutputGuardrail[Any]] | None = None
|
|
172
|
+
"""Optional list of output guardrails to run after invoking this tool."""
|
|
173
|
+
|
|
97
174
|
def __post_init__(self):
|
|
98
175
|
if self.strict_json_schema:
|
|
99
176
|
self.params_json_schema = ensure_strict_json_schema(self.params_json_schema)
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import inspect
|
|
4
|
+
from collections.abc import Awaitable
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Callable, Generic, Literal, overload
|
|
7
|
+
|
|
8
|
+
from typing_extensions import TypedDict, TypeVar
|
|
9
|
+
|
|
10
|
+
from .exceptions import UserError
|
|
11
|
+
from .tool_context import ToolContext
|
|
12
|
+
from .util._types import MaybeAwaitable
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from .agent import Agent
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass
|
|
19
|
+
class ToolInputGuardrailResult:
|
|
20
|
+
"""The result of a tool input guardrail run."""
|
|
21
|
+
|
|
22
|
+
guardrail: ToolInputGuardrail[Any]
|
|
23
|
+
"""The guardrail that was run."""
|
|
24
|
+
|
|
25
|
+
output: ToolGuardrailFunctionOutput
|
|
26
|
+
"""The output of the guardrail function."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class ToolOutputGuardrailResult:
|
|
31
|
+
"""The result of a tool output guardrail run."""
|
|
32
|
+
|
|
33
|
+
guardrail: ToolOutputGuardrail[Any]
|
|
34
|
+
"""The guardrail that was run."""
|
|
35
|
+
|
|
36
|
+
output: ToolGuardrailFunctionOutput
|
|
37
|
+
"""The output of the guardrail function."""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class RejectContentBehavior(TypedDict):
|
|
41
|
+
"""Rejects the tool call/output but continues execution with a message to the model."""
|
|
42
|
+
|
|
43
|
+
type: Literal["reject_content"]
|
|
44
|
+
message: str
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class RaiseExceptionBehavior(TypedDict):
|
|
48
|
+
"""Raises an exception to halt execution."""
|
|
49
|
+
|
|
50
|
+
type: Literal["raise_exception"]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class AllowBehavior(TypedDict):
|
|
54
|
+
"""Allows normal tool execution to continue."""
|
|
55
|
+
|
|
56
|
+
type: Literal["allow"]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass
|
|
60
|
+
class ToolGuardrailFunctionOutput:
|
|
61
|
+
"""The output of a tool guardrail function."""
|
|
62
|
+
|
|
63
|
+
output_info: Any
|
|
64
|
+
"""
|
|
65
|
+
Optional data about checks performed. For example, the guardrail could include
|
|
66
|
+
information about the checks it performed and granular results.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
behavior: RejectContentBehavior | RaiseExceptionBehavior | AllowBehavior = field(
|
|
70
|
+
default_factory=lambda: AllowBehavior(type="allow")
|
|
71
|
+
)
|
|
72
|
+
"""
|
|
73
|
+
Defines how the system should respond when this guardrail result is processed.
|
|
74
|
+
- allow: Allow normal tool execution to continue without interference (default)
|
|
75
|
+
- reject_content: Reject the tool call/output but continue execution with a message to the model
|
|
76
|
+
- raise_exception: Halt execution by raising a ToolGuardrailTripwireTriggered exception
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def allow(cls, output_info: Any = None) -> ToolGuardrailFunctionOutput:
|
|
81
|
+
"""Create a guardrail output that allows the tool execution to continue normally.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
output_info: Optional data about checks performed.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
ToolGuardrailFunctionOutput configured to allow normal execution.
|
|
88
|
+
"""
|
|
89
|
+
return cls(output_info=output_info, behavior=AllowBehavior(type="allow"))
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def reject_content(cls, message: str, output_info: Any = None) -> ToolGuardrailFunctionOutput:
|
|
93
|
+
"""Create a guardrail output that rejects the tool call/output but continues execution.
|
|
94
|
+
|
|
95
|
+
Args:
|
|
96
|
+
message: Message to send to the model instead of the tool result.
|
|
97
|
+
output_info: Optional data about checks performed.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
ToolGuardrailFunctionOutput configured to reject the content.
|
|
101
|
+
"""
|
|
102
|
+
return cls(
|
|
103
|
+
output_info=output_info,
|
|
104
|
+
behavior=RejectContentBehavior(type="reject_content", message=message),
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
@classmethod
|
|
108
|
+
def raise_exception(cls, output_info: Any = None) -> ToolGuardrailFunctionOutput:
|
|
109
|
+
"""Create a guardrail output that raises an exception to halt execution.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
output_info: Optional data about checks performed.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
ToolGuardrailFunctionOutput configured to raise an exception.
|
|
116
|
+
"""
|
|
117
|
+
return cls(output_info=output_info, behavior=RaiseExceptionBehavior(type="raise_exception"))
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@dataclass
|
|
121
|
+
class ToolInputGuardrailData:
|
|
122
|
+
"""Input data passed to a tool input guardrail function."""
|
|
123
|
+
|
|
124
|
+
context: ToolContext[Any]
|
|
125
|
+
"""
|
|
126
|
+
The tool context containing information about the current tool execution.
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
agent: Agent[Any]
|
|
130
|
+
"""
|
|
131
|
+
The agent that is executing the tool.
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@dataclass
|
|
136
|
+
class ToolOutputGuardrailData(ToolInputGuardrailData):
|
|
137
|
+
"""Input data passed to a tool output guardrail function.
|
|
138
|
+
|
|
139
|
+
Extends input data with the tool's output.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
output: Any
|
|
143
|
+
"""
|
|
144
|
+
The output produced by the tool function.
|
|
145
|
+
"""
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
TContext_co = TypeVar("TContext_co", bound=Any, covariant=True)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@dataclass
|
|
152
|
+
class ToolInputGuardrail(Generic[TContext_co]):
|
|
153
|
+
"""A guardrail that runs before a function tool is invoked."""
|
|
154
|
+
|
|
155
|
+
guardrail_function: Callable[
|
|
156
|
+
[ToolInputGuardrailData], MaybeAwaitable[ToolGuardrailFunctionOutput]
|
|
157
|
+
]
|
|
158
|
+
"""
|
|
159
|
+
The function that implements the guardrail logic.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
name: str | None = None
|
|
163
|
+
"""
|
|
164
|
+
Optional name for the guardrail. If not provided, uses the function name.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
def get_name(self) -> str:
|
|
168
|
+
return self.name or self.guardrail_function.__name__
|
|
169
|
+
|
|
170
|
+
async def run(self, data: ToolInputGuardrailData) -> ToolGuardrailFunctionOutput:
|
|
171
|
+
if not callable(self.guardrail_function):
|
|
172
|
+
raise UserError(f"Guardrail function must be callable, got {self.guardrail_function}")
|
|
173
|
+
|
|
174
|
+
result = self.guardrail_function(data)
|
|
175
|
+
if inspect.isawaitable(result):
|
|
176
|
+
return await result
|
|
177
|
+
return result
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@dataclass
|
|
181
|
+
class ToolOutputGuardrail(Generic[TContext_co]):
|
|
182
|
+
"""A guardrail that runs after a function tool is invoked."""
|
|
183
|
+
|
|
184
|
+
guardrail_function: Callable[
|
|
185
|
+
[ToolOutputGuardrailData], MaybeAwaitable[ToolGuardrailFunctionOutput]
|
|
186
|
+
]
|
|
187
|
+
"""
|
|
188
|
+
The function that implements the guardrail logic.
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
name: str | None = None
|
|
192
|
+
"""
|
|
193
|
+
Optional name for the guardrail. If not provided, uses the function name.
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
def get_name(self) -> str:
|
|
197
|
+
return self.name or self.guardrail_function.__name__
|
|
198
|
+
|
|
199
|
+
async def run(self, data: ToolOutputGuardrailData) -> ToolGuardrailFunctionOutput:
|
|
200
|
+
if not callable(self.guardrail_function):
|
|
201
|
+
raise UserError(f"Guardrail function must be callable, got {self.guardrail_function}")
|
|
202
|
+
|
|
203
|
+
result = self.guardrail_function(data)
|
|
204
|
+
if inspect.isawaitable(result):
|
|
205
|
+
return await result
|
|
206
|
+
return result
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
# Decorators
|
|
210
|
+
_ToolInputFuncSync = Callable[[ToolInputGuardrailData], ToolGuardrailFunctionOutput]
|
|
211
|
+
_ToolInputFuncAsync = Callable[[ToolInputGuardrailData], Awaitable[ToolGuardrailFunctionOutput]]
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@overload
|
|
215
|
+
def tool_input_guardrail(func: _ToolInputFuncSync): ...
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@overload
|
|
219
|
+
def tool_input_guardrail(func: _ToolInputFuncAsync): ...
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
@overload
|
|
223
|
+
def tool_input_guardrail(
|
|
224
|
+
*, name: str | None = None
|
|
225
|
+
) -> Callable[[_ToolInputFuncSync | _ToolInputFuncAsync], ToolInputGuardrail[Any]]: ...
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def tool_input_guardrail(
|
|
229
|
+
func: _ToolInputFuncSync | _ToolInputFuncAsync | None = None,
|
|
230
|
+
*,
|
|
231
|
+
name: str | None = None,
|
|
232
|
+
) -> (
|
|
233
|
+
ToolInputGuardrail[Any]
|
|
234
|
+
| Callable[[_ToolInputFuncSync | _ToolInputFuncAsync], ToolInputGuardrail[Any]]
|
|
235
|
+
):
|
|
236
|
+
"""Decorator to create a ToolInputGuardrail from a function."""
|
|
237
|
+
|
|
238
|
+
def decorator(f: _ToolInputFuncSync | _ToolInputFuncAsync) -> ToolInputGuardrail[Any]:
|
|
239
|
+
return ToolInputGuardrail(guardrail_function=f, name=name or f.__name__)
|
|
240
|
+
|
|
241
|
+
if func is not None:
|
|
242
|
+
return decorator(func)
|
|
243
|
+
return decorator
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
_ToolOutputFuncSync = Callable[[ToolOutputGuardrailData], ToolGuardrailFunctionOutput]
|
|
247
|
+
_ToolOutputFuncAsync = Callable[[ToolOutputGuardrailData], Awaitable[ToolGuardrailFunctionOutput]]
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
@overload
|
|
251
|
+
def tool_output_guardrail(func: _ToolOutputFuncSync): ...
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@overload
|
|
255
|
+
def tool_output_guardrail(func: _ToolOutputFuncAsync): ...
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
@overload
|
|
259
|
+
def tool_output_guardrail(
|
|
260
|
+
*, name: str | None = None
|
|
261
|
+
) -> Callable[[_ToolOutputFuncSync | _ToolOutputFuncAsync], ToolOutputGuardrail[Any]]: ...
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
def tool_output_guardrail(
|
|
265
|
+
func: _ToolOutputFuncSync | _ToolOutputFuncAsync | None = None,
|
|
266
|
+
*,
|
|
267
|
+
name: str | None = None,
|
|
268
|
+
) -> (
|
|
269
|
+
ToolOutputGuardrail[Any]
|
|
270
|
+
| Callable[[_ToolOutputFuncSync | _ToolOutputFuncAsync], ToolOutputGuardrail[Any]]
|
|
271
|
+
):
|
|
272
|
+
"""Decorator to create a ToolOutputGuardrail from a function."""
|
|
273
|
+
|
|
274
|
+
def decorator(f: _ToolOutputFuncSync | _ToolOutputFuncAsync) -> ToolOutputGuardrail[Any]:
|
|
275
|
+
return ToolOutputGuardrail(guardrail_function=f, name=name or f.__name__)
|
|
276
|
+
|
|
277
|
+
if func is not None:
|
|
278
|
+
return decorator(func)
|
|
279
|
+
return decorator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openai-agents
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: OpenAI Agents SDK
|
|
5
5
|
Project-URL: Homepage, https://openai.github.io/openai-agents-python/
|
|
6
6
|
Project-URL: Repository, https://github.com/openai/openai-agents-python
|
|
@@ -21,7 +21,7 @@ Classifier: Typing :: Typed
|
|
|
21
21
|
Requires-Python: >=3.9
|
|
22
22
|
Requires-Dist: griffe<2,>=1.5.6
|
|
23
23
|
Requires-Dist: mcp<2,>=1.11.0; python_version >= '3.10'
|
|
24
|
-
Requires-Dist: openai<2
|
|
24
|
+
Requires-Dist: openai<3,>=2.2
|
|
25
25
|
Requires-Dist: pydantic<3,>=2.10
|
|
26
26
|
Requires-Dist: requests<3,>=2.0
|
|
27
27
|
Requires-Dist: types-requests<3,>=2.0
|
|
@@ -32,6 +32,8 @@ Provides-Extra: litellm
|
|
|
32
32
|
Requires-Dist: litellm<2,>=1.67.4.post1; extra == 'litellm'
|
|
33
33
|
Provides-Extra: realtime
|
|
34
34
|
Requires-Dist: websockets<16,>=15.0; extra == 'realtime'
|
|
35
|
+
Provides-Extra: redis
|
|
36
|
+
Requires-Dist: redis>=6.4.0; extra == 'redis'
|
|
35
37
|
Provides-Extra: sqlalchemy
|
|
36
38
|
Requires-Dist: asyncpg>=0.29.0; extra == 'sqlalchemy'
|
|
37
39
|
Requires-Dist: sqlalchemy>=2.0; extra == 'sqlalchemy'
|
|
@@ -75,6 +77,8 @@ pip install openai-agents
|
|
|
75
77
|
|
|
76
78
|
For voice support, install with the optional `voice` group: `pip install 'openai-agents[voice]'`.
|
|
77
79
|
|
|
80
|
+
For Redis session support, install with the optional `redis` group: `pip install 'openai-agents[redis]'`.
|
|
81
|
+
|
|
78
82
|
### uv
|
|
79
83
|
|
|
80
84
|
If you're familiar with [uv](https://docs.astral.sh/uv/), using the tool would be even similar:
|
|
@@ -86,6 +90,8 @@ uv add openai-agents
|
|
|
86
90
|
|
|
87
91
|
For voice support, install with the optional `voice` group: `uv add 'openai-agents[voice]'`.
|
|
88
92
|
|
|
93
|
+
For Redis session support, install with the optional `redis` group: `uv add 'openai-agents[redis]'`.
|
|
94
|
+
|
|
89
95
|
## Hello world example
|
|
90
96
|
|
|
91
97
|
```python
|
|
@@ -255,8 +261,13 @@ print(result.final_output) # "Approximately 39 million"
|
|
|
255
261
|
```python
|
|
256
262
|
from agents import Agent, Runner, SQLiteSession
|
|
257
263
|
|
|
258
|
-
#
|
|
264
|
+
# SQLite - file-based or in-memory database
|
|
259
265
|
session = SQLiteSession("user_123", "conversations.db")
|
|
266
|
+
|
|
267
|
+
# Redis - for scalable, distributed deployments
|
|
268
|
+
# from agents.extensions.memory import RedisSession
|
|
269
|
+
# session = RedisSession.from_url("user_123", url="redis://localhost:6379/0")
|
|
270
|
+
|
|
260
271
|
agent = Agent(name="Assistant")
|
|
261
272
|
|
|
262
273
|
# Different session IDs maintain separate conversation histories
|
|
@@ -1,60 +1,63 @@
|
|
|
1
|
-
agents/__init__.py,sha256=
|
|
1
|
+
agents/__init__.py,sha256=qdaXm0t_NP4B78ODns3J9FAy4AurgDcQGNkXf9y_pL8,9036
|
|
2
2
|
agents/_config.py,sha256=ANrM7GP2VSQehDkMc9qocxkUlPwqU-i5sieMJyEwxpM,796
|
|
3
3
|
agents/_debug.py,sha256=dRe2dUlA9bCLp6f8bAdiX7JfGyJuHyS_DRdW0kZshl0,856
|
|
4
|
-
agents/_run_impl.py,sha256=
|
|
4
|
+
agents/_run_impl.py,sha256=WXxiCS_GMYhY8Z3SjxVOgcEk3YgtjdoM3pr6FxJXUi8,55174
|
|
5
5
|
agents/agent.py,sha256=P5AzwKz3FiQJjzfautF0R9JzxkTXEeItcEkJgn8z5mM,19832
|
|
6
6
|
agents/agent_output.py,sha256=teTFK8unUN3esXhmEBO0bQGYQm1Axd5rYleDt9TFDgw,7153
|
|
7
7
|
agents/computer.py,sha256=XD44UgiUWSfniv-xKwwDP6wFKVwBiZkpaL1hO-0-7ZA,2516
|
|
8
|
-
agents/exceptions.py,sha256=
|
|
8
|
+
agents/exceptions.py,sha256=roJsYttB5i7FQlzRQNg8QSVdALZFz5u7kUeVvJdaitE,4156
|
|
9
9
|
agents/function_schema.py,sha256=njtbLt44DOkIU0a0U8TeDNEx-iQZU8oohwy3k7-k4A8,14855
|
|
10
10
|
agents/guardrail.py,sha256=7P-kd9rKPhgB8rtI31MCV5ho4ZrEaNCQxHvE8IK3EOk,9582
|
|
11
11
|
agents/handoffs.py,sha256=kDTM3nj3E_0khiJPMJAIN00gektMTRNbaYSbc5ZCnBM,11411
|
|
12
|
-
agents/items.py,sha256=
|
|
12
|
+
agents/items.py,sha256=9-it0ZFCy_igRtpBIk7BTebdvK1G_Ygt16B24gFvN5w,14216
|
|
13
13
|
agents/lifecycle.py,sha256=hGsqzumOSaal6oAjTqTfvBXl-ShAOkC42sthJigB5Fg,4308
|
|
14
14
|
agents/logger.py,sha256=p_ef7vWKpBev5FFybPJjhrCCQizK08Yy1A2EDO1SNNg,60
|
|
15
15
|
agents/model_settings.py,sha256=7Ul-Xg-aNVXIbK6V4Rm2t5EEfNR0tsy_A9ac_wFqLLk,6828
|
|
16
16
|
agents/prompts.py,sha256=Ss5y_7s2HFcRAOAKu4WTxQszs5ybI8TfbxgEYdnj9sg,2231
|
|
17
17
|
agents/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
18
18
|
agents/repl.py,sha256=NX0BE5YDnmGQ2rdQsmLm3CKkQZ5m4GC95xXmUsAXJVs,2539
|
|
19
|
-
agents/result.py,sha256=
|
|
20
|
-
agents/run.py,sha256=
|
|
19
|
+
agents/result.py,sha256=FW3-fsYOIJrn7pjiDjWPHN58pPpYfNoFNTympFV_96k,13963
|
|
20
|
+
agents/run.py,sha256=z0SKQx2jk4nHeWkBII2ZDpEY4dxm6Ce6Ud8I9GN7N9A,74508
|
|
21
21
|
agents/run_context.py,sha256=vuSUQM8O4CLensQY27-22fOqECnw7yvwL9U3WO8b_bk,851
|
|
22
22
|
agents/stream_events.py,sha256=VFyTu-DT3ZMnHLtMbg-X_lxec0doQxNfx-hVxLB0BpI,1700
|
|
23
|
-
agents/strict_schema.py,sha256=
|
|
24
|
-
agents/tool.py,sha256=
|
|
23
|
+
agents/strict_schema.py,sha256=HFm4j753-UKDfJ0zSiQYf5V1qGuHY6TRm2zzwI0f0E0,6382
|
|
24
|
+
agents/tool.py,sha256=H-IytTUTna7qTQbfraRystrgKeYU5Cc1zFKAeXqwO5A,19537
|
|
25
25
|
agents/tool_context.py,sha256=g53mgaeX7kCwPaIReiwuUejD8qC7QejMS-F3Wnkuhhg,1866
|
|
26
|
+
agents/tool_guardrails.py,sha256=2uXEr_R5AWy9NHtBjd7G7upc3uZSuoP86Hfsc-qTadM,8344
|
|
26
27
|
agents/usage.py,sha256=Tb5udGd3DPgD0JBdRD8fDctTE4M-zKML5uRn8ZG1yBc,1675
|
|
27
28
|
agents/version.py,sha256=_1knUwzSK-HUeZTpRUkk6Z-CIcurqXuEplbV5TLJ08E,230
|
|
28
29
|
agents/extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
30
|
agents/extensions/handoff_filters.py,sha256=CS-k7TGCtT8TW3GeXb04OoFBXKdjg8-85QXswWAYBmI,2095
|
|
30
31
|
agents/extensions/handoff_prompt.py,sha256=oGWN0uNh3Z1L7E-Ev2up8W084fFrDNOsLDy7P6bcmic,1006
|
|
31
32
|
agents/extensions/visualization.py,sha256=sf9D_C-HMwkbWdZccTZvvMPRy_NSiwbm48tRJlESQBI,5144
|
|
32
|
-
agents/extensions/memory/__init__.py,sha256=
|
|
33
|
+
agents/extensions/memory/__init__.py,sha256=jhx0pa1TVRFooiI0ERRhklkaeiZ-NDGA_b9tJXp3VfM,2201
|
|
34
|
+
agents/extensions/memory/advanced_sqlite_session.py,sha256=rCrXM878foAuBN-rN2fibP2GHs-1hTtRx-TQcDKIfGI,52883
|
|
33
35
|
agents/extensions/memory/encrypt_session.py,sha256=PVnZIEj50bjUq16OLnMKrbZiinLkrVpamPPEw8RnUCA,6485
|
|
34
|
-
agents/extensions/memory/
|
|
36
|
+
agents/extensions/memory/redis_session.py,sha256=JwXY6zUTMgq9bRezlyFZ4Tze7DO7T0hioTc23qjSHjU,9838
|
|
37
|
+
agents/extensions/memory/sqlalchemy_session.py,sha256=LlZ5Gx1zR9cRGwM__LkQCHzK7ItT9hfACo16hCQWlQU,11879
|
|
35
38
|
agents/extensions/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
|
-
agents/extensions/models/litellm_model.py,sha256=
|
|
39
|
+
agents/extensions/models/litellm_model.py,sha256=D4dbbOHHgdBPADAEYHlFhma9645r3gN9U7gg4713mhw,23653
|
|
37
40
|
agents/extensions/models/litellm_provider.py,sha256=ZHgh1nMoEvA7NpawkzLh3JDuDFtwXUV94Rs7UrwWqAk,1083
|
|
38
41
|
agents/mcp/__init__.py,sha256=yHmmYlrmEHzUas1inRLKL2iPqbb_-107G3gKe_tyg4I,750
|
|
39
|
-
agents/mcp/server.py,sha256=
|
|
40
|
-
agents/mcp/util.py,sha256=
|
|
42
|
+
agents/mcp/server.py,sha256=cby0KKKKRhuWCydr4llERPL72Z94uV-SV3LLAcgcWTk,28435
|
|
43
|
+
agents/mcp/util.py,sha256=0AoTXYhSCxa1JOIdl8kdqBZJakpKbQTNBQxChXdH3hg,8700
|
|
41
44
|
agents/memory/__init__.py,sha256=EvPDQqQs6TGEYnZi3kyVmyuE3FoTB8dD8Sn2EXMOww0,322
|
|
42
|
-
agents/memory/openai_conversations_session.py,sha256=
|
|
45
|
+
agents/memory/openai_conversations_session.py,sha256=FbV2YPbyTanBxY7pVcYQrlXTebsTKpRn7eIR6ESM1hU,3352
|
|
43
46
|
agents/memory/session.py,sha256=pyyFn3r07ydhoy7vn1e_ky9OUa1a_7DKoEo8aZz2d3s,3038
|
|
44
47
|
agents/memory/sqlite_session.py,sha256=6HGzSL70mQgutITIPZUC2x2Qtj6U4hXiZTceu3Da7TM,10130
|
|
45
48
|
agents/memory/util.py,sha256=ZAHOrNVA36xICFzuNgHgEA1_s_oEMO6Wsu6-EecY8JU,586
|
|
46
49
|
agents/models/__init__.py,sha256=E0XVqWayVAsFqxucDLBW30siaqfNQsVrAnfidG_C3ok,287
|
|
47
50
|
agents/models/_openai_shared.py,sha256=4Ngwo2Fv2RXY61Pqck1cYPkSln2tDnb8Ai-ao4QG-iE,836
|
|
48
|
-
agents/models/chatcmpl_converter.py,sha256=
|
|
51
|
+
agents/models/chatcmpl_converter.py,sha256=qEobLnIJjrK6WRi_tsVkrDrGq78EGro3MZXlVMpMK2c,26011
|
|
49
52
|
agents/models/chatcmpl_helpers.py,sha256=YC2krp_-uBgRCrCEImLjNvONTWRWfwLlPKHI4kBmNXE,1483
|
|
50
53
|
agents/models/chatcmpl_stream_handler.py,sha256=r8nc-4hJg1plw87y24MD48O23xnfC_2gHKowtOYgO3M,28896
|
|
51
54
|
agents/models/default_models.py,sha256=mlvBePn8H4UkHo7lN-wh7A3k2ciLgBUFKpROQxzdTfs,2098
|
|
52
55
|
agents/models/fake_id.py,sha256=lbXjUUSMeAQ8eFx4V5QLUnBClHE6adJlYYav55RlG5w,268
|
|
53
56
|
agents/models/interface.py,sha256=-AFUHC8iRuGZmtQwguDw4s-M4OPL2y2mct4TAmWvVrU,4057
|
|
54
57
|
agents/models/multi_provider.py,sha256=aiDbls5G4YomPfN6qH1pGlj41WS5jlDp2T82zm6qcnM,5578
|
|
55
|
-
agents/models/openai_chatcompletions.py,sha256=
|
|
58
|
+
agents/models/openai_chatcompletions.py,sha256=A7mkzwY9VMg86az_RknI8IuK5g8U8Y728QMVOw6LYA8,13923
|
|
56
59
|
agents/models/openai_provider.py,sha256=vBu3mlgDBrI_cZVVmfnWBHoPlJlsmld3lfdX8sNQQAM,3624
|
|
57
|
-
agents/models/openai_responses.py,sha256=
|
|
60
|
+
agents/models/openai_responses.py,sha256=9orX2jaZIBbIDKfj0FoLmtYbCQ6SNzp56iQp6SQL8CU,19099
|
|
58
61
|
agents/realtime/README.md,sha256=5YCYXH5ULmlWoWo1PE9TlbHjeYgjnp-xY8ZssSFY2Vk,126
|
|
59
62
|
agents/realtime/__init__.py,sha256=v8SKjD85pqQD1ZPzEQAtmbZb2CRApe0XwrxkRxzCm7c,5013
|
|
60
63
|
agents/realtime/_default_tracker.py,sha256=4OMxBvD1MnZmMn6JZYKL42uWhVzvK6NdDLDfPP54d78,1765
|
|
@@ -63,7 +66,7 @@ agents/realtime/agent.py,sha256=bkegBJ_lc3z3NtnlIyEkVZFxZWBJwVjsQVzpQZAu7PM,4283
|
|
|
63
66
|
agents/realtime/audio_formats.py,sha256=DBUWVVff4XY5BT6Mol86tF4PFMp5OIS3LmAbqUmQn_k,1019
|
|
64
67
|
agents/realtime/config.py,sha256=ud0GK8ZbcnKRC4oGZNwpsiZI8TZ1OdTSMADfFtM8Z6I,6948
|
|
65
68
|
agents/realtime/events.py,sha256=eANiNNyYlp_1Ybdl-MOwXRVTDtrK9hfgn6iw0xNxnaY,5889
|
|
66
|
-
agents/realtime/handoffs.py,sha256=
|
|
69
|
+
agents/realtime/handoffs.py,sha256=iJ4lr5RVdDkw5W3_AOGB_Az-hlRt1CoFFFNFDfd3ues,6698
|
|
67
70
|
agents/realtime/items.py,sha256=5EG768FkKpbk-dhe4b_7BfFpdUEFWtxoiVUtNI9KXsc,5517
|
|
68
71
|
agents/realtime/model.py,sha256=Lnb9pEcvnlIdXJUcldVyioaX5lpmrBou5FZoNJe4XfA,6457
|
|
69
72
|
agents/realtime/model_events.py,sha256=2NKofzLszKHwtlcsogsNnH6hdeFfO7S96yWDB4AlxB8,4340
|
|
@@ -105,7 +108,7 @@ agents/voice/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
105
108
|
agents/voice/models/openai_model_provider.py,sha256=Khn0uT-VhsEbe7_OhBMGFQzXNwL80gcWZyTHl3CaBII,3587
|
|
106
109
|
agents/voice/models/openai_stt.py,sha256=eZ0dmX_uDywpR1H3Q2N5jrV7NK3bR9l2a1InWM3yegk,17151
|
|
107
110
|
agents/voice/models/openai_tts.py,sha256=4KoLQuFDHKu5a1VTJlu9Nj3MHwMlrn9wfT_liJDJ2dw,1477
|
|
108
|
-
openai_agents-0.
|
|
109
|
-
openai_agents-0.
|
|
110
|
-
openai_agents-0.
|
|
111
|
-
openai_agents-0.
|
|
111
|
+
openai_agents-0.4.0.dist-info/METADATA,sha256=oz5c_NXJgwN1WWVSpsQDb9MYB9tz7TZA1v2lqySphmM,12929
|
|
112
|
+
openai_agents-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
113
|
+
openai_agents-0.4.0.dist-info/licenses/LICENSE,sha256=E994EspT7Krhy0qGiES7WYNzBHrh1YDk3r--8d1baRU,1063
|
|
114
|
+
openai_agents-0.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|