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 |
|---|---|---|---|---|---|
redash | redash/destinations/hangoutschat.py | .py | import logging
import requests
from redash.destinations import BaseDestination, register
from redash.utils import json_dumps
class HangoutsChat(BaseDestination):
@classmethod
def name(cls):
return "Google Hangouts Chat"
@classmethod
def type(cls):
return "hangouts_chat"
@classm... | 97 | 3,261 |
redash | redash/destinations/pagerduty.py | .py | import logging
from redash.destinations import BaseDestination, register
enabled = True
try:
import pypd
except ImportError:
enabled = False
class PagerDuty(BaseDestination):
KEY_STRING = "{alert_id}_{query_id}"
DESCRIPTION_STR = "Alert: {alert_name}"
@classmethod
def enabled(cls):
... | 83 | 2,299 |
redash | redash/destinations/webhook.py | .py | import logging
import requests
from requests.auth import HTTPBasicAuth
from redash.destinations import BaseDestination, register
from redash.serializers import serialize_alert
from redash.utils import json_dumps
class Webhook(BaseDestination):
@classmethod
def configuration_schema(cls):
return {
... | 57 | 1,765 |
redash | redash/destinations/chatwork.py | .py | import logging
import requests
from redash.destinations import BaseDestination, register
class ChatWork(BaseDestination):
ALERTS_DEFAULT_MESSAGE_TEMPLATE = "{alert_name} changed state to {new_state}.\\n{alert_url}\\n{query_url}"
@classmethod
def configuration_schema(cls):
return {
"... | 65 | 2,491 |
redash | redash/cli/data_sources.py | .py | from sys import exit
import click
from click.types import convert_type
from flask.cli import AppGroup
from sqlalchemy.orm.exc import NoResultFound
from redash import models
from redash.query_runner import (
get_configuration_schema_for_query_runner_type,
query_runners,
)
from redash.utils import json_loads
fr... | 238 | 7,772 |
redash | redash/cli/organization.py | .py | from click import argument, option
from flask.cli import AppGroup
from redash import models
manager = AppGroup(help="Organization management commands.")
@manager.command(name="set_google_apps_domains")
@argument("domains")
def set_google_apps_domains(domains):
"""
Sets the allowable domains to the comma sep... | 57 | 1,737 |
redash | redash/cli/__init__.py | .py | import json
import click
from flask import current_app
from flask.cli import FlaskGroup, run_command, with_appcontext
from rq import Connection
from redash import __version__, create_app, rq_redis_connection, settings
from redash.cli import (
data_sources,
database,
groups,
organization,
queries,
... | 94 | 2,218 |
redash | redash/cli/users.py | .py | import json
from sys import exit
from click import BOOL, argument, option, prompt
from flask.cli import AppGroup
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.exc import NoResultFound
from redash import models
from redash.handlers.users import invite_user
manager = AppGroup(help="Users management com... | 329 | 9,552 |
redash | redash/cli/queries.py | .py | from click import argument
from flask.cli import AppGroup
from sqlalchemy.orm.exc import NoResultFound
manager = AppGroup(help="Queries management commands.")
@manager.command(name="rehash")
def rehash():
from redash import models
for q in models.Query.query.all():
old_hash = q.query_hash
q.... | 81 | 1,654 |
redash | redash/cli/groups.py | .py | from sys import exit
from click import argument, option
from flask.cli import AppGroup
from sqlalchemy.orm.exc import NoResultFound
from redash import models
manager = AppGroup(help="Groups management commands.")
@manager.command()
@argument("name")
@option(
"--org",
"organization",
default="default",
... | 123 | 3,630 |
redash | redash/cli/database.py | .py | import logging
import time
import sqlalchemy
from click import argument, option
from cryptography.fernet import InvalidToken
from flask.cli import AppGroup
from flask_migrate import stamp
from sqlalchemy.exc import DatabaseError
from sqlalchemy.sql import select
from sqlalchemy_utils.types.encrypted.encrypted_type imp... | 126 | 3,974 |
redash | redash/cli/rq.py | .py | import datetime
import socket
from itertools import chain
from click import argument
from flask.cli import AppGroup
from rq import Connection
from rq.worker import WorkerStatus
from sqlalchemy.orm import configure_mappers
from supervisor_checks import check_runner
from supervisor_checks.check_modules import base
from... | 94 | 2,832 |
redash | redash/models/types.py | .py | from sqlalchemy.ext.indexable import index_property
from sqlalchemy.ext.mutable import Mutable
from sqlalchemy.types import TypeDecorator
from sqlalchemy_utils import EncryptedType
from redash.utils import json_dumps, json_loads
from redash.utils.configuration import ConfigurationContainer
from .base import db
clas... | 108 | 3,080 |
redash | redash/models/changes.py | .py | from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.inspection import inspect
from sqlalchemy_utils.models import generic_repr
from .base import Column, GFKBase, db, key_type, primary_key
@generic_repr("id", "object_type", "object_id", "created_at")
class Change(GFKBase, db.Model):
id = primary_key(... | 93 | 2,978 |
redash | redash/models/parameterized_query.py | .py | import re
from functools import partial
from numbers import Number
import pystache
from dateutil.parser import parse
from funcy import distinct
from redash.utils import mustache_render
def _pluck_name_and_value(default_column, row):
row = {k.lower(): v for k, v in row.items()}
name_column = "name" if "name"... | 212 | 6,758 |
redash | redash/models/organizations.py | .py | from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm.attributes import flag_modified
from sqlalchemy_utils.models import generic_repr
from redash.settings.organization import settings as org_settings
from .base import Column, db, primary_key
from .mixins import TimestampMixin
from .types import Mutabl... | 86 | 2,579 |
redash | redash/models/__init__.py | .py | import calendar
import datetime
import logging
import numbers
import re
import time
import pytz
from sqlalchemy import UniqueConstraint, and_, cast, distinct, func, or_
from sqlalchemy.dialects.postgresql import ARRAY, DOUBLE_PRECISION, JSONB
from sqlalchemy.event import listens_for
from sqlalchemy.ext.hybrid import h... | 1,539 | 54,445 |
redash | redash/models/users.py | .py | import hashlib
import itertools
import logging
import time
from functools import reduce
from operator import or_
from flask import current_app, request_started, url_for
from flask_login import AnonymousUserMixin, UserMixin, current_user
from passlib.apps import custom_app_context as pwd_context
from sqlalchemy.dialect... | 423 | 13,500 |
redash | redash/models/mixins.py | .py | from sqlalchemy.event import listens_for
from .base import Column, db
class TimestampMixin:
updated_at = Column(db.DateTime(True), default=db.func.now(), nullable=False)
created_at = Column(db.DateTime(True), default=db.func.now(), nullable=False)
@listens_for(TimestampMixin, "before_update", propagate=Tru... | 29 | 883 |
redash | redash/models/base.py | .py | import functools
from flask_sqlalchemy import BaseQuery, SQLAlchemy
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import object_session
from sqlalchemy.pool import NullPool
from sqlalchemy_searchable import SearchQueryMixin, make_searchable, vectorizer
from redash import settings
from redash.uti... | 111 | 3,282 |
openai-agents-python | docs/scripts/generate_ref_files.py | .py | #!/usr/bin/env python
"""
generate_ref_files.py
Create missing Markdown reference stubs for mkdocstrings.
Usage:
python scripts/generate_ref_files.py
"""
from pathlib import Path
# ---- Paths -----------------------------------------------------------
REPO_ROOT = Path(__file__).resolve().parent.parent.parent ... | 78 | 2,261 |
openai-agents-python | docs/scripts/translate_docs.py | .py | # ruff: noqa
import argparse
import os
import re
import subprocess
import sys
from collections import Counter
from pathlib import Path
from openai import OpenAI
from concurrent.futures import ThreadPoolExecutor
# import logging
# logging.basicConfig(level=logging.INFO)
# logging.getLogger("openai").setLevel(logging.DE... | 729 | 29,195 |
openai-agents-python | tests/test_apply_diff.py | .py | """Tests for the V4A diff helper."""
from __future__ import annotations
import pytest
from agents import apply_diff
def test_apply_diff_with_floating_hunk_adds_lines() -> None:
diff = "\n".join(["@@", "+hello", "+world"]) # no trailing newline
assert apply_diff("", diff) == "hello\nworld\n"
def test_app... | 267 | 7,672 |
openai-agents-python | tests/test_agent_tool_state.py | .py | from __future__ import annotations
import gc
import weakref
from types import SimpleNamespace
from typing import Any, cast
import pytest
from openai.types.responses import ResponseFunctionToolCall
import agents.agent_tool_state as tool_state
from .test_responses import get_function_tool_call
@pytest.fixture(autou... | 117 | 5,404 |
openai-agents-python | tests/test_agent_clone_shallow_copy.py | .py | from agents import Agent, function_tool, handoff
@function_tool
def greet(name: str) -> str:
return f"Hello, {name}!"
def test_agent_clone_shallow_copy():
"""Test that clone creates shallow copy with tools.copy() workaround"""
target_agent = Agent(name="Target")
original = Agent(
name="Origi... | 33 | 1,104 |
openai-agents-python | tests/test_integration_runner.py | .py | from __future__ import annotations
import os
import runpy
import sys
from collections.abc import Callable
from pathlib import Path
from types import SimpleNamespace
from typing import Any, cast
import pytest
RUNNER = Path(__file__).resolve().parents[1] / ".github" / "scripts" / "run_integration_tests.py"
CHANGE_DETE... | 722 | 27,202 |
openai-agents-python | tests/test_responses_tracing.py | .py | import pytest
from inline_snapshot import snapshot
from openai import AsyncOpenAI
from openai.types.responses import ResponseCompletedEvent
from openai.types.responses.response_usage import InputTokensDetails, OutputTokensDetails
from agents import ModelBehaviorError, ModelSettings, ModelTracing, OpenAIResponsesModel,... | 494 | 15,772 |
openai-agents-python | tests/test_streaming_logging.py | .py | from __future__ import annotations
import logging
import pytest
import agents._debug as _debug
from agents import Agent, RunConfig
from agents.items import ToolCallOutputItem
from agents.run import AgentRunner
from agents.run_context import RunContextWrapper
from agents.run_state import RunState
from agents.testing ... | 60 | 1,734 |
openai-agents-python | tests/test_call_model_input_filter_unit.py | .py | from __future__ import annotations
from typing import Any
import pytest
from openai.types.responses import ResponseOutputMessage, ResponseOutputText
# Import directly from submodules to avoid heavy __init__ side effects
from agents.agent import Agent
from agents.exceptions import UserError
from agents.run import Cal... | 107 | 3,310 |
openai-agents-python | tests/test_asyncio_tasks.py | .py | from __future__ import annotations
import asyncio
import pytest
from agents.util._asyncio_tasks import gather_with_cancel, run_producer_consumer
@pytest.mark.asyncio
@pytest.mark.parametrize("error_type", [RuntimeError, asyncio.CancelledError])
async def test_gather_with_cancel_reports_child_failure_before_cancell... | 132 | 3,891 |
openai-agents-python | tests/test_run_config.py | .py | from __future__ import annotations
from pathlib import PureWindowsPath
from typing import Any, cast
import pytest
from agents import (
Agent,
RunConfig,
Runner,
SessionSettings,
ToolExecutionConfig,
ToolNameCollisionPolicy,
ToolNotFoundBehavior,
)
from agents.model_settings import ModelSe... | 395 | 14,782 |
openai-agents-python | tests/test_result_cast.py | .py | from __future__ import annotations
import dataclasses
import gc
import weakref
from typing import Any, cast
import pytest
from openai.types.responses import ResponseOutputMessage, ResponseOutputText
from pydantic import BaseModel, ConfigDict
from agents import (
Agent,
AgentToolInvocation,
MessageOutputI... | 393 | 11,452 |
openai-agents-python | tests/test_agent_memory_leak.py | .py | from __future__ import annotations
import gc
import weakref
import pytest
from openai.types.responses import ResponseOutputMessage, ResponseOutputText
from agents import Agent, Runner
from agents.testing import ScriptedModel
def _make_message(text: str) -> ResponseOutputMessage:
return ResponseOutputMessage(
... | 36 | 1,015 |
openai-agents-python | tests/test_visualization.py | .py | from unittest.mock import Mock
import graphviz # type: ignore
import pytest
from agents import Agent, handoff
from agents.extensions.visualization import (
draw_graph,
get_all_edges,
get_all_nodes,
get_main_graph,
)
from agents.handoffs import Handoff
from .mcp.helpers import FakeMCPServer
@pytest... | 296 | 10,301 |
openai-agents-python | tests/test_apply_diff_helpers.py | .py | """Direct tests for the apply_diff helpers to exercise corner cases."""
from __future__ import annotations
import pytest
from agents.apply_diff import (
Chunk,
ParserState,
_apply_chunks,
_find_context,
_find_context_core,
_is_done,
_normalize_diff_lines,
_read_section,
_read_str,... | 75 | 1,988 |
openai-agents-python | tests/test_example_workflows.py | .py | from __future__ import annotations
import asyncio
import json
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Literal, cast
from unittest.mock import AsyncMock
import pytest
from openai.types.responses import ResponseTextDeltaEvent
from pydantic import BaseModel
from age... | 1,462 | 50,753 |
openai-agents-python | tests/test_update_rclone_pin.py | .py | from __future__ import annotations
import hashlib
import importlib.util
import re
import sys
from datetime import datetime, timezone
from pathlib import Path
from types import ModuleType
import pytest
def _load_updater() -> ModuleType:
path = Path(__file__).parents[1] / ".github/scripts/update_rclone_pin.py"
... | 255 | 7,895 |
openai-agents-python | tests/test_soft_cancel.py | .py | """Tests for soft cancel (after_turn mode) functionality."""
import asyncio
import json
from collections.abc import AsyncGenerator
from typing import cast
import pytest
from agents import Agent, Runner, SQLiteSession
from agents.agent_output import AgentOutputSchema
from agents.stream_events import StreamEvent
from ... | 706 | 22,527 |
openai-agents-python | tests/test_agent_tracing.py | .py | from __future__ import annotations
import asyncio
from uuid import uuid4
import pytest
from inline_snapshot import snapshot
from openai.types.responses.response_usage import InputTokensDetails
from agents import Agent, RunConfig, Runner, RunState, custom_span, function_tool, trace
from agents.sandbox.runtime import ... | 1,156 | 35,257 |
openai-agents-python | tests/test_doc_parsing.py | .py | from agents.function_schema import generate_func_documentation
def func_foo_google(a: int, b: float) -> str:
"""
This is func_foo.
Args:
a: The first argument.
b: The second argument.
Returns:
A result
"""
return "ok"
def func_foo_numpy(a: int, b: float) -> str:
... | 116 | 2,722 |
openai-agents-python | tests/test_tool_approval_call_id_reuse.py | .py | from __future__ import annotations
import asyncio
import json
import warnings
from types import SimpleNamespace
from typing import Any, Literal, cast
import pytest
from openai.types.responses import ResponseCustomToolCall, ResponseFunctionToolCall
from openai.types.responses.response_computer_tool_call import (
A... | 3,232 | 105,916 |
openai-agents-python | tests/test_runner_guardrail_resume.py | .py | from types import SimpleNamespace
from typing import Any, cast
import pytest
from openai.types.responses import ResponseFunctionToolCall
import agents.run as run_module
from agents import Agent, Runner
from agents.guardrail import GuardrailFunctionOutput, InputGuardrail, InputGuardrailResult
from agents.items import ... | 285 | 10,675 |
openai-agents-python | tests/test_mcp_tool_metadata.py | .py | """Unit tests for src/agents/_mcp_tool_metadata.py pure helpers.
The module resolves MCP tool display metadata (title / description) from
either dict payloads or attribute-bearing objects. It feeds hosted-MCP
tool definitions into the model and into traces, but had no direct
test file.
"""
from __future__ import anno... | 211 | 7,462 |
openai-agents-python | tests/test_output_tool.py | .py | import json
from typing import Any, Literal, cast
import pytest
from pydantic import BaseModel
from typing_extensions import TypedDict
from agents import (
Agent,
AgentOutputSchema,
AgentOutputSchemaBase,
ModelBehaviorError,
UserError,
)
from agents.agent_output import _WRAPPER_DICT_KEY
from agent... | 235 | 8,438 |
openai-agents-python | tests/test_extra_headers.py | .py | import pytest
from openai.types.chat.chat_completion import ChatCompletion, Choice
from openai.types.chat.chat_completion_message import ChatCompletionMessage
from openai.types.responses.response_usage import InputTokensDetails, OutputTokensDetails
from agents import ModelSettings, ModelTracing, OpenAIChatCompletionsM... | 104 | 3,622 |
openai-agents-python | tests/test_agent_runner.py | .py | from __future__ import annotations
import asyncio
import json
import logging
import tempfile
import warnings
from collections.abc import Callable
from pathlib import Path
from typing import Any, cast
from unittest.mock import patch
import httpx
import pytest
from openai import APIConnectionError, BadRequestError, Not... | 6,737 | 221,187 |
openai-agents-python | tests/test_transforms.py | .py | import logging
import pytest
from agents.util._transforms import transform_string_function_style
@pytest.mark.parametrize(
("name", "transformed"),
[
("My Tool", "my_tool"),
("My-Tool", "my_tool"),
],
)
def test_transform_string_function_style_warns_for_replaced_characters(
caplog: p... | 44 | 1,189 |
openai-agents-python | tests/test_global_hooks.py | .py | from __future__ import annotations
import json
from collections import defaultdict
from typing import Any
import pytest
from typing_extensions import TypedDict
from agents import Agent, RunContextWrapper, RunHooks, Runner, TContext, Tool
from agents.testing import ScriptedModel
from agents.tool_context import ToolCo... | 392 | 14,020 |
openai-agents-python | tests/test_function_tool.py | .py | import asyncio
import contextlib
import copy
import dataclasses
import json
import logging
import time
from collections.abc import Callable
from typing import Any, cast
import pytest
from pydantic import BaseModel
from typing_extensions import TypedDict
import agents._debug as _debug
import agents.tool as tool_module... | 1,438 | 46,640 |
openai-agents-python | tests/test_trace_processor.py | .py | import logging
import os
import subprocess
import sys
import textwrap
import threading
import time
from typing import Any, cast
from unittest.mock import MagicMock, patch
import httpx2
import pytest
import agents._debug as _debug
from agents.tracing import flush_traces, get_trace_provider
from agents.tracing.processo... | 1,357 | 44,483 |
openai-agents-python | tests/test_shell_call_serialization.py | .py | from __future__ import annotations
import pytest
from agents.agent import Agent
from agents.exceptions import ModelBehaviorError
from agents.items import ToolCallOutputItem
from agents.run_internal import run_loop
from agents.testing import ScriptedModel
from agents.tool import ShellCallOutcome, ShellCommandOutput
... | 174 | 5,516 |
openai-agents-python | tests/test_test_environment.py | .py | from __future__ import annotations
import pytest
from .conftest import (
_PROXY_ENVIRONMENT_VARIABLES,
_PROXY_OPT_IN_ENVIRONMENT_VARIABLE,
_remove_ambient_proxy_environment,
)
def test_remove_ambient_proxy_environment_clears_proxy_variables() -> None:
environment = {
variable: "socks5h://127... | 36 | 1,051 |
openai-agents-python | tests/test_streamed_terminal_output_backfill.py | .py | from __future__ import annotations
import json
from collections.abc import AsyncIterator
import pytest
from openai.types.responses import (
ResponseCompletedEvent,
ResponseCreatedEvent,
ResponseInProgressEvent,
ResponseOutputItemDoneEvent,
)
from agents import Agent, Runner
from agents.items import T... | 156 | 4,910 |
openai-agents-python | tests/test_run_internal_approvals.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, cast
from openai.types.responses import ResponseFunctionToolCall
from agents import Agent
from agents.items import MessageOutputItem, ToolCallOutputItem, TResponseInputItem
from agents.run_internal.approvals import (
_bu... | 124 | 3,893 |
openai-agents-python | tests/test_run_error_details.py | .py | import json
import pytest
from agents import Agent, MaxTurnsExceeded, RunErrorDetails, Runner
from agents.testing import ScriptedModel
from .test_responses import get_function_tool, get_function_tool_call, get_text_message
@pytest.mark.asyncio
async def test_run_error_includes_data():
model = ScriptedModel()
... | 49 | 1,605 |
openai-agents-python | tests/test_agents_logging.py | .py | from __future__ import annotations
import io
import logging
import sys
import threading
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from typing import Any
import pytest
import agents
from agents import enable_verbose_stdout_logging
@pytest.fixture
def agents_logger(monke... | 171 | 5,629 |
openai-agents-python | tests/test_run.py | .py | from __future__ import annotations
from typing import Any, cast
from unittest import mock
import pytest
from agents import Agent, Runner
from agents.run import AgentRunner, set_default_agent_runner
from agents.testing import ScriptedModel
from .test_responses import get_text_input_item, get_text_message
@pytest.m... | 46 | 1,374 |
openai-agents-python | tests/test_server_conversation_tracker.py | .py | from types import SimpleNamespace
from typing import Any, cast
import pytest
from openai.types.responses import ResponseFunctionToolCall
from openai.types.responses.response_output_item import McpCall, McpListTools, McpListToolsTool
import agents.run_internal.oai_conversation as oai_conversation
from agents import Ag... | 1,058 | 35,200 |
openai-agents-python | tests/test_tool_choice_reset.py | .py | import pytest
from agents import Agent, ModelSettings, Runner
from agents.run_internal.run_loop import AgentToolUseTracker, maybe_reset_tool_choice
from agents.testing import ScriptedModel
from .test_responses import get_function_tool, get_function_tool_call, get_text_message
class TestToolChoiceReset:
def test... | 218 | 9,437 |
openai-agents-python | tests/test_source_compat_constructors.py | .py | from __future__ import annotations
import asyncio
from typing import Any, cast
import pytest
from agents import (
Agent,
AgentHookContext,
FunctionTool,
HandoffInputData,
ItemHelpers,
ModelRetrySettings,
ModelSettings,
MultiProvider,
RunConfig,
RunContextWrapper,
RunErrorD... | 491 | 12,640 |
openai-agents-python | tests/test_debug.py | .py | import os
from unittest.mock import patch
from agents._debug import _load_dont_log_model_data, _load_dont_log_tool_data
@patch.dict(os.environ, {})
def test_dont_log_model_data():
assert _load_dont_log_model_data() is True
@patch.dict(os.environ, {"OPENAI_AGENTS_DONT_LOG_MODEL_DATA": "0"})
def test_dont_log_mo... | 55 | 1,565 |
openai-agents-python | tests/test_apply_patch_tool.py | .py | from __future__ import annotations
import json
from dataclasses import dataclass
from typing import Any, cast
import pytest
from agents import (
Agent,
ApplyPatchTool,
RunConfig,
RunContextWrapper,
RunHooks,
set_tracing_disabled,
trace,
)
from agents.editor import ApplyPatchOperation, App... | 448 | 15,741 |
openai-agents-python | tests/test_agent_config.py | .py | from typing import Any
import pytest
from openai.types.shared import Reasoning
from pydantic import BaseModel
from agents import Agent, AgentOutputSchema, Handoff, RunContextWrapper, handoff
from agents.lifecycle import AgentHooksBase
from agents.model_settings import ModelSettings
from agents.retry import ModelRetry... | 293 | 10,051 |
openai-agents-python | tests/test_config.py | .py | import asyncio
import gc
import os
import weakref
from typing import Any, cast
import httpx2
import openai
import pytest
from agents import (
UserError,
responses_websocket_session,
set_default_openai_api,
set_default_openai_client,
set_default_openai_key,
set_default_openai_responses_transpor... | 517 | 16,889 |
openai-agents-python | tests/test_run_examples_script.py | .py | from __future__ import annotations
from pathlib import Path
import examples.run_examples as run_examples
def test_default_auto_skip_excludes_prerequisite_bound_examples() -> None:
expected = {
"examples/sandbox/docker/mounts/azure_mount_read_write.py",
"examples/sandbox/docker/mounts/gcs_mount_r... | 180 | 6,250 |
openai-agents-python | tests/test_strict_schema_oneof.py | .py | from typing import Annotated, Literal
from pydantic import BaseModel, Field
from agents.agent_output import AgentOutputSchema
from agents.strict_schema import ensure_strict_json_schema
def test_oneof_converted_to_anyof():
schema = {
"type": "object",
"properties": {"value": {"oneOf": [{"type": "... | 288 | 8,776 |
openai-agents-python | tests/test_tool_metadata.py | .py | from __future__ import annotations
from typing import cast
from openai.types.responses.tool_param import CodeInterpreter, ImageGeneration, Mcp
from agents.computer import Computer
from agents.run_context import RunContextWrapper
from agents.tool import (
ApplyPatchTool,
CodeInterpreterTool,
ComputerTool,... | 76 | 2,450 |
openai-agents-python | tests/test_released_api_contract.py | .py | import builtins
import importlib
import json
import subprocess
import sys
from collections.abc import AsyncIterator, Callable, Iterator
from dataclasses import asdict, dataclass
from enum import Enum
from importlib.metadata import version
from inspect import Parameter, Signature
from pathlib import Path
from types impo... | 3,245 | 110,133 |
openai-agents-python | tests/test_process_model_response.py | .py | from typing import Any, cast
import pytest
from openai._models import construct_type
from openai.types.responses import (
ResponseApplyPatchToolCall,
ResponseCompactionItem,
ResponseCustomToolCall,
ResponseFunctionShellToolCall,
ResponseFunctionShellToolCallOutput,
ResponseFunctionToolCall,
... | 933 | 31,988 |
openai-agents-python | tests/test_run_state_compatibility_corpus.py | .py | import asyncio
import builtins
import json
import logging
import sys
import types
from collections.abc import Iterator, Mapping
from pathlib import Path
from typing import Any, cast
import pytest
import agents.run_state as run_state_module
if sys.version_info < (3, 11):
from exceptiongroup import BaseExceptionGr... | 1,386 | 52,816 |
openai-agents-python | tests/test_stream_input_guardrail_timing.py | .py | from __future__ import annotations
import asyncio
from datetime import datetime
from typing import Any
import pytest
from openai.types.responses import ResponseCompletedEvent
from agents import Agent, GuardrailFunctionOutput, InputGuardrail, RunContextWrapper, Runner
from agents.exceptions import InputGuardrailTripw... | 270 | 9,889 |
openai-agents-python | tests/test_hitl_session_scenario.py | .py | from __future__ import annotations
from dataclasses import dataclass
from typing import Any, cast
import pytest
from agents import (
Agent,
ModelSettings,
OpenAIConversationsSession,
Runner,
function_tool,
)
from agents.items import TResponseInputItem
from agents.testing import ModelCall, ModelSt... | 438 | 13,964 |
openai-agents-python | tests/test_agent_tool_input.py | .py | from __future__ import annotations
import json
import pytest
from pydantic import ValidationError
from agents.agent_tool_input import (
AgentAsToolInput,
StructuredInputSchemaInfo,
_build_schema_summary,
_describe_json_schema_field,
_format_enum_label,
_format_literal_label,
_read_schema_... | 128 | 4,458 |
openai-agents-python | tests/test_shell_tool.py | .py | from __future__ import annotations
import json
from typing import Any, cast
import pytest
from agents import (
Agent,
RunConfig,
RunContextWrapper,
RunHooks,
ShellCallOutcome,
ShellCommandOutput,
ShellResult,
ShellTool,
UserError,
set_tracing_disabled,
trace,
)
from agents... | 814 | 26,905 |
openai-agents-python | tests/test_invalid_final_output_handler.py | .py | from __future__ import annotations
import json
from typing import Any
import pytest
from openai.types.responses import ResponseOutputMessage
from pydantic import BaseModel
import agents._debug as _debug
from agents import (
Agent,
AgentHookContext,
GuardrailFunctionOutput,
ItemHelpers,
MessageOut... | 377 | 12,744 |
openai-agents-python | tests/test_output_guardrail_cancellation.py | .py | from __future__ import annotations
import asyncio
from typing import Any
import pytest
from agents import (
Agent,
GuardrailFunctionOutput,
OutputGuardrail,
OutputGuardrailTripwireTriggered,
RunContextWrapper,
)
from agents.run_internal.guardrails import run_output_guardrails
@pytest.mark.async... | 67 | 2,506 |
openai-agents-python | tests/test_streaming_tool_call_arguments.py | .py | """
Tests to ensure that tool call arguments are properly populated in streaming events.
This test specifically guards against the regression where tool_called events
were emitted with empty arguments during streaming (Issue #1629).
"""
import json
from collections.abc import AsyncIterator
from typing import cast
im... | 320 | 11,252 |
openai-agents-python | tests/test_strict_schema.py | .py | import copy
from collections import OrderedDict
import pytest
from agents.exceptions import UserError
from agents.strict_schema import ensure_strict_json_schema
def _nested_object_schema(depth: int) -> dict[str, object]:
root: dict[str, object] = {"type": "object", "properties": {}}
current = root
for _... | 993 | 30,452 |
openai-agents-python | tests/test_hitl_error_scenarios.py | .py | """Regression tests for HITL edge cases."""
from __future__ import annotations
import asyncio
from collections.abc import Callable
from typing import Any, Optional, cast
import pytest
from openai.types.responses import (
ResponseComputerToolCall,
ResponseCustomToolCall,
ResponseFunctionToolCall,
)
from o... | 3,800 | 131,163 |
openai-agents-python | tests/test_agent_llm_hooks.py | .py | from collections import defaultdict
from typing import Any
import pytest
from agents.agent import Agent
from agents.items import ItemHelpers, ModelResponse, TResponseInputItem
from agents.lifecycle import AgentHooks
from agents.run import Runner
from agents.run_context import AgentHookContext, RunContextWrapper, TCon... | 131 | 4,507 |
openai-agents-python | tests/test_scripted_sandbox.py | .py | from __future__ import annotations
import inspect
import io
from pathlib import Path
from types import MappingProxyType
from typing import Any, cast, get_type_hints
import pytest
from typing_extensions import assert_type
from agents import RunConfig, Runner
from agents.sandbox import ExecResult, Manifest, SandboxAge... | 576 | 19,920 |
openai-agents-python | tests/test_agent_runner_streamed.py | .py | from __future__ import annotations
import asyncio
import contextlib
import json
import logging
from collections.abc import AsyncIterator
from typing import Any, cast
import httpx
import pytest
from openai import APIConnectionError, BadRequestError, NotFoundError
from openai.types.responses import (
ResponseComple... | 3,649 | 124,551 |
openai-agents-python | tests/test_provider_span_errors.py | .py | """Every model provider must record a failed model call on its own span.
`Span.__exit__` finishes a span without attaching an exception, so a provider that
does not annotate its span exports a failed model call that is indistinguishable
from a successful one. `OpenAIResponsesModel` has always annotated its span; these... | 464 | 15,369 |
openai-agents-python | tests/test_hitl_utils.py | .py | from types import SimpleNamespace
from tests.utils.hitl import RecordingEditor
def test_recording_editor_records_operations() -> None:
editor = RecordingEditor()
operation = SimpleNamespace(path="file.txt")
editor.create_file(operation)
editor.update_file(operation)
editor.delete_file(operation)... | 15 | 388 |
openai-agents-python | tests/test_custom_tool.py | .py | from typing import Any, cast
import pytest
from openai.types.responses import ResponseCustomToolCall
from agents import Agent, CustomTool, RunConfig, RunContextWrapper
from agents.items import ToolApprovalItem, ToolCallOutputItem
from agents.lifecycle import RunHooks
from agents.run_internal.run_steps import ToolRunC... | 95 | 3,082 |
openai-agents-python | tests/test_run_hooks.py | .py | import json
from collections import defaultdict
from typing import Any, cast
import pytest
from agents.agent import Agent
from agents.items import ItemHelpers, ModelResponse, TResponseInputItem
from agents.lifecycle import AgentHooks, RunHooks
from agents.run import Runner
from agents.run_context import AgentHookCont... | 446 | 14,752 |
openai-agents-python | tests/test_run_step_processing.py | .py | from __future__ import annotations
from typing import Any, cast
import pytest
from openai.types.responses import (
ResponseComputerToolCall,
ResponseFileSearchToolCall,
ResponseFunctionToolCall,
ResponseFunctionWebSearch,
)
from openai.types.responses.response_computer_tool_call import ActionClick
fro... | 549 | 17,015 |
openai-agents-python | tests/test_handoff_history_duplication.py | .py | """Tests for handoff history duplication fix (Issue #2171).
These tests verify that when nest_handoff_history is enabled,
function_call and function_call_output items are NOT duplicated
in the input sent to the next agent.
"""
import dataclasses
import json
from copy import deepcopy
from typing import Any, cast
impo... | 2,411 | 90,665 |
openai-agents-python | tests/test_function_tool_decorator.py | .py | from __future__ import annotations
import asyncio
import copy
import dataclasses
import functools
import inspect
import json
import operator
import sys
from collections.abc import Callable
from types import ModuleType
from typing import Annotated, Any, Generic, TypeVar, cast
import pytest
from inline_snapshot import ... | 998 | 30,986 |
openai-agents-python | tests/test_prompt_cache_key.py | .py | from __future__ import annotations
import pytest
from openai.types.responses.response_create_params import ContextManagement, PromptCacheOptions
from agents import Agent, ModelSettings, RunConfig, Runner
from agents.testing import ScriptedModel
from .test_responses import get_function_tool, get_function_tool_call, g... | 270 | 9,495 |
openai-agents-python | tests/test_agent_instructions_signature.py | .py | from unittest.mock import Mock
import pytest
from agents import Agent, RunContextWrapper
class TestInstructionsSignatureValidation:
"""Test suite for instructions function signature validation"""
@pytest.fixture
def mock_run_context(self):
"""Create a mock RunContextWrapper for testing"""
... | 154 | 6,215 |
openai-agents-python | tests/test_tool_context.py | .py | from typing import Annotated, Any, cast
import pytest
from openai.types.responses import ResponseFunctionToolCall
from agents import Agent
from agents.run_config import RunConfig
from agents.run_context import RunContextWrapper
from agents.tool import FunctionTool, invoke_function_tool
from agents.tool_context import... | 421 | 12,760 |
openai-agents-python | tests/test_extension_filters.py | .py | from __future__ import annotations
import json as json_module
from copy import deepcopy
from typing import Any, cast
from unittest.mock import patch
from openai.types.responses import ResponseOutputMessage, ResponseOutputText
from openai.types.responses.response_reasoning_item import ResponseReasoningItem
from agent... | 1,323 | 45,095 |
openai-agents-python | tests/test_logprobs.py | .py | import pytest
from openai.types.chat import ChatCompletion, ChatCompletionMessage
from openai.types.chat.chat_completion import Choice
from openai.types.responses.response_usage import InputTokensDetails, OutputTokensDetails
from agents import (
ModelSettings,
ModelTracing,
OpenAIChatCompletionsModel,
... | 166 | 5,451 |
openai-agents-python | tests/test_exception_exports.py | .py | """Verify that all public exception classes are re-exported from the top-level agents package."""
from typing import Any, cast
import pytest
import agents
from agents import exceptions as exceptions_module
def test_mcp_tool_cancellation_error_is_exported_at_top_level() -> None:
# MCPToolCancellationError is a ... | 54 | 1,997 |
openai-agents-python | tests/test_tracing.py | .py | from __future__ import annotations
import asyncio
from typing import Any
import pytest
from inline_snapshot import snapshot
from agents.tracing import (
Span,
Trace,
TracingProcessor,
agent_span,
custom_span,
function_span,
generation_span,
handoff_span,
set_trace_processors,
... | 549 | 16,283 |
openai-agents-python | tests/test_tool_use_tracker.py | .py | from __future__ import annotations
from typing import Any, cast
from openai.types.responses import ResponseFunctionToolCall
from agents import Agent, ModelSettings, function_tool, tool_namespace
from agents.items import ToolCallItem, ToolCallOutputItem, ToolSearchCallItem, ToolSearchOutputItem
from agents.run_intern... | 246 | 8,434 |
openai-agents-python | tests/test_agent_hooks.py | .py | from __future__ import annotations
import json
from collections import defaultdict
from typing import Any
import pytest
from typing_extensions import TypedDict
from agents.agent import Agent
from agents.lifecycle import AgentHooks
from agents.run import Runner
from agents.run_context import AgentHookContext, RunCont... | 544 | 18,077 |
openai-agents-python | tests/test_usage.py | .py | from __future__ import annotations
from typing import Any
import pytest
from openai.types.completion_usage import (
CompletionTokensDetails,
CompletionUsage,
PromptTokensDetails,
)
from openai.types.responses.response_usage import InputTokensDetails, OutputTokensDetails
from agents import Agent, Runner
f... | 617 | 20,155 |
openai-agents-python | tests/test_run_impl_resume_paths.py | .py | import asyncio
import json
from typing import Any, cast
import pytest
from openai.types.responses import ResponseFunctionToolCall, ResponseOutputMessage
import agents.run as run_module
from agents import Agent, Runner, function_tool
from agents.agent import ToolsToFinalOutputResult
from agents.agent_output import Age... | 568 | 20,061 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.