repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
openai-agents-python
src/agents/sandbox/util/token_truncation.py
.py
from __future__ import annotations from dataclasses import dataclass from typing import Literal APPROX_BYTES_PER_TOKEN = 4 TruncationMode = Literal["bytes", "tokens"] @dataclass(frozen=True) class TruncationPolicy: mode: TruncationMode limit: int @classmethod def bytes(cls, limit: int) -> Truncati...
242
7,304
openai-agents-python
src/agents/sandbox/util/__init__.py
.py
from .deep_merge import deep_merge from .github import clone_repo, ensure_git_available from .parse_utils import parse_ls_la from .retry import ( DEFAULT_TRANSIENT_RETRY_BACKOFF, DEFAULT_TRANSIENT_RETRY_INTERVAL_S, DEFAULT_TRANSIENT_RETRY_MAX_ATTEMPT, TRANSIENT_HTTP_STATUS_CODES, BackoffStrategy, ...
77
2,101
openai-agents-python
src/agents/sandbox/util/deep_merge.py
.py
from typing import TypeGuard def _is_string_object_dict(value: object) -> TypeGuard[dict[str, object]]: return isinstance(value, dict) and all(isinstance(key, str) for key in value) def deep_merge(dict1: dict[str, object], dict2: dict[str, object]) -> dict[str, object]: """ Recursively merge dict2 into ...
22
753
openai-agents-python
src/agents/sandbox/util/iterator_io.py
.py
import io from collections.abc import Callable, Iterator from typing import Any, cast class IteratorIO(io.IOBase): def __init__( self, it: Iterator[bytes], *, on_close: Callable[[], object] | None = None, ): self._it = it self._on_close = on_close self._...
95
2,509
openai-agents-python
src/agents/sandbox/util/retry.py
.py
from __future__ import annotations import asyncio import functools import inspect from collections.abc import Callable, Coroutine, Iterable from enum import Enum from typing import ParamSpec, TypeVar, cast P = ParamSpec("P") T = TypeVar("T") class BackoffStrategy(str, Enum): def __str__(self) -> str: re...
128
4,248
openai-agents-python
src/agents/sandbox/util/parse_utils.py
.py
from ..files import EntryKind, FileEntry from ..types import Permissions def parse_ls_la(output: str, *, base: str) -> list[FileEntry]: entries: list[FileEntry] = [] for raw_line in output.splitlines(): line = raw_line.strip("\n") if not line or line.startswith("total"): continue ...
80
2,761
openai-agents-python
src/agents/sandbox/util/github.py
.py
from __future__ import annotations import shutil import subprocess from pathlib import Path def ensure_git_available() -> None: if shutil.which("git") is None: raise RuntimeError("git is required to use github_repo artifacts") def clone_repo(*, repo: str, ref: str, dest: Path) -> None: """Shallow c...
54
1,387
openai-agents-python
src/agents/run_internal/guardrails.py
.py
from __future__ import annotations import asyncio from typing import Any from ..agent import Agent from ..exceptions import InputGuardrailTripwireTriggered, OutputGuardrailTripwireTriggered from ..guardrail import ( InputGuardrail, InputGuardrailResult, OutputGuardrail, OutputGuardrailResult, ) from ....
242
9,093
openai-agents-python
src/agents/run_internal/error_handlers.py
.py
from __future__ import annotations import inspect import json from typing import Any, Literal from openai.types.responses import ResponseOutputMessage, ResponseOutputText from ..agent import Agent from ..agent_output import _WRAPPER_DICT_KEY, AgentOutputSchema from ..exceptions import ( InputGuardrailTripwireTri...
263
9,075
openai-agents-python
src/agents/run_internal/session_persistence.py
.py
""" Session persistence helpers for the run pipeline. Only internal persistence/retry helpers live here; public session interfaces stay in higher-level modules. """ from __future__ import annotations import asyncio import copy import inspect import json from collections import deque from collections.abc import Sequen...
1,171
43,751
openai-agents-python
src/agents/run_internal/run_grouping.py
.py
from __future__ import annotations from typing import Literal from uuid import uuid4 from ..memory import Session RunGroupingKind = Literal["conversation", "session", "group", "run"] RunGrouping = tuple[RunGroupingKind, str] def resolve_run_grouping( *, conversation_id: str | None, session: Session | N...
60
1,547
openai-agents-python
src/agents/run_internal/tool_execution.py
.py
""" Tool execution helpers for the run pipeline. This module hosts execution-time helpers, approval plumbing, and payload coercion. Action classes live in tool_actions.py. """ from __future__ import annotations import asyncio import copy import dataclasses import functools import inspect import json from collections....
2,776
104,268
openai-agents-python
src/agents/run_internal/tool_actions.py
.py
""" Action executors used by the run loop. This module only houses XXXAction classes; helper functions and approval plumbing live in tool_execution.py. """ from __future__ import annotations import copy import dataclasses import inspect import json from collections.abc import Callable from typing import TYPE_CHECKING...
1,081
41,416
openai-agents-python
src/agents/run_internal/approvals.py
.py
""" Helpers for approval handling within the run loop. Keep only execution-time utilities that coordinate approval placeholders and normalization; public APIs should stay in run.py or peer modules. """ from __future__ import annotations from collections.abc import Sequence from typing import Any from openai.types.re...
103
3,365
openai-agents-python
src/agents/run_internal/__init__.py
.py
""" Internal helpers shared by the agent run pipeline. Public-facing APIs (e.g., RunConfig, RunOptions) belong at the top-level; only execution-time utilities that are not part of the surface area should live under run_internal. """ from __future__ import annotations
8
269
openai-agents-python
src/agents/run_internal/run_steps.py
.py
""" Internal step/result data structures used by the run loop orchestration. These types are not part of the public SDK surface. """ from __future__ import annotations import dataclasses from dataclasses import dataclass from typing import Any from openai.types.responses import ResponseComputerToolCall, ResponseFunc...
233
6,862
openai-agents-python
src/agents/run_internal/agent_runner_helpers.py
.py
"""Internal helpers for AgentRunner.run.""" from __future__ import annotations from collections.abc import Mapping from typing import Any, cast from openai.types.responses.response_usage import OutputTokensDetails from ..agent import Agent from ..agent_tool_state import set_agent_tool_state_scope from ..exceptions ...
580
21,720
openai-agents-python
src/agents/run_internal/oai_conversation.py
.py
""" Conversation-state helpers used during agent runs. This module should only host internal tracking and normalization logic for conversation-aware execution, not public-facing APIs. """ from __future__ import annotations from collections.abc import Sequence from dataclasses import dataclass, field from typing impor...
693
30,211
openai-agents-python
src/agents/run_internal/tool_use_tracker.py
.py
""" Tool-use tracking utilities. Hosts AgentToolUseTracker and helpers to serialize/deserialize its state plus lightweight tool-call type utilities. Internal use only. """ from __future__ import annotations from typing import TYPE_CHECKING, Any, get_args, get_origin from .._tool_identity import get_function_tool_tra...
181
6,339
openai-agents-python
src/agents/run_internal/agent_bindings.py
.py
from __future__ import annotations from dataclasses import dataclass from typing import Generic from ..agent import Agent from ..run_context import TContext __all__ = [ "AgentBindings", "bind_execution_agent", "bind_public_agent", ] @dataclass(frozen=True) class AgentBindings(Generic[TContext]): ""...
39
1,019
openai-agents-python
src/agents/run_internal/prompt_cache_key.py
.py
from __future__ import annotations from collections.abc import Mapping from dataclasses import dataclass, replace as dataclass_replace from hashlib import sha256 from typing import Any from ..memory import Session from ..model_settings import ModelSettings from ..run_state import RunState from .run_grouping import Ru...
131
4,384
openai-agents-python
src/agents/run_internal/turn_resolution.py
.py
from __future__ import annotations import inspect from collections.abc import Awaitable, Callable, Container, Mapping, Sequence from copy import deepcopy from dataclasses import replace from typing import Any, Literal, cast from openai.types.responses import ( ResponseCompactionItem, ResponseComputerToolCall,...
3,619
148,886
openai-agents-python
src/agents/run_internal/run_loop.py
.py
""" Run-loop orchestration helpers used by the Agent runner. This module coordinates tool execution, approvals, and turn processing; all symbols here are internal and not part of the public SDK. """ from __future__ import annotations import asyncio import dataclasses as _dc from collections.abc import Awaitable, Call...
2,493
108,529
openai-agents-python
src/agents/run_internal/_asyncio_progress.py
.py
"""Best-effort progress inspection for cancelled function-tool tasks. These helpers prefer public coroutine introspection first, then fall back to a small set of private asyncio attributes for patterns that still hide their driving tasks or deadlines (`Task._fut_waiter`, gather `_children`, shield callbacks, and loop ...
192
6,932
openai-agents-python
src/agents/run_internal/model_retry.py
.py
from __future__ import annotations import asyncio import random from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Mapping from inspect import isawaitable from typing import Any, TypeVar import httpx2 from openai import APIConnectionError, APITimeoutError, BadRequestError from .._httpx_c...
892
34,956
openai-agents-python
src/agents/run_internal/tool_caller.py
.py
from __future__ import annotations import json from collections.abc import Collection, Sequence from typing import Any from ..exceptions import ModelBehaviorError from ..tool import ToolCaller from ..tracing import SpanError from ..util import _error_tracing def ensure_tool_caller_allowed( *, tool_call: Any...
130
4,509
openai-agents-python
src/agents/run_internal/tool_planning.py
.py
from __future__ import annotations import asyncio import dataclasses as _dc import inspect import json from collections.abc import Awaitable, Callable, Hashable, Mapping, Sequence from typing import Any, TypeVar, cast from openai.types.responses import ResponseFunctionToolCall from openai.types.responses.response_inp...
1,102
43,377
openai-agents-python
src/agents/run_internal/streaming.py
.py
from __future__ import annotations import asyncio from ..items import ( CompactionItem, HandoffCallItem, HandoffOutputItem, MCPApprovalRequestItem, MCPApprovalResponseItem, MCPListToolsItem, MessageOutputItem, ReasoningItem, RunItem, ToolApprovalItem, ToolCallItem, Tool...
74
2,994
openai-agents-python
src/agents/run_internal/items.py
.py
""" Item utilities for the run pipeline. Hosts input normalization helpers and lightweight builders for synthetic run items or IDs used during tool execution. Internal use only. """ from __future__ import annotations import hashlib import json from collections import deque from collections.abc import Sequence from da...
1,098
42,114
openai-agents-python
src/agents/run_internal/turn_preparation.py
.py
from __future__ import annotations import inspect from typing import Any from ..agent import Agent from ..agent_output import AgentOutputSchema, AgentOutputSchemaBase from ..exceptions import UserError from ..handoffs import Handoff, handoff from ..items import TResponseInputItem from ..lifecycle import AgentHooksBas...
168
6,297
openai-agents-python
src/agents/extensions/handoff_prompt.py
.py
# A recommended prompt prefix for agents that use handoffs. We recommend including this or # similar instructions in any agents that use handoffs. RECOMMENDED_PROMPT_PREFIX = ( "# System context\n" "You are part of a multi-agent system called the Agents SDK, designed to make agent " "coordination and execut...
20
1,006
openai-agents-python
src/agents/extensions/visualization.py
.py
from __future__ import annotations import graphviz # type: ignore from agents import Agent from agents.handoffs import Handoff def _escape_label(name: str) -> str: """Escape a name for use inside a Graphviz double-quoted ID or label. Backslashes are escaped first, then double quotes and line breaks, so a ...
193
5,905
openai-agents-python
src/agents/extensions/__init__.py
.py
from .tool_output_trimmer import ToolOutputTrimmer __all__ = ["ToolOutputTrimmer"]
4
84
openai-agents-python
src/agents/extensions/handoff_filters.py
.py
"""Contains common handoff input filters, for convenience.""" from __future__ import annotations from ..handoffs import ( HandoffInputData, default_handoff_history_mapper, nest_handoff_history, ) from ..items import ( HandoffCallItem, HandoffOutputItem, MCPApprovalRequestItem, MCPApprovalR...
119
3,637
openai-agents-python
src/agents/extensions/tool_output_trimmer.py
.py
"""Built-in call_model_input_filter that trims large tool outputs from older turns. Agentic applications often accumulate large tool outputs (search results, code execution output, error analyses) that consume significant tokens but lose relevance as the conversation progresses. This module provides a configurable fil...
503
20,898
openai-agents-python
src/agents/extensions/sandbox/__init__.py
.py
try: from .e2b import ( E2BCloudBucketMountStrategy as E2BCloudBucketMountStrategy, E2BSandboxClient as E2BSandboxClient, E2BSandboxClientOptions as E2BSandboxClientOptions, E2BSandboxSession as E2BSandboxSession, E2BSandboxSessionState as E2BSandboxSessionState, E2BS...
214
7,038
openai-agents-python
src/agents/extensions/sandbox/_rclone.py
.py
from __future__ import annotations from ...sandbox.entries.mounts.patterns import RcloneMountPattern from ...sandbox.errors import MountConfigError from ...sandbox.session.base_sandbox_session import BaseSandboxSession _APT = "DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes apt-get -o Dpkg::Use-Pty=0" _RCLONE_C...
193
6,993
openai-agents-python
src/agents/extensions/sandbox/e2b/mounts.py
.py
"""Mount strategy for E2B sandboxes.""" from __future__ import annotations from pathlib import Path from typing import Literal from ....sandbox._mount_security import ( redact_mount_error_data, validate_mount_activation_credential_boundary, ) from ....sandbox.entries.mounts.base import InContainerMountStrate...
158
5,065
openai-agents-python
src/agents/extensions/sandbox/e2b/__init__.py
.py
from __future__ import annotations from .mounts import E2BCloudBucketMountStrategy from .sandbox import ( E2BSandboxClient, E2BSandboxClientOptions, E2BSandboxSession, E2BSandboxSessionState, E2BSandboxTimeouts, E2BSandboxType, _E2BSandboxFactoryAPI, _encode_e2b_snapshot_ref, _impor...
30
683
openai-agents-python
src/agents/extensions/sandbox/e2b/sandbox.py
.py
""" E2B sandbox (https://e2b.dev) implementation. Create an E2B account and export `E2B_API_KEY` to configure E2B locally. This module provides an E2B-backed sandbox client/session implementation backed by the E2B SDK sandbox classes. Note: The `e2b` and `e2b-code-interpreter` dependencies are intended to be optiona...
1,861
68,497
openai-agents-python
src/agents/extensions/sandbox/cloudflare/mounts.py
.py
from __future__ import annotations from dataclasses import dataclass from pathlib import Path from typing import Literal from ....sandbox._mount_security import redact_mount_error_data from ....sandbox.entries import GCSMount, Mount, R2Mount, S3Mount from ....sandbox.entries.mounts.base import MountStrategyBase from ...
250
9,140
openai-agents-python
src/agents/extensions/sandbox/cloudflare/__init__.py
.py
from __future__ import annotations from .mounts import CloudflareBucketMountConfig, CloudflareBucketMountStrategy from .sandbox import ( CloudflareSandboxClient, CloudflareSandboxClientOptions, CloudflareSandboxSession, CloudflareSandboxSessionState, ) __all__ = [ "CloudflareBucketMountConfig", ...
19
495
openai-agents-python
src/agents/extensions/sandbox/cloudflare/sandbox.py
.py
""" Cloudflare sandbox (https://developers.cloudflare.com/sandbox/) implementation. This module provides a Cloudflare Worker-backed sandbox client/session implementation. The sandbox communicates with a Cloudflare Worker service over HTTP and WebSocket. Note: The `aiohttp` dependency is intended to be optional (insta...
1,717
65,792
openai-agents-python
src/agents/extensions/sandbox/blaxel/mounts.py
.py
""" Mount strategies for Blaxel sandboxes. Two strategies are provided: * **BlaxelCloudBucketMountStrategy** -- mounts S3, R2, and GCS buckets via FUSE tools (``s3fs``, ``gcsfuse``) executed inside the sandbox. Credential-bearing mounts require an exact-path runtime acknowledgement on the trusted manifest. * **B...
752
26,926
openai-agents-python
src/agents/extensions/sandbox/blaxel/__init__.py
.py
from __future__ import annotations from ....sandbox.errors import ( ExposedPortUnavailableError, InvalidManifestPathError, WorkspaceArchiveReadError, ) from .mounts import ( BlaxelCloudBucketMountConfig, BlaxelCloudBucketMountStrategy, BlaxelDriveMount, BlaxelDriveMountConfig, BlaxelDri...
40
989
openai-agents-python
src/agents/extensions/sandbox/blaxel/sandbox.py
.py
""" Blaxel sandbox (https://blaxel.ai) implementation. This module provides a Blaxel-backed sandbox client/session implementation backed by ``blaxel.core.sandbox.SandboxInstance``. The ``blaxel`` dependency is optional, so package-level exports should guard imports of this module. Within this module, Blaxel SDK impor...
1,326
50,031
openai-agents-python
src/agents/extensions/sandbox/runloop/mounts.py
.py
"""Mount strategy for Runloop sandboxes.""" from __future__ import annotations from pathlib import Path from typing import Literal from ....sandbox._mount_security import ( redact_mount_error_data, validate_mount_activation_credential_boundary, ) from ....sandbox.entries.mounts.base import InContainerMountSt...
204
6,826
openai-agents-python
src/agents/extensions/sandbox/runloop/__init__.py
.py
from __future__ import annotations from .mounts import RunloopCloudBucketMountStrategy from .sandbox import ( DEFAULT_RUNLOOP_ROOT_WORKSPACE_ROOT, DEFAULT_RUNLOOP_WORKSPACE_ROOT, RunloopAfterIdle, RunloopExistingSecret, RunloopGatewaySpec, RunloopLaunchParameters, RunloopMcpSpec, Runloo...
54
1,545
openai-agents-python
src/agents/extensions/sandbox/runloop/sandbox.py
.py
""" Runloop sandbox (https://runloop.ai) implementation. This module provides a Runloop-backed sandbox client/session implementation backed by `runloop_api_client.sdk.AsyncRunloopSDK`. The `runloop_api_client` dependency is optional, so package-level exports should guard imports of this module. Within this module, Ru...
1,745
67,168
openai-agents-python
src/agents/extensions/sandbox/vercel/mounts.py
.py
"""Create-time-only S3 mounts for Vercel sandboxes.""" from __future__ import annotations import asyncio import shlex from pathlib import Path from typing import Literal, NoReturn from ....exceptions import _mark_error_data_redacted from ....sandbox._mount_security import ( discard_mount_source_exception, re...
606
21,207
openai-agents-python
src/agents/extensions/sandbox/vercel/__init__.py
.py
from __future__ import annotations from .mounts import VercelCloudBucketMountStrategy from .sandbox import ( VercelSandboxClient, VercelSandboxClientOptions, VercelSandboxSession, VercelSandboxSessionState, ) __all__ = [ "VercelCloudBucketMountStrategy", "VercelSandboxClient", "VercelSandb...
18
401
openai-agents-python
src/agents/extensions/sandbox/vercel/sandbox.py
.py
""" Vercel sandbox (https://vercel.com) implementation. This module provides a Vercel-backed sandbox client/session implementation backed by `vercel.sandbox.AsyncSandbox`. The `vercel` dependency is optional, so package-level exports should guard imports of this module. Within this module, Vercel SDK imports are norm...
1,702
66,363
openai-agents-python
src/agents/extensions/sandbox/modal/mounts.py
.py
from __future__ import annotations from dataclasses import dataclass from pathlib import Path from typing import Literal from ....sandbox._mount_security import redact_mount_error_data from ....sandbox.entries import GCSMount, Mount, R2Mount, S3Mount from ....sandbox.entries.mounts.base import MountStrategyBase from ...
211
8,302
openai-agents-python
src/agents/extensions/sandbox/modal/__init__.py
.py
from __future__ import annotations import tarfile from ....sandbox.snapshot import resolve_snapshot from .mounts import ModalCloudBucketMountConfig, ModalCloudBucketMountStrategy from .sandbox import ( _DEFAULT_TIMEOUT_S, _MODAL_STDIN_CHUNK_SIZE, ModalImageSelector, ModalSandboxClient, ModalSandbo...
38
990
openai-agents-python
src/agents/extensions/sandbox/modal/sandbox.py
.py
""" Modal sandbox (https://modal.com) implementation. Run `python -m modal setup` to configure Modal locally. This module provides a Modal-backed sandbox client/session implementation backed by `modal.Sandbox`. Note: The `modal` dependency is intended to be optional (installed via an extra), so package-level exports...
2,317
92,885
openai-agents-python
src/agents/extensions/sandbox/daytona/mounts.py
.py
"""Mount strategy for Daytona sandboxes. Provides ``DaytonaCloudBucketMountStrategy``, a wrapper around the generic :class:`InContainerMountStrategy` that ensures ``rclone`` is installed inside the sandbox before delegating to :class:`RcloneMountPattern`. Supports credentialless S3, R2, GCS, and Azure Blob mounts thr...
271
9,560
openai-agents-python
src/agents/extensions/sandbox/daytona/__init__.py
.py
from __future__ import annotations from ....sandbox.errors import ( ExposedPortUnavailableError, InvalidManifestPathError, WorkspaceArchiveReadError, ) from .mounts import DaytonaCloudBucketMountStrategy from .sandbox import ( DEFAULT_DAYTONA_WORKSPACE_ROOT, DaytonaSandboxClient, DaytonaSandbox...
32
832
openai-agents-python
src/agents/extensions/sandbox/daytona/sandbox.py
.py
""" Daytona sandbox (https://daytona.io) implementation. This module provides a Daytona-backed sandbox client/session implementation backed by `daytona.Sandbox` via the AsyncDaytona client. The `daytona` dependency is optional, so package-level exports should guard imports of this module. Within this module, Daytona ...
1,379
51,811
openai-agents-python
src/agents/extensions/experimental/__init__.py
.py
# This package contains experimental extensions to the agents package. # The interface and implementation details could be changed until being GAed. __all__ = [ "codex", "hosted_multi_agent", ]
8
203
openai-agents-python
src/agents/extensions/experimental/hosted_multi_agent/model.py
.py
from __future__ import annotations import asyncio import contextlib import weakref from collections import deque from collections.abc import AsyncIterator, Mapping from dataclasses import dataclass, field from typing import Any, Literal, cast, get_args, overload from openai import AsyncOpenAI from openai.resources.be...
974
39,729
openai-agents-python
src/agents/extensions/experimental/hosted_multi_agent/__init__.py
.py
"""Experimental OpenAI Responses hosted multi-agent support.""" from .model import ( HostedAgentMetadata, HostedMultiAgentConfig, OpenAIHostedMultiAgentModel, get_hosted_agent_metadata, ) __all__ = [ "HostedAgentMetadata", "HostedMultiAgentConfig", "OpenAIHostedMultiAgentModel", "get_h...
16
345
openai-agents-python
src/agents/extensions/experimental/codex/codex_options.py
.py
from __future__ import annotations from collections.abc import Mapping from dataclasses import dataclass, fields from typing import Any from agents.exceptions import UserError @dataclass(frozen=True) class CodexOptions: # Optional absolute path to the codex CLI binary. codex_path_override: str | None = None...
38
1,308
openai-agents-python
src/agents/extensions/experimental/codex/thread_options.py
.py
from __future__ import annotations from collections.abc import Mapping, Sequence from dataclasses import dataclass, fields from typing import Any, Literal from agents.exceptions import UserError ApprovalMode = Literal["never", "on-request", "on-failure", "untrusted"] SandboxMode = Literal["read-only", "workspace-wri...
53
2,065
openai-agents-python
src/agents/extensions/experimental/codex/exec.py
.py
from __future__ import annotations import asyncio import contextlib import os import platform import shutil import sys from collections.abc import AsyncGenerator from dataclasses import dataclass from pathlib import Path from agents.exceptions import UserError from .thread_options import ApprovalMode, ModelReasoning...
308
11,099
openai-agents-python
src/agents/extensions/experimental/codex/__init__.py
.py
from .codex import Codex from .codex_options import CodexOptions from .codex_tool import ( CodexToolOptions, CodexToolResult, CodexToolStreamEvent, OutputSchemaDescriptor, codex_tool, ) from .events import ( ItemCompletedEvent, ItemStartedEvent, ItemUpdatedEvent, ThreadError, Thr...
93
1,914
openai-agents-python
src/agents/extensions/experimental/codex/thread.py
.py
from __future__ import annotations import asyncio import contextlib from collections.abc import AsyncGenerator from dataclasses import dataclass from typing import Any, Literal, TypeAlias, cast from typing_extensions import TypedDict from .codex_options import CodexOptions from .events import ( ItemCompletedEven...
215
7,166
openai-agents-python
src/agents/extensions/experimental/codex/codex.py
.py
from __future__ import annotations from collections.abc import Mapping from typing import Any, overload from agents.exceptions import UserError from .codex_options import CodexOptions, coerce_codex_options from .exec import CodexExec from .thread import Thread from .thread_options import ThreadOptions, coerce_thread...
100
3,454
openai-agents-python
src/agents/extensions/experimental/codex/payloads.py
.py
from __future__ import annotations import dataclasses from collections.abc import Iterable from typing import Any, cast class _DictLike: def __getitem__(self, key: str) -> Any: if key in self._field_names(): return getattr(self, key) raise KeyError(key) def get(self, key: str, de...
32
892
openai-agents-python
src/agents/extensions/experimental/codex/output_schema_file.py
.py
from __future__ import annotations import json import os import shutil import tempfile from collections.abc import Callable from dataclasses import dataclass from typing import Any from agents.exceptions import UserError @dataclass class OutputSchemaFile: # Holds the on-disk schema path and cleanup callback. ...
52
1,536
openai-agents-python
src/agents/extensions/experimental/codex/codex_tool.py
.py
from __future__ import annotations import asyncio import copy import dataclasses import inspect import json import os import re from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping, MutableMapping from dataclasses import dataclass from typing import Any, Literal, TypeAlias, TypeGuard from openai.t...
1,437
49,479
openai-agents-python
src/agents/extensions/experimental/codex/turn_options.py
.py
from __future__ import annotations import asyncio from collections.abc import Mapping from dataclasses import dataclass, fields from typing import Any from agents.exceptions import UserError AbortSignal = asyncio.Event @dataclass(frozen=True) class TurnOptions: # JSON schema used by Codex for structured output...
37
1,124
openai-agents-python
src/agents/extensions/experimental/codex/items.py
.py
from __future__ import annotations from collections.abc import Mapping from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, Literal, TypeAlias, TypeGuard, cast from .payloads import _DictLike # Item payloads are emitted inside item.* events from the Codex CLI JSONL stream. if TYPE_CHECKIN...
244
7,183
openai-agents-python
src/agents/extensions/experimental/codex/events.py
.py
from __future__ import annotations from collections.abc import Mapping from dataclasses import dataclass, field from typing import Any, Literal, TypeAlias, cast from .items import ThreadItem, coerce_thread_item from .payloads import _DictLike # Event payloads emitted by the Codex CLI JSONL stream. @dataclass(froze...
161
4,911
openai-agents-python
src/agents/extensions/memory/encrypt_session.py
.py
"""Encrypted Session wrapper for secure conversation storage. This module provides transparent encryption for session storage with automatic expiration of old data. When TTL expires, expired items are silently skipped. Usage:: from agents.extensions.memory import EncryptedSession, SQLAlchemySession # Create...
261
9,175
openai-agents-python
src/agents/extensions/memory/dapr_session.py
.py
"""Dapr State Store-powered Session backend. Usage:: from agents.extensions.memory import DaprSession # Create from Dapr sidecar address session = DaprSession.from_address( session_id="user-123", state_store_name="statestore", dapr_address="localhost:50001", ) # Or pass a...
578
24,212
openai-agents-python
src/agents/extensions/memory/__init__.py
.py
"""Session memory backends living in the extensions namespace. This package contains optional, production-grade session implementations that introduce extra third-party dependencies (database drivers, ORMs, etc.). They conform to the [`Session`][agents.memory.session.Session] protocol so they can be used as a drop-in ...
75
2,688
openai-agents-python
src/agents/extensions/memory/sqlalchemy_session.py
.py
"""SQLAlchemy-powered Session backend. Usage:: from agents.extensions.memory import SQLAlchemySession # Create from SQLAlchemy URL (uses asyncpg driver under the hood for Postgres) session = SQLAlchemySession.from_url( session_id="user-123", url="postgresql+asyncpg://app:secret@db.example...
524
21,794
openai-agents-python
src/agents/extensions/memory/mongodb_session.py
.py
"""MongoDB-powered Session backend. Requires ``pymongo>=4.14``, which ships the native async API (``AsyncMongoClient``). Install it with:: pip install openai-agents[mongodb] Usage:: from agents.extensions.memory import MongoDBSession # Create from MongoDB URI session = MongoDBSession.from_uri( ...
596
24,068
openai-agents-python
src/agents/extensions/memory/async_sqlite_session.py
.py
from __future__ import annotations import asyncio import json from collections.abc import AsyncIterator from contextlib import asynccontextmanager from pathlib import Path from typing import Any, cast import aiosqlite from ...items import TResponseInputItem from ...memory import SessionABC from ...memory.session_set...
441
17,332
openai-agents-python
src/agents/extensions/memory/advanced_sqlite_session.py
.py
from __future__ import annotations import asyncio import json import logging import sqlite3 import time from contextlib import closing from pathlib import Path from typing import Any, ClassVar, cast from agents.result import RunResult from agents.usage import Usage from ... import _debug from ..._tool_identity impor...
1,973
84,166
openai-agents-python
src/agents/extensions/memory/redis_session.py
.py
"""Redis-powered Session backend. Usage:: from agents.extensions.memory import RedisSession # Create from Redis URL session = RedisSession.from_url( session_id="user-123", url="redis://localhost:6379/0", ) # Or pass an existing Redis client that your application already manages ...
787
32,696
openai-agents-python
src/agents/extensions/memory/_optional_imports.py
.py
from __future__ import annotations from typing import NoReturn def raise_optional_dependency_error( export_name: str, *, dependency_name: str, extra_name: str, cause: ImportError | None = None, ) -> NoReturn: error = ImportError( f"{export_name} requires the '{dependency_name}' extra....
20
466
openai-agents-python
src/agents/extensions/models/litellm_model.py
.py
from __future__ import annotations import asyncio import inspect import json import os import time from collections.abc import AsyncIterator from copy import copy from typing import Any, Literal, cast, overload from openai.types.responses.response_usage import OutputTokensDetails from agents.exceptions import ModelB...
1,069
45,658
openai-agents-python
src/agents/extensions/models/any_llm_provider.py
.py
from typing import Literal from ...models.default_models import get_default_model from ...models.interface import Model, ModelProvider from .any_llm_model import AnyLLMModel # This is kept for backward compatibility but using get_default_model() method is recommended. DEFAULT_MODEL: str = f"openai/{get_default_model(...
37
1,224
openai-agents-python
src/agents/extensions/models/litellm_provider.py
.py
from ...models.default_models import get_default_model from ...models.interface import Model, ModelProvider from .litellm_model import LitellmModel # This is kept for backward compatibility but using get_default_model() method is recommended. DEFAULT_MODEL: str = "gpt-4.1" class LitellmProvider(ModelProvider): "...
24
1,084
openai-agents-python
src/agents/extensions/models/any_llm_model.py
.py
from __future__ import annotations import asyncio import contextlib import importlib import inspect import json import time from collections.abc import AsyncGenerator, AsyncIterator, Iterable, Mapping from copy import copy from typing import TYPE_CHECKING, Any, Literal, cast, overload from openai import NotGiven, omi...
1,606
66,184
openai-agents-python
src/agents/voice/pipeline.py
.py
from __future__ import annotations import asyncio from typing import Any from .._config_coercion import coerce_dataclass_config from ..exceptions import UserError from ..logger import ( log_model_and_tool_action_error, log_model_and_tool_action_warning, logger, ) from ..tracing import TraceCtxManager from...
198
9,109
openai-agents-python
src/agents/voice/pipeline_config.py
.py
from __future__ import annotations from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any from .._config_coercion import _declared_dataclass_type, coerce_dataclass_config from ..tracing import TracingConfig from ..tracing.util import gen_group_id from .model import STTModelSettings, TTSModelSe...
80
3,082
openai-agents-python
src/agents/voice/workflow.py
.py
from __future__ import annotations import abc from collections.abc import AsyncIterator from typing import Any from ..agent import Agent from ..items import TResponseInputItem from ..result import RunResultStreaming from ..run import Runner class VoiceWorkflowBase(abc.ABC): """ A base class for a voice work...
102
3,807
openai-agents-python
src/agents/voice/utils.py
.py
import re from collections.abc import Callable def get_sentence_based_splitter( min_sentence_length: int = 20, ) -> Callable[[str], tuple[str, str]]: """Returns a function that splits text into chunks based on sentence boundaries. Args: min_sentence_length: The minimum length of a sentence to be ...
43
1,726
openai-agents-python
src/agents/voice/exceptions.py
.py
from ..exceptions import AgentsException class STTWebsocketConnectionError(AgentsException): """Exception raised when the STT websocket connection fails.""" def __init__(self, message: str): self.message = message
9
233
openai-agents-python
src/agents/voice/model.py
.py
from __future__ import annotations import abc from collections.abc import AsyncIterator, Callable from dataclasses import dataclass from typing import Any, Literal from .imports import np, npt from .input import AudioInput, StreamedAudioInput from .utils import get_sentence_based_splitter DEFAULT_TTS_INSTRUCTIONS = ...
195
5,956
openai-agents-python
src/agents/voice/__init__.py
.py
from .events import VoiceStreamEvent, VoiceStreamEventAudio, VoiceStreamEventLifecycle from .exceptions import STTWebsocketConnectionError from .input import AudioInput, StreamedAudioInput from .model import ( StreamedTranscriptionSession, STTModel, STTModelSettings, TTSModel, TTSModelSettings, ...
54
1,537
openai-agents-python
src/agents/voice/input.py
.py
from __future__ import annotations import asyncio import base64 import io import wave from dataclasses import dataclass from typing import cast from ..exceptions import UserError from .imports import np, npt DEFAULT_SAMPLE_RATE = 24000 def _buffer_to_audio_file( buffer: npt.NDArray[np.int16 | np.float32 | np.f...
131
4,849
openai-agents-python
src/agents/voice/testing.py
.py
"""Deterministic speech and workflow components for Voice pipeline tests.""" from __future__ import annotations import copy from collections.abc import AsyncIterator, Iterable, Sequence from dataclasses import dataclass, field from typing import Any from .imports import np from .input import AudioInput, StreamedAudi...
422
14,365
openai-agents-python
src/agents/voice/result.py
.py
from __future__ import annotations import asyncio import base64 from collections import deque from collections.abc import AsyncIterator from typing import Any from ..exceptions import UserError from ..logger import ( log_model_action_error, log_model_and_tool_action_error, logger, ) from ..tracing import ...
432
18,248
openai-agents-python
src/agents/voice/imports.py
.py
try: import numpy as np import numpy.typing as npt import websockets except ImportError as _e: raise ImportError( "`numpy` + `websockets` are required to use voice. You can install them via the optional " "dependency group: `pip install 'openai-agents[voice]'`." ) from _e __all__ = ...
12
348
openai-agents-python
src/agents/voice/events.py
.py
from __future__ import annotations from dataclasses import dataclass from typing import Literal, TypeAlias from .imports import np, npt @dataclass class VoiceStreamEventAudio: """Streaming event from the VoicePipeline""" data: npt.NDArray[np.int16 | np.float32] | None """The audio data.""" type: L...
46
1,176
openai-agents-python
src/agents/voice/models/openai_stt.py
.py
from __future__ import annotations import asyncio import base64 import json import time from collections.abc import AsyncIterator from dataclasses import dataclass from typing import Any, cast from openai import AsyncOpenAI from ... import _debug from ...exceptions import AgentsException, UserError from ...logger im...
557
20,826
openai-agents-python
src/agents/voice/models/openai_model_provider.py
.py
from __future__ import annotations from typing import Any import httpx2 from openai import AsyncOpenAI, DefaultAsyncHttpx2Client from ...exceptions import UserError from ...models import _openai_shared from ...models.openai_agent_registration import ( OpenAIAgentRegistrationConfig, ResolvedOpenAIAgentRegistr...
117
4,393