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/realtime/test_twilio_sip_server.py | .py | from __future__ import annotations
import importlib
from types import ModuleType
from unittest.mock import AsyncMock, Mock
import pytest
#
# This is a unit test for examples/realtime/twilio_sip/server.py
# If this is no longer relevant in the future, we can remove it.
#
@pytest.fixture
def twilio_server(monkeypatc... | 76 | 2,249 |
openai-agents-python | tests/realtime/test_openai_realtime_conversions.py | .py | from typing import cast
import pytest
from openai.types.realtime.realtime_conversation_item_user_message import (
RealtimeConversationItemUserMessage,
)
from openai.types.realtime.realtime_response_usage import RealtimeResponseUsage
from openai.types.realtime.realtime_tracing_config import (
TracingConfigurati... | 296 | 10,331 |
openai-agents-python | tests/realtime/test_playback_tracker.py | .py | from unittest.mock import AsyncMock, patch
import pytest
from openai.types.realtime.realtime_audio_formats import AudioPCM, AudioPCMA, AudioPCMU
from agents.realtime._default_tracker import ModelAudioTracker
from agents.realtime.model import RealtimePlaybackTracker
from agents.realtime.model_inputs import RealtimeMod... | 308 | 13,525 |
openai-agents-python | tests/realtime/test_audio_formats_unit.py | .py | import logging
import math
from typing import Any
import pytest
from openai.types.realtime.realtime_audio_formats import AudioPCM, AudioPCMA, AudioPCMU
from agents import _debug
from agents.realtime.audio_formats import to_realtime_audio_format
def test_to_realtime_audio_format_from_strings():
assert to_realtim... | 161 | 6,405 |
openai-agents-python | tests/realtime/test_session_exceptions.py | .py | from __future__ import annotations
import asyncio
import json
from unittest.mock import AsyncMock, Mock
import pytest
import websockets.exceptions
from agents.realtime.events import RealtimeError
from agents.realtime.model_events import (
RealtimeModelErrorEvent,
RealtimeModelEvent,
RealtimeModelExceptio... | 224 | 8,663 |
openai-agents-python | tests/memory/test_session_persistence_sanitize.py | .py | from __future__ import annotations
from typing import Any, cast
import pytest
from agents.items import TResponseInputItem
from agents.run_internal.session_persistence import _sanitize_openai_conversation_item
def _sanitize(item: dict[str, Any]) -> dict[str, Any]:
return cast(dict[str, Any], _sanitize_openai_co... | 180 | 5,075 |
openai-agents-python | tests/memory/test_openai_conversations_session.py | .py | """Tests for OpenAI Conversations Session functionality."""
from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from openai.types.responses.response_output_item import Program, ProgramOutput
from agents import (
Agent... | 777 | 32,462 |
openai-agents-python | tests/memory/test_session_limit.py | .py | """Test session_limit parameter functionality via SessionSettings."""
import tempfile
from pathlib import Path
from typing import cast
import pytest
from agents import Agent, RunConfig, SQLiteSession
from agents.items import TResponseInputItem
from agents.memory import SessionSettings
from agents.testing import Scri... | 236 | 8,871 |
openai-agents-python | tests/memory/test_session.py | .py | """Tests for session memory functionality."""
import asyncio
import sqlite3
import tempfile
import threading
from pathlib import Path
from typing import Any, cast
import pytest
from agents import Agent, RunConfig, Runner, SessionSettings, SQLiteSession, TResponseInputItem
from agents.memory.sqlite_session import _aw... | 1,215 | 44,963 |
openai-agents-python | tests/memory/test_session_context_wrapper.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, cast
import pytest
from agents import Agent, RunContextWrapper, Runner, SessionSettings, TResponseInputItem
from agents.exceptions import InputGuardrailTripwireTriggered
from agents.guardrail import GuardrailFunctionOutput, ... | 460 | 15,992 |
openai-agents-python | tests/memory/test_openai_responses_compaction_session.py | .py | from __future__ import annotations
import asyncio
import logging
import warnings as warnings_module
from types import SimpleNamespace
from typing import Any, cast
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from openai.types.responses.response_usage import (
InputTokensDetails,
OutputT... | 1,804 | 69,390 |
openai-agents-python | tests/models/test_reasoning_content.py | .py | from __future__ import annotations
from collections.abc import AsyncIterator
from typing import Any, cast
import pytest
from openai.types.chat import ChatCompletion, ChatCompletionChunk, ChatCompletionMessage
from openai.types.chat.chat_completion_chunk import Choice, ChoiceDelta
from openai.types.completion_usage im... | 763 | 26,369 |
openai-agents-python | tests/models/test_litellm_logging_patch.py | .py | from __future__ import annotations
import importlib
import pytest
pytest.importorskip("litellm")
def test_litellm_logging_patch_env_var_controls_application(monkeypatch):
"""Assert the serializer patch only applies when the env var is enabled."""
litellm_logging = importlib.import_module("litellm.litellm_c... | 30 | 1,169 |
openai-agents-python | tests/models/test_default_models.py | .py | import os
from typing import Literal
from unittest.mock import patch
import pytest
from openai.types.shared.reasoning import Reasoning
from agents import Agent
from agents.model_settings import ModelSettings
from agents.models import (
get_default_model,
get_default_model_settings,
gpt_5_reasoning_setting... | 202 | 9,377 |
openai-agents-python | tests/models/test_model_payload_iterators.py | .py | from __future__ import annotations
from collections.abc import Iterable, Iterator
from typing import Any, cast
import httpx
import pytest
from openai import omit
from openai.types.chat.chat_completion import ChatCompletion
from agents import (
ModelSettings,
ModelTracing,
OpenAIChatCompletionsModel,
... | 187 | 5,848 |
openai-agents-python | tests/models/test_openai_responses_converter.py | .py | # Copyright (c) OpenAI
#
# Licensed under the MIT License.
# See LICENSE file in the project root for full license information.
"""
Unit tests for the `Converter` class defined in
`agents.models.openai_responses`. The converter is responsible for
translating various agent tool types and output schemas into the paramet... | 1,159 | 38,536 |
openai-agents-python | tests/models/test_litellm_user_agent.py | .py | from __future__ import annotations
from typing import Any
import pytest
from agents import ModelSettings, ModelTracing, __version__
from agents.models.chatcmpl_helpers import HEADERS_OVERRIDE
@pytest.mark.allow_call_model_methods
@pytest.mark.asyncio
@pytest.mark.parametrize("override_ua", [None, "test_user_agent"... | 90 | 2,672 |
openai-agents-python | tests/models/test_trace_config.py | .py | from agents.model_settings import ModelSettings
from agents.models._trace import model_config_for_trace, sanitize_url_for_trace
def test_sanitize_url_for_trace_strips_auth_query_and_fragment() -> None:
assert (
sanitize_url_for_trace("https://user:pass@example.com/v1?api-key=secret#fragment")
== "... | 33 | 1,297 |
openai-agents-python | tests/models/test_openai_client_utils.py | .py | from __future__ import annotations
import pytest
from agents.models.openai_client_utils import (
is_official_openai_base_url,
is_official_openai_client,
)
@pytest.mark.parametrize(
"base_url",
[
"https://api.openai.com",
"https://api.openai.com/v1/",
],
)
def test_official_openai... | 44 | 1,249 |
openai-agents-python | tests/models/test_litellm_logprobs.py | .py | import litellm
import pytest
from litellm.types.utils import (
ChatCompletionTokenLogprob,
ChoiceLogprobs,
Choices,
Message,
ModelResponse,
TopLogprob,
Usage,
)
from openai.types.responses import ResponseOutputMessage, ResponseOutputText
from agents.extensions.models.litellm_model import Li... | 122 | 4,481 |
openai-agents-python | tests/models/test_remove_openai_responses_api_incompatible_fields.py | .py | from __future__ import annotations
from typing import Any, cast
from unittest.mock import MagicMock
import pytest
from agents import Agent, ModelSettings
from agents.items import TResponseInputItem
from agents.models.fake_id import FAKE_RESPONSES_ID
from agents.models.openai_responses import OpenAIResponsesModel
fro... | 206 | 7,994 |
openai-agents-python | tests/models/test_extended_thinking_message_order.py | .py | """Tests for the extended thinking message order bug fix in LitellmModel."""
from __future__ import annotations
from typing import Any, cast
from openai.types.chat import ChatCompletionMessageParam
from agents.extensions.models.litellm_model import LitellmModel
class TestExtendedThinkingMessageOrder:
"""Test ... | 355 | 14,803 |
openai-agents-python | tests/models/test_responses_websocket_session.py | .py | import importlib
import pytest
from agents import Agent, ResponsesWebSocketSession, RunConfig, responses_websocket_session
from agents.models.multi_provider import MultiProvider
from agents.models.openai_provider import OpenAIProvider
@pytest.mark.asyncio
async def test_responses_websocket_session_builds_shared_run... | 179 | 6,324 |
openai-agents-python | tests/models/test_deepseek_reasoning_content.py | .py | from typing import Any
import litellm
import pytest
from litellm.types.utils import (
ChatCompletionMessageToolCall,
Choices,
Function,
Message,
ModelResponse,
Usage,
)
from agents.extensions.models.litellm_model import LitellmModel
from agents.model_settings import ModelSettings
from agents.m... | 362 | 12,942 |
openai-agents-python | tests/models/test_openai_responses.py | .py | from __future__ import annotations
import asyncio
import json
from types import SimpleNamespace
from typing import Any, cast
import httpx2
import pytest
from openai import NOT_GIVEN, APIConnectionError, AsyncOpenAI, RateLimitError, omit
from openai.types.responses import Response, ResponseCompletedEvent, ResponseErro... | 4,818 | 154,222 |
openai-agents-python | tests/models/test_litellm_chatcompletions_stream.py | .py | import asyncio
from collections.abc import AsyncIterator
from typing import Any, cast
import pytest
from openai.types.chat.chat_completion_chunk import (
ChatCompletionChunk,
Choice,
ChoiceDelta,
ChoiceDeltaToolCall,
ChoiceDeltaToolCallFunction,
)
from openai.types.completion_usage import (
Com... | 1,040 | 38,657 |
openai-agents-python | tests/models/test_any_llm_model.py | .py | from __future__ import annotations
import asyncio
import importlib
import sys
import types as pytypes
from collections.abc import AsyncIterator
from typing import Any, Literal, cast
import pytest
from openai.types.chat import (
ChatCompletion,
ChatCompletionChunk,
ChatCompletionMessage,
ChatCompletion... | 2,208 | 77,281 |
openai-agents-python | tests/models/test_model_retry.py | .py | from __future__ import annotations
import asyncio
from collections.abc import AsyncIterator
from contextvars import ContextVar
from typing import Any, cast
import httpx2
import pytest
from openai import APIConnectionError, APIStatusError, BadRequestError
from pydantic import ValidationError
from agents.exceptions im... | 3,715 | 113,425 |
openai-agents-python | tests/models/test_litellm_extra_body.py | .py | import logging
import litellm
import pytest
from litellm.types.utils import Choices, Message, ModelResponse, Usage
from openai.types.shared import Reasoning
from agents import function_tool
from agents.extensions.models.litellm_model import LitellmModel
from agents.model_settings import ModelSettings
from agents.mode... | 316 | 10,570 |
openai-agents-python | tests/models/test_map.py | .py | import asyncio
from typing import Any, cast
import pytest
from agents import (
Agent,
MultiProvider,
OpenAIResponsesModel,
OpenAIResponsesWSModel,
RunConfig,
UserError,
)
from agents.extensions.models.litellm_model import LitellmModel
from agents.models.multi_provider import MultiProviderMap
f... | 304 | 9,929 |
openai-agents-python | tests/models/test_openai_chatcompletions_converter.py | .py | # Copyright (c) OpenAI
#
# Licensed under the MIT License.
# See LICENSE file in the project root for full license information.
"""
Unit tests for the internal `Converter` class defined in
`agents.models.openai_chatcompletions`. The converter is responsible for
translating between internal "item" structures (e.g., `Re... | 917 | 32,724 |
openai-agents-python | tests/models/test_openai_chatcompletions.py | .py | from __future__ import annotations
import logging
from collections.abc import AsyncIterator
from typing import Any, cast
import httpx2
import pytest
from openai import APIConnectionError, APIStatusError, AsyncOpenAI, omit
from openai._models import add_request_id
from openai.types.chat.chat_completion import ChatComp... | 1,593 | 54,532 |
openai-agents-python | tests/models/test_gemini_thought_signatures.py | .py | """
Test for Gemini thought signatures in function calling.
Validates that thought signatures are preserved through the bidirectional roundtrip:
- Gemini chatcmpl message → response item → back to message
"""
from __future__ import annotations
from typing import Any
from openai.types.chat.chat_completion_message_to... | 127 | 5,033 |
openai-agents-python | tests/models/test_kwargs_functionality.py | .py | from typing import Any
import httpx2
import litellm
import pytest
from httpx import Headers, Response
from litellm.exceptions import RateLimitError
from litellm.types.utils import Choices, Message, ModelResponse, Usage
from openai import APIConnectionError, omit
from openai.types.chat.chat_completion import ChatComple... | 459 | 15,318 |
openai-agents-python | tests/models/test_openai_chatcompletions_stream.py | .py | import asyncio
import logging
from collections.abc import AsyncIterator
from typing import Any, cast
import httpx2
import pytest
from openai.types.chat.chat_completion import ChatCompletion, Choice as ChatCompletionChoice
from openai.types.chat.chat_completion_chunk import (
ChatCompletionChunk,
Choice,
Ch... | 4,217 | 150,563 |
openai-agents-python | tests/models/test_openai_retry_helpers.py | .py | """Unit tests for the low-level helpers in :mod:`agents.models._openai_retry`.
These exercise the header-parsing, status-extraction, and error-code helpers
directly, plus a few public ``get_openai_retry_advice`` branches that the broader
behavioral suite in ``test_model_retry.py`` does not reach.
"""
from __future__ ... | 194 | 6,937 |
openai-agents-python | tests/models/test_litellm_content_filter.py | .py | import litellm
import pytest
from litellm.types.utils import Choices, Message, ModelResponse, Usage
from openai.types.responses import ResponseOutputMessage, ResponseOutputRefusal
from agents.extensions.models.litellm_model import LitellmModel
from agents.model_settings import ModelSettings
from agents.models.interfac... | 90 | 3,374 |
openai-agents-python | tests/models/test_anthropic_thinking_blocks.py | .py | """
Test for Anthropic thinking blocks in conversation history.
This test validates the fix for issue #1704:
- Thinking blocks are properly preserved from Anthropic responses
- Reasoning items are stored in session but not sent back in conversation history
- Non-reasoning models are unaffected
- Token usage is not inc... | 681 | 26,062 |
openai-agents-python | tests/models/test_litellm_usage_requests.py | .py | import litellm
import pytest
from litellm.types.utils import Choices, Message, ModelResponse
from agents.extensions.models.litellm_model import LitellmModel
from agents.model_settings import ModelSettings
from agents.models.interface import ModelTracing
async def _get_response(monkeypatch, *, response: ModelResponse... | 46 | 1,565 |
openai-agents-python | tests/models/test_reasoning_content_replay_hook.py | .py | from __future__ import annotations
from typing import Any, cast
import httpx
import litellm
import pytest
from litellm.types.utils import Choices, Message, ModelResponse, Usage
from openai.types.chat.chat_completion import ChatCompletion, Choice
from openai.types.chat.chat_completion_message import ChatCompletionMess... | 404 | 15,391 |
openai-agents-python | tests/models/test_agent_registration.py | .py | from __future__ import annotations
import pytest
from agents import (
OpenAIAgentRegistrationConfig,
RunConfig,
set_default_openai_agent_registration,
set_default_openai_harness,
)
from agents.models.multi_provider import MultiProvider
from agents.models.openai_agent_registration import (
OPENAI_H... | 199 | 7,230 |
openai-agents-python | tests/models/test_gemini_thought_signatures_stream.py | .py | """
Test for Gemini thought signatures in streaming function calls.
Validates that thought signatures are captured from streaming chunks
and included in the final function call events.
"""
from __future__ import annotations
from collections.abc import AsyncIterator
from typing import Any, cast
import pytest
from op... | 211 | 6,375 |
openai-agents-python | integration_tests/_contract_support.py | .py | from __future__ import annotations
import dataclasses
import enum
import importlib
import inspect
import json
import logging
import sys
import traceback
from collections.abc import Callable, Iterable, Mapping
from copy import deepcopy
from importlib.util import find_spec
from pathlib import Path
from types import Func... | 2,119 | 89,064 |
openai-agents-python | integration_tests/conftest.py | .py | from __future__ import annotations
import importlib
import os
import sys
from collections.abc import Iterator
from dataclasses import dataclass
from pathlib import Path
import pytest
LIVE_MARKERS = frozenset({"core", "providers", "realtime", "voice", "hosted"})
@dataclass(frozen=True)
class ExternalProvider:
n... | 260 | 8,820 |
openai-agents-python | integration_tests/security/test_packaged_mount_redaction.py | .py | from __future__ import annotations
import io
import logging
import uuid
from pathlib import Path
from typing import Literal
import pytest
from agents.sandbox import Manifest
from agents.sandbox.entries import FuseMountPattern, MountpointMountPattern
from agents.sandbox.entries.mounts.patterns import FuseMountConfig,... | 177 | 5,939 |
openai-agents-python | integration_tests/security/test_local_sandbox_isolation.py | .py | from __future__ import annotations
import json
import logging
import os
import uuid
from pathlib import Path
from typing import Any, cast
import pytest
from openai.types.responses import (
ResponseFunctionToolCall,
ResponseOutputMessage,
ResponseOutputText,
)
from agents import RunConfig, Runner
from age... | 376 | 13,872 |
openai-agents-python | integration_tests/packaging/test_optional_extras.py | .py | from __future__ import annotations
import importlib
import os
from pathlib import Path
import pytest
pytestmark = pytest.mark.extras
def test_requested_optional_extra_imports_from_its_standalone_environment() -> None:
optional_extra = os.environ["OPENAI_AGENTS_INTEGRATION_EXTRA"]
module_names = {
"... | 61 | 1,931 |
openai-agents-python | integration_tests/packaging/test_released_api_contract.py | .py | import os
from importlib.metadata import metadata, requires, version
from importlib.util import find_spec
from pathlib import Path
import pytest
from packaging.requirements import Requirement
from packaging.utils import canonicalize_name
from integration_tests._contract_support import (
load_api_contract,
val... | 223 | 9,014 |
openai-agents-python | integration_tests/packaging/mcp_legacy_server.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... | 69 | 1,967 |
openai-agents-python | integration_tests/packaging/test_mcp_compat.py | .py | from __future__ import annotations
import importlib.metadata
import os
import sys
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from agents.mcp import MCPServerSse, MCPServerStdio, MCPServerStreamableHttp
pytestmark = pytest.mark.mcp_compat
LEGACY_SERVER_PATH = Path(__file__).wi... | 87 | 2,784 |
openai-agents-python | integration_tests/packaging/test_distribution_contents.py | .py | from __future__ import annotations
import importlib
import importlib.metadata
import importlib.util
import os
import sys
import tarfile
import warnings
import zipfile
from pathlib import Path
import pytest
pytestmark = pytest.mark.packaging
def test_wheel_excludes_integration_tests_and_contains_runtime_modules() -... | 180 | 6,431 |
openai-agents-python | integration_tests/packaging/test_provider_selection.py | .py | from __future__ import annotations
import runpy
from pathlib import Path
from types import SimpleNamespace
from typing import cast
import pytest
from integration_tests.conftest import _external_providers, pytest_runtest_setup
pytestmark = pytest.mark.packaging
def _configure_provider_credentials(monkeypatch: pyte... | 260 | 9,603 |
openai-agents-python | integration_tests/packaging/test_run_state_compatibility.py | .py | import json
import logging
from pathlib import Path
import pytest
from agents import Agent, RunState
from agents.run_state import SUPPORTED_SCHEMA_VERSIONS
from integration_tests._contract_support import (
_deserialize_common_sandbox_session_state,
_redaction_observables,
validate_historical_resume_behavi... | 141 | 4,886 |
openai-agents-python | integration_tests/openai/test_approval_resume.py | .py | from __future__ import annotations
from pathlib import Path
import pytest
from agents import (
Agent,
RunConfig,
Runner,
RunResult,
RunResultStreaming,
RunState,
SQLiteSession,
ToolCallOutputItem,
)
from agents.decorators import tool
pytestmark = pytest.mark.core
@pytest.mark.param... | 180 | 6,466 |
openai-agents-python | integration_tests/openai/test_retry.py | .py | from __future__ import annotations
from pathlib import Path
from typing import Any
import httpx2
import pytest
from openai import APIConnectionError, AsyncOpenAI
from agents import (
Agent,
ModelRetrySettings,
ModelSettings,
OpenAIResponsesModel,
RunConfig,
Runner,
RunResult,
RunResul... | 81 | 2,531 |
openai-agents-python | integration_tests/openai/test_handoffs.py | .py | from __future__ import annotations
import pytest
from agents import (
Agent,
RunConfig,
Runner,
RunResult,
RunResultStreaming,
ToolCallItem,
ToolCallOutputItem,
handoff,
)
from agents.decorators import tool
from agents.extensions.handoff_filters import remove_all_tools
pytestmark = py... | 112 | 3,889 |
openai-agents-python | integration_tests/openai/test_sessions.py | .py | from __future__ import annotations
from pathlib import Path
from typing import Literal
import pytest
from openai import AsyncOpenAI
from agents import (
Agent,
ModelSettings,
OpenAIConversationsSession,
OpenAIResponsesCompactionSession,
RunConfig,
Runner,
RunResult,
RunResultStreaming... | 311 | 9,921 |
openai-agents-python | integration_tests/openai/test_tracing.py | .py | from __future__ import annotations
from typing import Any, cast
import pytest
from agents import (
Agent,
RunConfig,
Runner,
RunResult,
RunResultStreaming,
Span,
Trace,
TracingProcessor,
set_trace_processors,
set_tracing_disabled,
)
from agents.decorators import tool
from agen... | 110 | 3,737 |
openai-agents-python | integration_tests/openai/test_execution_controls.py | .py | from __future__ import annotations
import asyncio
from pathlib import Path
from typing import Any, cast
import pytest
from openai.types.responses import ResponseReasoningItem
from agents import (
Agent,
AgentHookContext,
ModelSettings,
RunConfig,
RunContextWrapper,
RunErrorHandlerInput,
R... | 493 | 17,335 |
openai-agents-python | integration_tests/openai/test_model_settings.py | .py | from __future__ import annotations
from typing import Any
import pytest
from openai.resources.responses import AsyncResponses
from openai.types.shared import Reasoning
from agents import Agent, ModelSettings, RunConfig, Runner
from agents.retry import ModelRetryBackoffSettings, ModelRetrySettings
pytestmark = pytes... | 110 | 4,301 |
openai-agents-python | integration_tests/openai/test_websocket.py | .py | from __future__ import annotations
from collections.abc import Mapping
from typing import Any
import pytest
from agents import (
Agent,
ModelSettings,
ToolCallOutputItem,
responses_websocket_session,
)
from agents.decorators import tool
from agents.models.openai_responses import OpenAIResponsesWSMode... | 73 | 2,486 |
openai-agents-python | integration_tests/openai/test_guardrails.py | .py | from __future__ import annotations
from typing import Any
import pytest
from agents import (
Agent,
GuardrailFunctionOutput,
InputGuardrailTripwireTriggered,
OutputGuardrailTripwireTriggered,
RunConfig,
RunContextWrapper,
Runner,
ToolExecutionConfig,
ToolGuardrailFunctionOutput,
... | 193 | 6,167 |
openai-agents-python | integration_tests/openai/test_responses.py | .py | from __future__ import annotations
from typing import Any
import pytest
from openai.resources.responses import AsyncResponses
from pydantic import BaseModel
from agents import (
Agent,
ModelSettings,
RunConfig,
Runner,
RunResult,
RunResultStreaming,
)
from agents.decorators import tool
from a... | 191 | 6,397 |
openai-agents-python | integration_tests/openai/test_chat_completions.py | .py | from __future__ import annotations
from typing import Any
import pytest
from openai import AsyncOpenAI
from pydantic import BaseModel
from agents import Agent, RunConfig, Runner, RunResult, RunResultStreaming
from agents.decorators import tool
from agents.models.openai_chatcompletions import OpenAIChatCompletionsMod... | 105 | 3,445 |
openai-agents-python | integration_tests/voice/test_voice_pipeline.py | .py | from __future__ import annotations
import asyncio
from collections.abc import AsyncIterator
from typing import Any
import pytest
from agents import Agent
pytestmark = pytest.mark.voice
@pytest.mark.parametrize("audio_dtype", ["int16", "float32"])
async def test_static_voice_pipeline_transcribes_and_synthesizes_wi... | 255 | 8,706 |
openai-agents-python | integration_tests/realtime/test_realtime.py | .py | from __future__ import annotations
import asyncio
import pytest
from agents import GuardrailFunctionOutput, ToolGuardrailFunctionOutput, ToolInputGuardrailData
from agents.decorators import output_guardrail, tool, tool_input_guardrail
from agents.realtime import (
AssistantMessageItem,
AssistantText,
Inp... | 516 | 18,394 |
openai-agents-python | integration_tests/hosted/test_multi_agent.py | .py | from __future__ import annotations
import os
from typing import Any
import pytest
from agents import Agent, RunConfig, Runner, RunResult, RunResultStreaming
from agents.decorators import tool
from agents.extensions.experimental.hosted_multi_agent import (
HostedMultiAgentConfig,
OpenAIHostedMultiAgentModel,
... | 70 | 2,434 |
openai-agents-python | integration_tests/hosted/test_tool_search.py | .py | from __future__ import annotations
import pytest
from agents import (
Agent,
ModelSettings,
RunConfig,
Runner,
RunResult,
RunResultStreaming,
ToolCallItem,
ToolCallOutputItem,
ToolSearchCallItem,
ToolSearchOutputItem,
ToolSearchTool,
tool_namespace,
)
from agents.decora... | 125 | 4,149 |
openai-agents-python | integration_tests/hosted/test_programmatic_tool_calling.py | .py | from __future__ import annotations
import json
from typing import Any, cast
import pytest
from openai.types.responses import ResponseFunctionToolCall
from openai.types.responses.response_output_item import Program
from pydantic import BaseModel
from agents import (
Agent,
ModelSettings,
ProgrammaticToolC... | 292 | 10,817 |
openai-agents-python | integration_tests/hosted/test_mcp.py | .py | from __future__ import annotations
import os
import pytest
from agents import Agent, HostedMCPTool, ModelSettings, RunConfig, Runner, RunState
from agents.items import (
MCPApprovalRequestItem,
MCPApprovalResponseItem,
MCPListToolsItem,
ToolCallItem,
)
from agents.model_settings import MCPToolChoice
... | 159 | 5,312 |
openai-agents-python | integration_tests/hosted/test_web_search.py | .py | from __future__ import annotations
import pytest
from agents import Agent, RunConfig, Runner, ToolCallItem, WebSearchTool
pytestmark = pytest.mark.hosted
async def test_web_search_emits_provider_owned_call_items(integration_model: str) -> None:
agent = Agent(
name="Packaged web search agent",
m... | 32 | 1,034 |
openai-agents-python | integration_tests/hosted/test_local_tool_families.py | .py | from __future__ import annotations
from typing import Any
import pytest
from agents import (
Agent,
CustomTool,
ModelSettings,
RunConfig,
Runner,
RunResult,
RunResultStreaming,
RunState,
ShellCommandRequest,
ShellTool,
ToolCallOutputItem,
)
from agents.tool_context import ... | 204 | 7,405 |
openai-agents-python | integration_tests/hosted/test_code_interpreter.py | .py | from __future__ import annotations
import pytest
from openai.types.responses import ResponseReasoningItem
from agents import Agent, CodeInterpreterTool, RunConfig, Runner
from agents.items import ToolCallItem
pytestmark = pytest.mark.hosted
async def test_code_interpreter_reasoning_items_survive_follow_up_replay(
... | 74 | 2,721 |
openai-agents-python | integration_tests/providers/test_litellm.py | .py | from __future__ import annotations
from typing import Any
import pytest
from agents import Agent, ModelSettings, RunConfig, Runner, RunResult, RunResultStreaming
from agents.decorators import tool
pytestmark = pytest.mark.providers
@pytest.mark.parametrize("dictionary", [False, True], ids=["typed", "dictionary"])... | 190 | 6,757 |
openai-agents-python | integration_tests/providers/test_any_llm.py | .py | from __future__ import annotations
from typing import Any
import pytest
from agents import Agent, ModelSettings, RunConfig, Runner, RunResult, RunResultStreaming
from agents.decorators import tool
pytestmark = pytest.mark.providers
@pytest.mark.parametrize("dictionary", [False, True], ids=["typed", "dictionary"])... | 178 | 6,265 |
openai-agents-python | examples/auto_mode.py | .py | """Utilities for running examples in automated mode.
When ``EXAMPLES_INTERACTIVE_MODE=auto`` is set, these helpers provide
deterministic inputs and confirmations so examples can run without manual
interaction. The helpers are intentionally lightweight to avoid adding
dependencies to example code.
"""
from __future__ ... | 38 | 1,208 |
openai-agents-python | examples/web_search_utils.py | .py | from __future__ import annotations
from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from typing import Any
@dataclass(frozen=True)
class URLCitation:
title: str
url: str
def get_field(obj: Any, key: str) -> Any:
if isinstance(obj, Mapping):
return obj.get(key)
... | 80 | 2,275 |
openai-agents-python | examples/run_examples.py | .py | """Run multiple example entry points with optional auto mode and logging.
Features:
* Discovers ``__main__``-guarded example files under ``examples/``.
* Skips interactive/server/audio/external examples unless explicitly included.
* Auto mode (``EXAMPLES_INTERACTIVE_MODE=auto``) enables deterministic inputs,
auto-ap... | 915 | 31,562 |
openai-agents-python | examples/sandbox/tax_prep.py | .py | from __future__ import annotations
import argparse
import asyncio
import sys
from pathlib import Path
from typing import cast
from openai.types.responses import ResponseTextDeltaEvent
from agents import Runner
from agents.items import TResponseInputItem
from agents.run import RunConfig
from agents.sandbox import Man... | 260 | 8,862 |
openai-agents-python | examples/sandbox/unix_local_pty.py | .py | """Show how a sandbox agent can keep using the same interactive Python process.
This example uses the Unix-local sandbox with the `Shell` capability. The task only asks
for a stateful interaction, but the streamed output shows the actual shell tools the agent
chooses, including the follow-up writes that keep the same ... | 166 | 5,742 |
openai-agents-python | examples/sandbox/sandbox_agents_as_tools.py | .py | """
Show how sandbox agents can be exposed as tools to a normal orchestrator.
Each sandbox reviewer gets its own isolated workspace. The outer orchestrator
does not inspect files directly. It calls the reviewers as tools and combines
their outputs with a normal Python function tool.
"""
import argparse
import asyncio... | 212 | 9,200 |
openai-agents-python | examples/sandbox/sandbox_agent_with_remote_snapshot.py | .py | """
Sandbox agent example using a dependency-injected remote snapshot client.
This demonstrates persisting a Unix-local sandbox workspace to S3 with `RemoteSnapshotSpec`,
then resuming the session from the downloaded snapshot.
"""
from __future__ import annotations
import argparse
import asyncio
import io
import os
... | 174 | 6,032 |
openai-agents-python | examples/sandbox/handoffs.py | .py | """
Show how a non-sandbox agent can hand work to a sandbox agent.
The intake agent never sees a workspace directly. It hands document-heavy work
to a sandbox reviewer, and that reviewer then hands the synthesized result to a
plain account-facing writer.
"""
import argparse
import asyncio
import sys
from pathlib impo... | 105 | 3,947 |
openai-agents-python | examples/sandbox/shared_session_workdirs.py | .py | """Run two trusted agents in separate working directories of one live sandbox.
Run-scoped working directories make relative paths consistent; they are not confinement.
Use separate sandbox sessions for untrusted agents or workloads that need compute isolation.
"""
from __future__ import annotations
import argparse
i... | 290 | 10,856 |
openai-agents-python | examples/sandbox/sandbox_agent_capabilities.py | .py | from __future__ import annotations
import argparse
import asyncio
import json
import sys
import tempfile
from collections.abc import AsyncIterator
from pathlib import Path
from typing import Any, cast
from openai.types.responses import ResponseFunctionCallArgumentsDeltaEvent, ResponseTextDeltaEvent
from openai.types.... | 476 | 17,317 |
openai-agents-python | examples/sandbox/memory_multi_agent_multiturn.py | .py | from __future__ import annotations
import argparse
import asyncio
import sys
from pathlib import Path
from agents import Runner, SQLiteSession
from agents.run import RunConfig
from agents.sandbox import Manifest, MemoryLayoutConfig, SandboxAgent, SandboxRunConfig
from agents.sandbox.capabilities import Filesystem, Me... | 236 | 8,675 |
openai-agents-python | examples/sandbox/unix_local_runner.py | .py | """
Start here if you want the simplest Unix-local sandbox example.
This file mirrors the Docker example, but the sandbox runs as a temporary local
workspace on macOS or Linux instead of inside a Docker container.
"""
import argparse
import asyncio
import io
import sys
import tempfile
from pathlib import Path
from o... | 215 | 9,254 |
openai-agents-python | examples/sandbox/basic.py | .py | from __future__ import annotations
import argparse
import asyncio
import sys
from pathlib import Path
from typing import Any, Literal, cast
from openai.types.responses import ResponseTextDeltaEvent
from agents import ModelSettings, Runner
from agents.run import RunConfig
from agents.sandbox import Manifest, SandboxA... | 242 | 8,668 |
openai-agents-python | examples/sandbox/memory_s3.py | .py | from __future__ import annotations
import argparse
import asyncio
import os
import sys
import uuid
from dataclasses import dataclass
from pathlib import Path
from agents import Runner
from agents.run import RunConfig
from agents.sandbox import (
Manifest,
MemoryGenerateConfig,
MemoryLayoutConfig,
Sand... | 330 | 12,026 |
openai-agents-python | examples/sandbox/sandbox_agent_with_tools.py | .py | """
Show how a sandbox agent can combine three tool sources in one run.
This example gives the model:
1. A sandbox workspace to inspect with the shared shell capability.
2. A normal local function tool for approval routing.
3. A local stdio MCP server for reference policy lookups.
"""
import argparse
import asyncio
... | 118 | 4,678 |
openai-agents-python | examples/sandbox/memory.py | .py | from __future__ import annotations
import argparse
import asyncio
import sys
import tempfile
from pathlib import Path
from agents import Runner
from agents.run import RunConfig
from agents.sandbox import LocalSnapshotSpec, Manifest, SandboxAgent, SandboxRunConfig
from agents.sandbox.capabilities import Filesystem, Me... | 230 | 9,647 |
openai-agents-python | examples/sandbox/healthcare_support/workflow.py | .py | from __future__ import annotations
import json
from collections.abc import Awaitable, Callable
from pathlib import Path
from typing import Any, cast
from pydantic import BaseModel
from agents import (
Agent,
AgentHookContext,
RunContextWrapper,
RunHooks,
Runner,
SQLiteSession,
Tool,
g... | 519 | 19,086 |
openai-agents-python | examples/sandbox/healthcare_support/support_agents.py | .py | from __future__ import annotations
from pathlib import Path
from openai.types.shared import Reasoning
from agents import Agent, AgentOutputSchema, ModelSettings, Tool
from agents.sandbox import SandboxAgent
from agents.sandbox.capabilities import Filesystem, LocalDirLazySkillSource, Shell, Skills
from agents.sandbox... | 174 | 7,045 |
openai-agents-python | examples/sandbox/healthcare_support/main.py | .py | from __future__ import annotations
import argparse
import asyncio
import json
import sys
from pathlib import Path
from typing import Any
if __package__ is None or __package__ == "":
_DEMO_DIR = Path(__file__).resolve().parent
sys.path.insert(0, str(_DEMO_DIR.parents[2]))
sys.path.insert(0, str(_DEMO_DIR))... | 153 | 4,751 |
openai-agents-python | examples/sandbox/healthcare_support/models.py | .py | from __future__ import annotations
from typing import Any, Literal
from pydantic import BaseModel, Field
IntentName = Literal[
"eligibility_verification",
"prior_auth_confusion",
"referral_status_question",
"billing_coverage_clarification",
"general_intake",
]
class ScenarioExpectation(BaseMode... | 84 | 2,242 |
openai-agents-python | examples/sandbox/healthcare_support/data.py | .py | from __future__ import annotations
import json
import os
import re
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import Any
from examples.sandbox.healthcare_support.models import KnowledgeSnippet, ScenarioCase
EXAMPLE_ROOT = Path(__file__).resolve().parent
SCENA... | 198 | 7,003 |
openai-agents-python | examples/sandbox/healthcare_support/tools.py | .py | from __future__ import annotations
import hashlib
import json
from collections.abc import Awaitable, Callable
from dataclasses import dataclass, field
from typing import Any
from agents import RunContextWrapper
from agents.decorators import tool
from examples.sandbox.healthcare_support.data import HealthcareSupportDa... | 116 | 3,594 |
openai-agents-python | examples/sandbox/extensions/modal_runner.py | .py | """
Minimal Modal-backed sandbox example for manual validation.
This example mirrors the local and Docker sandbox demos, but it sends the
workspace to a Modal sandbox.
"""
import argparse
import asyncio
import io
import os
import sys
import tempfile
from pathlib import Path
from typing import Literal, cast
from open... | 399 | 15,077 |
openai-agents-python | examples/sandbox/extensions/e2b_runner.py | .py | """
Minimal E2B-backed sandbox example for manual validation.
This example is intentionally small: it creates a tiny workspace, lets the
agent inspect it through one shell tool, and prints a short answer.
"""
import argparse
import asyncio
import io
import os
import sys
import tempfile
from pathlib import Path
from t... | 274 | 9,144 |
openai-agents-python | examples/sandbox/extensions/cloudflare_runner.py | .py | """
Cloudflare-backed sandbox example for manual validation.
This example mirrors the Modal and E2B extension runners. It supports:
- Standard agent run (non-streaming and streaming).
- Snapshot stop/resume round-trip verification.
- PTY interactive session demo.
- Cloud bucket mount demo (R2/S3/GCS via CloudflareBuck... | 447 | 15,832 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.