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
tests/sandbox/test_tar_utils.py
.py
from __future__ import annotations import io import os import stat import sys import tarfile from dataclasses import dataclass from pathlib import Path import pytest from agents.sandbox.util.tar_utils import ( UnsafeTarMemberError, safe_extract_tarfile, safe_tar_member_rel_path, strip_tar_member_pref...
492
16,528
openai-agents-python
tests/sandbox/_apply_patch_test_session.py
.py
from __future__ import annotations import io import uuid from pathlib import Path from agents.sandbox import Manifest from agents.sandbox.errors import WorkspaceReadNotFoundError from agents.sandbox.session.base_sandbox_session import BaseSandboxSession from agents.sandbox.snapshot import NoopSnapshot from agents.san...
153
4,660
openai-agents-python
tests/sandbox/test_memory.py
.py
from __future__ import annotations import asyncio import io import json import logging from dataclasses import dataclass from datetime import datetime from pathlib import Path from typing import Any, cast, get_type_hints import pytest from openai.types.responses import ResponseCustomToolCall, ResponseFunctionToolCall...
1,951
69,457
openai-agents-python
tests/sandbox/test_docker.py
.py
from __future__ import annotations import asyncio import builtins import errno import io import queue import shutil import socket import tarfile import threading import time import uuid from collections.abc import Callable, Iterator from pathlib import Path from typing import cast import docker.errors # type: ignore...
4,636
155,288
openai-agents-python
tests/sandbox/capabilities/test_apply_patch_tool.py
.py
from __future__ import annotations import asyncio import json from collections.abc import Awaitable from pathlib import Path, PureWindowsPath from typing import Any, cast import pytest import agents.sandbox.apply_patch as sandbox_apply_patch from agents import Agent, CustomTool, RunHooks from agents.editor import Ap...
627
23,354
openai-agents-python
tests/sandbox/capabilities/test_view_image_tool.py
.py
from __future__ import annotations import base64 import io from pathlib import Path from typing import cast import pytest from agents.sandbox import Manifest, SandboxPathGrant, SandboxWorkspaceScope from agents.sandbox.capabilities.tools import ViewImageArgs, ViewImageTool from agents.sandbox.errors import InvalidMa...
281
10,488
openai-agents-python
tests/sandbox/capabilities/test_shell_capability.py
.py
from __future__ import annotations import uuid from typing import Any, cast import pytest from agents.sandbox import Manifest, SandboxPathGrant, SandboxWorkspaceScope from agents.sandbox.capabilities import Shell, ShellToolSet from agents.sandbox.capabilities.tools import ( ExecCommandArgs, ExecCommandTool, ...
880
29,763
openai-agents-python
tests/sandbox/capabilities/test_filesystem_capability.py
.py
from __future__ import annotations import uuid from pathlib import Path from typing import Any, cast import pytest from agents.editor import ApplyPatchOperation from agents.sandbox import Manifest, SandboxWorkspaceScope from agents.sandbox.capabilities import Filesystem, FilesystemToolSet from agents.sandbox.capabil...
143
5,480
openai-agents-python
tests/sandbox/capabilities/test_skills_capability.py
.py
from __future__ import annotations import io import uuid from pathlib import Path, PurePath, PureWindowsPath from typing import cast import pytest from agents.sandbox import Manifest, SandboxPathGrant from agents.sandbox.capabilities import ( LazySkillSource, LocalDirLazySkillSource, Skill, SkillMeta...
1,074
41,103
openai-agents-python
tests/sandbox/capabilities/test_compaction_capability.py
.py
from __future__ import annotations from typing import cast import pytest from agents.items import TResponseInputItem from agents.sandbox.capabilities import Compaction, StaticCompactionPolicy class TestCompactionCapability: def test_sampling_params_uses_static_threshold(self) -> None: """Tests compacti...
103
3,525
openai-agents-python
tests/sandbox/capabilities/test_apply_patch_preflight.py
.py
from __future__ import annotations from typing import Any import pytest from agents import Agent, RunHooks from agents.items import ToolCallOutputItem from agents.run import RunConfig from agents.run_context import RunContextWrapper from agents.run_internal.run_steps import ToolRunCustom from agents.run_internal.too...
63
1,807
openai-agents-python
tests/sandbox/integration_tests/_helpers.py
.py
from __future__ import annotations import io import os import tarfile from collections.abc import Mapping from dataclasses import dataclass from pathlib import Path import pytest from agents import function_tool from agents.editor import ApplyPatchOperation from agents.sandbox.capabilities import Capability from age...
626
20,258
openai-agents-python
tests/sandbox/integration_tests/test_runner_pause_resume.py
.py
from __future__ import annotations from collections.abc import Sequence from pathlib import Path import pytest from agents import RunConfig, Runner, function_tool from agents.items import RunItem, ToolCallOutputItem from agents.run_state import RunState from agents.sandbox import SandboxAgent, SandboxRunConfig from ...
185
6,299
openai-agents-python
tests/sandbox/integration_tests/test_model.py
.py
from __future__ import annotations import json from collections.abc import Mapping, Sequence from typing import Any from agents.items import TResponseOutputItem from agents.testing import ScriptedModel from tests.test_responses import get_final_output_message, get_function_tool_call __test__ = False class TestMode...
60
1,653
openai-agents-python
tests/extensions/test_tool_output_trimmer.py
.py
"""Tests for ToolOutputTrimmer — the built-in call_model_input_filter for trimming large tool outputs from older conversation turns. """ from __future__ import annotations import copy import json from typing import Any, cast from unittest.mock import MagicMock import pytest from openai.types.responses import Respons...
1,168
43,720
openai-agents-python
tests/extensions/sandbox/test_runloop_capabilities_example.py
.py
from __future__ import annotations import importlib.util import sys import types from pathlib import Path from typing import Any, cast import pytest def _load_example_module() -> Any: path = ( Path(__file__).resolve().parents[3] / "examples" / "sandbox" / "extensions" / "...
351
11,602
openai-agents-python
tests/extensions/sandbox/test_cloudflare.py
.py
from __future__ import annotations import asyncio import base64 import io import json import tarfile import uuid from pathlib import Path from typing import Any, cast import aiohttp import pytest from agents.extensions.sandbox.cloudflare import ( CloudflareBucketMountStrategy, CloudflareSandboxClient, Cl...
2,159
76,635
openai-agents-python
tests/extensions/sandbox/test_vercel.py
.py
from __future__ import annotations import asyncio import builtins import importlib import io import json import sys import tarfile import types from collections.abc import Callable from pathlib import Path from typing import Any, Literal, cast import httpx import pytest from pydantic import BaseModel, PrivateAttr fr...
4,215
160,033
openai-agents-python
tests/extensions/sandbox/test_blaxel.py
.py
from __future__ import annotations import asyncio import io import json import logging import shlex import tarfile import time import uuid from dataclasses import FrozenInstanceError from pathlib import Path from typing import Any from unittest.mock import AsyncMock, MagicMock, patch import pytest from pydantic impor...
4,134
162,688
openai-agents-python
tests/extensions/sandbox/test_runloop_mounts.py
.py
from __future__ import annotations import io import types import uuid from pathlib import Path from typing import Any, cast import pytest from agents.sandbox import Manifest from agents.sandbox.entries import RcloneMountPattern, S3Mount from agents.sandbox.errors import MountConfigError from agents.sandbox.session.b...
227
7,443
openai-agents-python
tests/extensions/sandbox/test_runloop.py
.py
from __future__ import annotations import asyncio import builtins import importlib import io import json import shlex import sys import tarfile import types from pathlib import Path, PurePosixPath from typing import Any, Literal, cast import pytest from pydantic import BaseModel, Field, PrivateAttr from agents impor...
3,128
123,512
openai-agents-python
tests/extensions/sandbox/test_rclone.py
.py
from __future__ import annotations import pytest from agents.extensions.sandbox._rclone import ( _RCLONE_CHECKSUM_MISMATCH_EXIT, _RCLONE_SHA256_BY_ARCH, _RCLONE_VERSION, _rclone_arch, _rclone_install_command, ensure_rclone, ) from agents.sandbox.errors import MountConfigError from agents.sandb...
116
3,861
openai-agents-python
tests/extensions/sandbox/test_modal.py
.py
from __future__ import annotations import asyncio import builtins import importlib import io import os import sys import tarfile import types from collections.abc import Callable from pathlib import Path, PureWindowsPath from typing import Any, NoReturn, cast import pytest from pydantic import Field, PrivateAttr fro...
4,777
171,473
openai-agents-python
tests/extensions/sandbox/test_daytona.py
.py
from __future__ import annotations import asyncio import builtins import importlib import io import shlex import sys import types import uuid from collections import deque from pathlib import Path from typing import Any, Literal, cast from unittest.mock import AsyncMock, MagicMock, patch import pytest from pydantic i...
2,046
78,107
openai-agents-python
tests/extensions/sandbox/test_e2b.py
.py
from __future__ import annotations import asyncio import base64 import builtins import inspect import io import logging import shlex import tarfile import uuid from pathlib import Path from typing import Literal, cast import pytest from pydantic import Field, PrivateAttr import agents.extensions.sandbox.e2b.sandbox ...
2,671
90,807
openai-agents-python
tests/extensions/sandbox/test_blaxel_mounts.py
.py
from __future__ import annotations import shlex from agents.extensions.sandbox.blaxel.mounts import ( BlaxelCloudBucketMountConfig, _mount_gcs, _mount_s3, ) from agents.sandbox import ExecResult from agents.testing import scripted_sandbox_session _INJECTION = "x; touch /tmp/pwned" def _successful_exec(...
57
1,810
openai-agents-python
tests/extensions/experiemental/codex/test_payloads.py
.py
from __future__ import annotations import pytest from agents.extensions.experimental.codex.items import AgentMessageItem, TodoItem, TodoListItem def test_dict_like_supports_mapping_access_for_dataclass_fields() -> None: item = AgentMessageItem(id="item-1", text="hello") assert item["id"] == "item-1" as...
46
1,351
openai-agents-python
tests/extensions/experiemental/codex/test_codex_exec_thread.py
.py
from __future__ import annotations import asyncio import importlib import inspect import json import os from dataclasses import fields from pathlib import Path from typing import Any, cast import pytest from agents.exceptions import UserError from agents.extensions.experimental.codex import Usage from agents.extensi...
786
26,888
openai-agents-python
tests/extensions/experiemental/codex/test_codex_tool.py
.py
from __future__ import annotations import asyncio import copy import dataclasses import importlib import inspect import json from dataclasses import dataclass, fields from types import MappingProxyType, SimpleNamespace from typing import Any, cast import pytest from openai.types.responses import ResponseFunctionToolC...
2,299
75,382
openai-agents-python
tests/extensions/experimental/hosted_multi_agent/test_live.py
.py
from __future__ import annotations import json import os from typing import Any import pytest from openai import AsyncOpenAI from agents import Agent, ModelSettings, RunConfig, Runner, function_tool from agents.extensions.experimental.hosted_multi_agent import ( HostedMultiAgentConfig, OpenAIHostedMultiAgent...
180
6,755
openai-agents-python
tests/extensions/experimental/hosted_multi_agent/test_model.py
.py
from __future__ import annotations import asyncio from collections import deque from collections.abc import Mapping, Sequence from types import SimpleNamespace from typing import Any, cast import pytest from openai import omit from openai.types.responses import ( ResponseCompletedEvent, ResponseOutputItemDone...
1,208
38,685
openai-agents-python
tests/extensions/memory/test_async_sqlite_session.py
.py
"""Tests for AsyncSQLiteSession functionality.""" from __future__ import annotations import asyncio import json import sqlite3 import sys import tempfile from collections.abc import Sequence from datetime import datetime from pathlib import Path from typing import Any, cast import pytest pytest.importorskip("aiosql...
1,126
41,333
openai-agents-python
tests/extensions/memory/test_encrypt_session.py
.py
from __future__ import annotations import tempfile from pathlib import Path from typing import Any, cast import pytest pytest.importorskip("cryptography") # Skip tests if cryptography is not installed from cryptography.fernet import Fernet from agents import ( Agent, RunContextWrapper, Runner, Ses...
644
20,671
openai-agents-python
tests/extensions/memory/test_redis_session.py
.py
from __future__ import annotations import asyncio import json import sys import time from collections.abc import Awaitable from typing import Any, cast import pytest pytest.importorskip("redis") # Skip tests if Redis is not installed from agents import Agent, Runner, TResponseInputItem from agents.extensions.memor...
3,113
112,265
openai-agents-python
tests/extensions/memory/test_memory_imports.py
.py
from __future__ import annotations import importlib.abc import sys from types import ModuleType import pytest _PACKAGE_EXPORTS: tuple[tuple[str, str, str, str, str], ...] = ( ( "EncryptedSession", "agents.extensions.memory.encrypt_session", "agents.extensions.memory.encrypt_session", ...
155
4,918
openai-agents-python
tests/extensions/memory/test_dapr_redis_integration.py
.py
""" Integration tests for DaprSession with real Dapr sidecar and Redis using testcontainers. These tests use Docker containers for both Redis and Dapr, with proper networking. Tests are automatically skipped if dependencies (dapr, testcontainers, docker) are not available. Run with: pytest tests/extensions/memory/tes...
599
19,946
openai-agents-python
tests/extensions/memory/test_sqlalchemy_session.py
.py
from __future__ import annotations import asyncio import gc import json import threading from collections.abc import Iterable, Sequence from contextlib import asynccontextmanager from datetime import datetime, timedelta from pathlib import Path from typing import Any, cast import pytest from openai.types.responses.re...
1,327
47,055
openai-agents-python
tests/extensions/memory/test_mongodb_session.py
.py
"""Tests for MongoDBSession using in-process mock objects. All tests run without a real MongoDB server — or even the ``pymongo`` package — by injecting lightweight fake classes into ``sys.modules`` before the module under test is imported. This keeps the suite fast and dependency-free while exercising the full sessio...
1,485
55,241
openai-agents-python
tests/extensions/memory/test_advanced_sqlite_session.py
.py
"""Tests for AdvancedSQLiteSession functionality.""" import asyncio import contextlib import json import logging import multiprocessing import sqlite3 import sys import tempfile import threading import time from collections.abc import Iterator from pathlib import Path from typing import Any, cast from unittest.mock im...
4,311
162,227
openai-agents-python
tests/extensions/memory/test_dapr_session.py
.py
from __future__ import annotations import json from typing import Any from unittest.mock import Mock import pytest pytest.importorskip("dapr") # Skip tests if Dapr is not installed from agents import Agent, Runner, TResponseInputItem from agents.extensions.memory import ( DAPR_CONSISTENCY_EVENTUAL, DAPR_CO...
1,591
58,213
openai-agents-python
tests/fastapi/test_streaming_context.py
.py
import pytest from httpx import ASGITransport, AsyncClient from inline_snapshot import snapshot from agents.testing import ScriptedModel from ..test_responses import get_text_message from .streaming_app import agent, app @pytest.mark.asyncio async def test_streaming_context(): """This ensures that FastAPI strea...
43
1,872
openai-agents-python
tests/fastapi/streaming_app.py
.py
from collections.abc import AsyncIterator from fastapi import FastAPI from starlette.responses import StreamingResponse from agents import Agent, Runner, RunResultStreaming agent = Agent( name="Assistant", instructions="You are a helpful assistant.", ) app = FastAPI() @app.post("/stream") async def strea...
31
784
openai-agents-python
tests/voice/test_input.py
.py
import io import wave import numpy as np import pytest try: from agents import UserError from agents.voice import AudioInput, StreamedAudioInput from agents.voice.input import DEFAULT_SAMPLE_RATE, _buffer_to_audio_file except ImportError: pass def test_buffer_to_audio_file_int16(): # Create a si...
225
8,696
openai-agents-python
tests/voice/test_testing.py
.py
from __future__ import annotations from typing import Any, cast import numpy as np import pytest from agents.voice import ( AudioInput, StreamedAudioInput, STTModelSettings, TTSModelSettings, VoicePipeline, ) from agents.voice.events import VoiceStreamEventAudio, VoiceStreamEventLifecycle from ag...
544
18,324
openai-agents-python
tests/voice/test_openai_model_provider.py
.py
# Tests for the OpenAI voice model provider (OpenAIVoiceModelProvider). from typing import Any, cast import httpx2 import openai import pytest from agents.exceptions import UserError from agents.models import _openai_shared from agents.voice.models.openai_model_provider import OpenAIVoiceModelProvider, shared_http_c...
49
1,672
openai-agents-python
tests/voice/test_openai_stt.py
.py
# test_openai_stt_transcription_session.py import asyncio import base64 import json import logging import time from collections.abc import AsyncGenerator from typing import cast from unittest.mock import AsyncMock, MagicMock, patch import numpy as np import numpy.typing as npt import pytest import agents._debug as _...
841
29,643
openai-agents-python
tests/voice/pipeline_test_models.py
.py
from __future__ import annotations from collections.abc import AsyncIterator from typing import Literal import numpy as np import numpy.typing as npt from agents.voice import ( StreamedAudioInput, STTModelSettings, TTSModelSettings, ) from agents.voice.testing import ( ScriptedSTTModel, ScriptedT...
91
2,981
openai-agents-python
tests/voice/test_pipeline.py
.py
from __future__ import annotations import asyncio import gc import logging import weakref from collections.abc import AsyncGenerator, AsyncIterator from dataclasses import dataclass, field from typing import Any, Literal, cast from unittest.mock import patch import numpy as np import numpy.typing as npt import pytest...
1,611
56,603
openai-agents-python
tests/voice/test_workflow.py
.py
from __future__ import annotations import json import pytest from inline_snapshot import snapshot from agents import Agent from agents.testing import ScriptedModel from ..test_responses import get_function_tool, get_function_tool_call, get_text_message try: from agents.voice import SingleAgentVoiceWorkflow ex...
139
4,172
openai-agents-python
tests/voice/test_openai_tts.py
.py
# Tests for the OpenAI text-to-speech model (OpenAITTSModel). from types import SimpleNamespace from typing import Any import pytest from openai import omit try: from agents.voice import OpenAITTSModel, TTSModelSettings except ImportError: pass class _FakeStreamResponse: """A minimal async context mana...
139
4,404
openai-agents-python
tests/voice/helpers.py
.py
try: from agents.voice import StreamedAudioResult except ImportError: pass async def extract_events(result: StreamedAudioResult) -> tuple[list[str], list[bytes]]: """Collapse pipeline stream events to simple labels for ordering assertions.""" flattened: list[str] = [] audio_chunks: list[bytes] = [...
22
759
openai-agents-python
tests/voice/test_utils.py
.py
from __future__ import annotations import pytest from agents.voice import get_sentence_based_splitter def _stream(text: str, chunk_size: int, min_sentence_length: int = 20) -> list[str]: """Feed text through the splitter the way VoiceStreamedResult._add_text does.""" split = get_sentence_based_splitter(min_...
72
2,725
openai-agents-python
tests/model_settings/test_serialization.py
.py
import json from dataclasses import fields import pytest from openai.types.shared import Reasoning from pydantic import TypeAdapter from pydantic_core import to_json from agents.model_settings import MCPToolChoice, ModelSettings from agents.retry import ModelRetryBackoffSettings, ModelRetrySettings, retry_policies ...
418
13,910
openai-agents-python
tests/mcp/test_caching.py
.py
from unittest.mock import AsyncMock, call, patch import pytest from mcp.types import PaginatedRequestParams from agents import Agent from agents.mcp import MCPServerStdio from agents.run_context import RunContextWrapper from .helpers import DummyStreamsContextManager, tee from .model_compat import ListToolsResult, T...
197
8,062
openai-agents-python
tests/mcp/test_mcp_server_manager.py
.py
import asyncio import logging from collections.abc import Awaitable, Callable from typing import Any, cast import pytest from mcp.types import ( CallToolResult, GetPromptResult, ListPromptsResult, ListResourcesResult, ReadResourceResult, Tool as MCPTool, ) from agents import _debug from agents...
1,283
42,994
openai-agents-python
tests/mcp/test_runner_calls_mcp.py
.py
import json from typing import Any import pytest from pydantic import BaseModel from agents import ( Agent, FunctionTool, ModelBehaviorError, RunContextWrapper, Runner, UserError, default_tool_error_function, handoff, ) from agents.exceptions import AgentsException from agents.testing ...
403
12,333
openai-agents-python
tests/mcp/test_client_session_retries.py
.py
import asyncio import sys from contextlib import asynccontextmanager from typing import Any, cast import httpx import pytest from anyio import ClosedResourceError from mcp import ClientSession from mcp.types import ( CallToolResult, GetPromptResult, PaginatedRequestParams, Prompt, ) from agents.except...
867
29,097
openai-agents-python
tests/mcp/test_mcp_util.py
.py
import asyncio import copy import dataclasses import json import logging from typing import Any from unittest.mock import patch import pytest from inline_snapshot import snapshot from mcp import Tool as MCPToolType from mcp.types import CallToolResult as CallToolResultType, TextContent from pydantic import BaseModel, ...
2,907
99,911
openai-agents-python
tests/mcp/test_mcp_imports.py
.py
from __future__ import annotations import importlib import importlib.abc import sys from types import ModuleType import pytest _SERVER_EXPORTS = ( "LocalMCPApprovalCallable", "MCPServer", "MCPServerSse", "MCPServerSseParams", "MCPServerStdio", "MCPServerStdioParams", "MCPServerStreamableH...
74
2,188
openai-agents-python
tests/mcp/model_compat.py
.py
from __future__ import annotations from typing import Any, cast from mcp import Tool as _Tool from mcp.types import ( AudioContent as _AudioContent, CallToolResult as _CallToolResult, ImageContent as _ImageContent, InitializeResult as _InitializeResult, JSONRPCMessage as _JSONRPCMessage, ListP...
90
2,584
openai-agents-python
tests/mcp/test_streamable_http_session_id.py
.py
"""Tests for MCPServerStreamableHttp.session_id property (issue #924).""" from __future__ import annotations from unittest.mock import AsyncMock, MagicMock, patch import pytest from agents.mcp import MCPServerStreamableHttp from agents.mcp._compat import MCP_V2 class TestStreamableHttpSessionId: """Tests that...
118
5,307
openai-agents-python
tests/mcp/test_mcp_approval.py
.py
import asyncio import pytest from mcp.types import Tool as MCPTool from agents import Agent, RunContextWrapper, Runner from agents.exceptions import UserError from agents.testing import ScriptedModel from ..test_responses import get_function_tool_call, get_text_message from ..utils.hitl import queue_function_call_an...
242
8,409
openai-agents-python
tests/mcp/test_tool_filtering.py
.py
""" Tool filtering tests use FakeMCPServer instead of real MCPServer implementations to avoid external dependencies (processes, network connections) and ensure fast, reliable unit tests. FakeMCPServer delegates filtering logic to the real _MCPServerWithClientSession implementation. """ import asyncio import pytest fr...
280
9,928
openai-agents-python
tests/mcp/test_mcp_auth_params.py
.py
"""Tests for auth and httpx_client_factory params on MCPServerSse and MCPServerStreamableHttp.""" from __future__ import annotations from unittest.mock import MagicMock, patch import httpx import pytest from agents.mcp import MCPServerSse, MCPServerStreamableHttp from agents.mcp._compat import MCP_V2 from agents.mc...
183
7,396
openai-agents-python
tests/mcp/test_connect_disconnect.py
.py
from unittest.mock import AsyncMock, patch import pytest from agents.mcp import MCPServerStdio from .helpers import DummyStreamsContextManager, tee from .model_compat import ListToolsResult, Tool as MCPTool @pytest.mark.asyncio @patch("mcp.client.stdio.stdio_client", return_value=DummyStreamsContextManager()) @pat...
70
2,177
openai-agents-python
tests/mcp/test_mcp_pagination_integration.py
.py
from __future__ import annotations import sys from pathlib import Path import pytest from agents import Agent, Runner from agents.mcp import MCPServerStdio from agents.mcp._compat import MCP_V2, result_next_cursor from agents.testing import ScriptedModel from ..test_responses import get_function_tool_call, get_text...
72
2,229
openai-agents-python
tests/mcp/test_message_handler.py
.py
from __future__ import annotations import contextlib from typing import Any import anyio import pytest from mcp.client.session import MessageHandlerFnT from mcp.shared.message import SessionMessage from mcp.types import ( Implementation, ServerCapabilities, ) from agents.mcp._compat import MCP_V2 from agents...
131
3,550
openai-agents-python
tests/mcp/test_server_errors.py
.py
import asyncio import builtins import logging import sys import traceback from datetime import timedelta from unittest.mock import AsyncMock, MagicMock, patch import httpx import pytest from agents import Agent, _debug from agents.exceptions import UserError from agents.mcp._compat import MCP_V2 from agents.mcp.serve...
1,609
60,488
openai-agents-python
tests/mcp/test_prompt_server.py
.py
from typing import Any import pytest from mcp.types import ListResourcesResult, ReadResourceResult from agents import Agent, Runner from agents.mcp import MCPServer, MCPToolMetaResolver from agents.testing import ScriptedModel from ..test_responses import get_text_message from .model_compat import ListResourceTempla...
324
11,533
openai-agents-python
tests/mcp/test_mcp_v2_http.py
.py
from __future__ import annotations import asyncio import json import socket from typing import Any import httpx import mcp import pytest import uvicorn from mcp.server import Server from mcp.types import ListToolsResult, TextContent, Tool from agents.exceptions import UserError from agents.mcp import MCPServerStream...
379
11,807
openai-agents-python
tests/mcp/test_mcp_resources.py
.py
"""Tests for MCP server list_resources, list_resource_templates, and read_resource.""" from unittest.mock import AsyncMock, MagicMock import pytest from mcp.types import ( ListResourcesResult, PaginatedRequestParams, ReadResourceResult, ) from agents.mcp import MCPServerStreamableHttp from agents.mcp._co...
196
6,539
openai-agents-python
tests/mcp/helpers.py
.py
from __future__ import annotations import asyncio import json import shutil from typing import Any from mcp import Tool as MCPToolType from mcp.types import ( CallToolResult, ContentBlock, GetPromptResult, ListPromptsResult, ListResourcesResult, PromptMessage, ReadResourceResult, TextC...
166
5,717
openai-agents-python
tests/mcp/test_mcp_version_compat.py
.py
from __future__ import annotations import sys from pathlib import Path import pytest from agents.mcp import MCPServerStdio from agents.mcp._compat import MCP_V2, result_is_error LEGACY_SERVER_PATH = Path(__file__).parent / "servers" / "legacy.py" @pytest.mark.asyncio async def test_stdio_connects_to_legacy_server...
32
946
openai-agents-python
tests/mcp/test_mcp_tracing.py
.py
import json import pytest from inline_snapshot import snapshot from agents import Agent, RunConfig, Runner from agents.testing import ScriptedModel from ..test_responses import get_function_tool, get_function_tool_call, get_text_message from ..testing_processor import SPAN_PROCESSOR_TESTING, fetch_normalized_spans f...
314
11,049
openai-agents-python
tests/mcp/test_streamable_http_client_factory.py
.py
"""Tests for MCPServerStreamableHttp httpx_client_factory functionality.""" from __future__ import annotations import base64 import logging from unittest.mock import MagicMock, patch import httpx import pytest from anyio import create_memory_object_stream from mcp.shared.message import SessionMessage from mcp.types ...
499
18,242
openai-agents-python
tests/mcp/servers/legacy.py
.py
from __future__ import annotations import json import sys def send(message: dict[str, object]) -> None: sys.stdout.write(json.dumps(message) + "\n") sys.stdout.flush() def main() -> None: for line in sys.stdin: message = json.loads(line) request_id = message.get("id") method = m...
77
2,231
openai-agents-python
tests/mcp/servers/paginated.py
.py
from __future__ import annotations from importlib.metadata import version from typing import Any import anyio from mcp.server import Server from mcp.server.stdio import stdio_server from mcp.types import ( CallToolResult, ListPromptsRequest, ListPromptsResult as _ListPromptsResult, ListToolsRequest, ...
128
3,824
openai-agents-python
tests/utils/test_simple_session.py
.py
from __future__ import annotations from typing import cast import pytest from agents.items import TResponseInputItem from tests.utils.simple_session import CountingSession, IdStrippingSession, SimpleListSession @pytest.mark.asyncio async def test_simple_list_session_preserves_history_and_saved_items() -> None: ...
55
1,816
openai-agents-python
tests/utils/hitl.py
.py
from __future__ import annotations from collections.abc import Awaitable, Callable, Iterable, Sequence from dataclasses import dataclass from typing import Any, cast from openai.types.responses import ResponseFunctionToolCall from agents import Agent, Runner, RunResult, RunResultStreaming from agents.items import To...
493
15,405
openai-agents-python
tests/utils/simple_session.py
.py
from __future__ import annotations from typing import cast from agents.items import TResponseInputItem from agents.memory.session import Session from agents.memory.session_settings import SessionSettings class SimpleListSession(Session): """A minimal in-memory session implementation for tests.""" session_s...
83
2,728
openai-agents-python
tests/utils/factories.py
.py
from __future__ import annotations from collections.abc import Callable from typing import Any, Literal, TypeVar, cast from openai.types.responses import ( ResponseFunctionToolCall, ResponseOutputMessage, ResponseOutputText, ) from agents import Agent from agents._tool_identity import FunctionToolLookupK...
139
4,253
openai-agents-python
tests/utils/test_pretty_print_and_items.py
.py
from __future__ import annotations from openai.types.responses import ResponseOutputMessage, ResponseOutputText from agents import Agent from agents.exceptions import RunErrorDetails from agents.items import ItemHelpers, MessageOutputItem from agents.util._pretty_print import pretty_print_run_error_details def _mak...
89
3,377
openai-agents-python
tests/utils/test_json.py
.py
import json from types import MappingProxyType from openai.types.responses.response_output_message_param import ResponseOutputMessageParam from openai.types.responses.response_output_text_param import ResponseOutputTextParam from agents.util._json import _to_dump_compatible def test_to_dump_compatible(): # Give...
44
1,862
openai-agents-python
tests/fixtures/run_state/generate_corpus.py
.py
from __future__ import annotations import json import os import subprocess import tarfile import tempfile from dataclasses import dataclass from io import BytesIO from pathlib import Path from typing import cast ROOT = Path(__file__).resolve().parents[3] OUTPUT = Path(__file__).resolve().parent / "features" MINIMAL_O...
672
19,720
openai-agents-python
tests/realtime/test_model_events.py
.py
from typing import get_args import agents.realtime as realtime from agents.realtime.model_events import RealtimeModelEvent from agents.usage import Usage def test_all_events_have_type() -> None: """Test that all events have a type.""" events = get_args(RealtimeModelEvent) assert len(events) > 0 for e...
68
2,276
openai-agents-python
tests/realtime/test_app_server_debug.py
.py
from __future__ import annotations import importlib import logging from pathlib import Path from types import ModuleType import pytest from agents.realtime.events import RealtimeEventInfo, RealtimeRawModelEvent from agents.realtime.items import InputText, UserMessageItem from agents.realtime.model_events import Real...
45
1,454
openai-agents-python
tests/realtime/test_testing.py
.py
from __future__ import annotations import asyncio from collections.abc import Iterator from dataclasses import dataclass, field from typing import Any, cast import pytest from agents import Agent, handoff from agents.realtime import ( RealtimeModelConfig, RealtimeModelExceptionEvent, RealtimeModelListene...
1,370
46,137
openai-agents-python
tests/realtime/test_realtime_handoffs.py
.py
"""Tests for realtime handoff functionality.""" import asyncio import inspect from collections.abc import Awaitable, Coroutine from typing import Any, cast from unittest.mock import Mock import pytest from pydantic import BaseModel from agents import Agent from agents.exceptions import ModelBehaviorError, UserError ...
356
11,666
openai-agents-python
tests/realtime/test_ga_session_update_normalization.py
.py
from __future__ import annotations from typing import Any, cast import pytest from websockets.asyncio.client import ClientConnection from agents.realtime.openai_realtime import OpenAIRealtimeWebSocketModel class _DummyWS: def __init__(self) -> None: self.sent: list[str] = [] async def send(self, d...
36
1,031
openai-agents-python
tests/realtime/test_openai_realtime.py
.py
import asyncio import json import logging import time from types import SimpleNamespace from typing import Any, cast from unittest.mock import AsyncMock, Mock, patch import pytest import websockets from openai.types.realtime.realtime_session_create_request import RealtimeSessionCreateRequest from pydantic import TypeA...
3,615
138,521
openai-agents-python
tests/realtime/test_runner.py
.py
from unittest.mock import AsyncMock, Mock, patch import pytest from agents.realtime.agent import RealtimeAgent from agents.realtime.config import RealtimeRunConfig, RealtimeSessionModelSettings from agents.realtime.model import RealtimeModelConfig from agents.realtime.runner import RealtimeRunner from agents.realtime...
241
8,399
openai-agents-python
tests/realtime/test_session_payload_and_formats.py
.py
from __future__ import annotations from collections.abc import Mapping from typing import Any, cast import pydantic from openai.types.realtime.realtime_audio_config import RealtimeAudioConfig from openai.types.realtime.realtime_audio_formats import ( AudioPCM, AudioPCMA, AudioPCMU, ) from openai.types.rea...
124
4,498
openai-agents-python
tests/realtime/test_realtime_model_settings.py
.py
from __future__ import annotations import asyncio from typing import Any, cast from unittest.mock import AsyncMock import pytest from openai.types.realtime.realtime_session_create_request import ( RealtimeSessionCreateRequest, ) from openai.types.realtime.session_update_event import SessionUpdateEvent from agent...
462
15,659
openai-agents-python
tests/realtime/test_tracing.py
.py
from typing import cast from unittest.mock import AsyncMock, Mock, patch import pytest from openai.types.realtime.realtime_session_create_request import ( RealtimeSessionCreateRequest, ) from openai.types.realtime.realtime_tracing_config import TracingConfiguration from agents.realtime.agent import RealtimeAgent ...
266
10,932
openai-agents-python
tests/realtime/test_playback_tracker_manual_unit.py
.py
from agents.realtime.model import RealtimePlaybackTracker def test_playback_tracker_on_play_bytes_and_state(): tr = RealtimePlaybackTracker() tr.set_audio_format("pcm16") # PCM path # 48k bytes -> (48000 / (24000 * 2)) * 1000 = 1_000ms tr.on_play_bytes("item1", 0, b"x" * 48000) st = tr.get_state...
24
782
openai-agents-python
tests/realtime/test_item_parsing.py
.py
from openai.types.realtime.realtime_conversation_item_assistant_message import ( Content as AssistantMessageContent, RealtimeConversationItemAssistantMessage, ) from openai.types.realtime.realtime_conversation_item_system_message import ( Content as SystemMessageContent, RealtimeConversationItemSystemMe...
81
2,311
openai-agents-python
tests/realtime/test_openai_realtime_sip_model.py
.py
from __future__ import annotations import asyncio import pytest from agents.exceptions import UserError from agents.realtime.openai_realtime import OpenAIRealtimeSIPModel class _DummyWebSocket: def __init__(self) -> None: self.sent_messages: list[str] = [] self.closed = False def __aiter__...
57
1,590
openai-agents-python
tests/realtime/test_session.py
.py
import asyncio import dataclasses import json import logging import threading import traceback from pathlib import Path from typing import Any, Literal, cast from unittest.mock import AsyncMock, Mock, PropertyMock, patch import pytest from pydantic import BaseModel, ConfigDict import agents._debug as _debug from agen...
6,205
235,257
openai-agents-python
tests/realtime/test_agent.py
.py
from __future__ import annotations from typing import Any from unittest.mock import patch import pytest from agents import RunContextWrapper from agents.realtime.agent import RealtimeAgent def test_can_initialize_realtime_agent(): agent = RealtimeAgent(name="test", instructions="Hello") assert agent.name =...
101
3,684
openai-agents-python
tests/realtime/test_conversion_helpers.py
.py
from __future__ import annotations import base64 from unittest.mock import Mock import pytest from openai.types.realtime.conversation_item_create_event import ConversationItemCreateEvent from openai.types.realtime.conversation_item_truncate_event import ConversationItemTruncateEvent from openai.types.realtime.input_a...
381
14,288