openai-agents-python/benchmarks/native-sdk/container-default-host
Mark Stuart 251da9e3d7
bench: support buffered default-host comparisons (#5968)
Co-authored-by: markstuart-oai <323302876+markstuart-oai@users.noreply.github.com>
2026-11-13 16:18:21 -08:00
..
Dockerfile Isolated default-host SDK benchmark profile (#5755) 2026-11-10 22:41:46 -08:00
README.md bench: support buffered default-host comparisons (#5968) 2026-11-13 16:18:21 -08:00
setup.py Isolated default-host SDK benchmark profile (#5755) 2026-11-10 22:41:46 -08:00
source-manifest.json Isolated default-host SDK benchmark profile (#5755) 2026-11-10 22:41:46 -08:00

Default-host container smoke

The --default-host-setup profile has been exercising the normal https://api.openai.com/v1 address against a local TLS peer. Container-only hostname mapping and a temporary trusted certificate authority (CA) have been preserving hostname verification without a custom endpoint or certificate override.

Supported workloads: fresh no-tool calls, or one asynchronous function tool with final-only or active-reader output, using streaming response mode or explicit caller-owned buffered mode for final-only calls. Omitted-Provider mode has been accepting the selected wheel's actual default HTTP/SSE or WSS route. Caller-owned mode has been accepting HTTP/SSE or buffered JSON. Buffered calls have been requiring final-only workloads. Retained-conversation workloads, synchronous tools, tool fanout and multiple tool rounds have been remaining outside this profile.

The example has been selecting --native-provider-mode omitted, with the worker setting only its synthetic API key before SDK import. No caller-owned Provider has been entering that route. The default caller-owned option has been retaining the earlier Provider ownership. Both modes have been using fresh independent conversations.

--native-transport http below has been declaring the expected HTTP/SSE route, without forcing that route in the SDK. For a wheel selecting WSS by default, --native-transport websocket has been declaring the expected route instead. Selecting caller-owned has also been requiring the http declaration in this profile.

Prerequisites

  • Linux x86-64, Docker, uv and the GNU timeout command.
  • One existing native wheel for the selected source revision, with its recorded SHA-256. Required compatibility: Ubuntu 24.04/glibc 2.39 and the container's architecture.
  • A complete, relocatable standard CPython 3.13.16 directory, including bin, lib and its bundled libraries. The same copied interpreter for SDK and peer environments.
  • Package access during image provisioning; offline networking during the smoke. No SDK source build in this example.

The supplied three-line Dockerfile has been providing OS setup tools only. The complete image recipe below has been provisioning the native SDK, stable v0 and peer environments from the same Python 3.13.16 directory. It has also been installing the pinned dual-HTTP peer dependencies before offline execution. All three environments have been receiving explicit certifi==2026.10.23: setup has been importing certifi for every interpreter before installing the temporary CA.

Provision the image

Starting directory: the repository root. WHEEL and CPYTHON_DIR below: absolute paths to the existing wheel and complete Python directory. Fresh LAB: separate from the SDK checkout and any measured environment.

set -eu
BENCH="$PWD/benchmarks/native-sdk"
WHEEL="/absolute/path/to/exact-native-wheel.whl"
CPYTHON_DIR="/absolute/path/to/cpython-3.13.16-linux-x86_64-gnu"
LAB="$(mktemp -d /tmp/agents-default-host.XXXXXX)"
RUN_ID="$(cat /proc/sys/kernel/random/uuid)"
CTX="$LAB/context"
mkdir "$CTX" "$LAB/output" "$LAB/docker-config"
export DOCKER_CONFIG="$LAB/docker-config"
IMAGE="agents-default-host-smoke:$RUN_ID"
CONTAINER="agents-default-host-smoke-$RUN_ID"
sha256sum "$WHEEL" > "$LAB/wheel.sha256"
cp -a "$CPYTHON_DIR" "$CTX/python"
cp "$(command -v uv)" "$CTX/uv"
cp "$WHEEL" "$CTX/native.whl"
basename "$WHEEL" > "$CTX/wheel-name.txt"
cp -a "$BENCH" "$CTX/bench"
cat > "$CTX/Dockerfile" <<'DOCKERFILE'
FROM ubuntu:24.04
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates openssl libstdc++6 libatomic1 \
    && rm -rf /var/lib/apt/lists/*
COPY python/ /opt/python/
COPY uv /usr/local/bin/uv
COPY native.whl wheel-name.txt /input/
COPY bench/ /bench/
RUN wheel_name="$(cat /input/wheel-name.txt)" && mv /input/native.whl "/input/$wheel_name" \
    && uv venv --python /opt/python/bin/python3.13 /opt/sdk \
    && uv venv --python /opt/python/bin/python3.13 /opt/stable \
    && uv venv --python /opt/python/bin/python3.13 /opt/peer \
    && uv pip install --no-build --compile-bytecode --python /opt/sdk/bin/python "/input/$wheel_name" 'pydantic==2.12.3' 'typing-extensions==4.16.0' 'jsonschema==4.26.0' 'referencing==0.37.0' 'certifi==2026.10.23' \
    && uv pip install --no-build --compile-bytecode --python /opt/stable/bin/python 'openai-agents==0.24.0' 'openai==3.29.0' 'pydantic==2.12.3' 'typing-extensions==4.16.0' 'certifi==2026.10.23' \
    && uv pip install --no-build --compile-bytecode --python /opt/peer/bin/python 'aiohttp==3.14.3' 'openai==3.41.0' 'pydantic==2.12.3' 'certifi==2026.10.23' \
    && uv pip install --no-build --compile-bytecode --python /opt/peer/bin/python -r /bench/requirements-http2-peer.txt \
    && uv pip freeze --python /opt/sdk/bin/python > /input/sdk-packages.txt \
    && uv pip freeze --python /opt/stable/bin/python > /input/stable-packages.txt \
    && uv pip freeze --python /opt/peer/bin/python > /input/peer-packages.txt
DOCKERFILE
timeout --signal=TERM --kill-after=15s 600s \
  docker build --rm --force-rm --tag "$IMAGE" "$CTX" > "$LAB/build.log" 2>&1
docker image inspect "$IMAGE" > "$LAB/image.json"

The image's package inventories have been recording the full installed versions. The UUID has been keeping the image tag and container name independent of the temporary directory. A task-local DOCKER_CONFIG has been keeping Docker configuration writes in LAB. Container mount: the results directory only.

Run one offline functional smoke

Root inside the disposable container: required for CA installation and port 443. Container writable layer only for OS/certifi trust changes and keys; output-directory mount only for results. No host trust changes.

cleanup_container() {
  docker rm --force "$CONTAINER" >/dev/null 2>&1 || true
}
trap cleanup_container EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
timeout --signal=TERM --kill-after=15s 180s \
  docker run --rm --init --name "$CONTAINER" --network none \
    --add-host api.openai.com:127.0.0.1 \
    --mount "type=bind,src=$LAB/output,dst=/out" \
    "$IMAGE" env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOME=/root \
    /bin/sh -ec '
      /opt/peer/bin/python -B /bench/container-default-host/setup.py \
        --directory /run/sdk-benchmark \
        --python /opt/sdk/bin/python --python /opt/peer/bin/python
      cp /input/sdk-packages.txt /input/peer-packages.txt /out/
      exec env SDK_BENCH_SERVER_PYTHON=/opt/peer/bin/python \
        OPENAI_AGENTS_TEST_IN_CODEX_SANDBOX=1 PYTHONHASHSEED=0 \
        /opt/sdk/bin/python -B /bench/worker.py --engine v1 \
        --default-host-setup /run/sdk-benchmark/setup.json \
        --native-transport http --native-provider-mode omitted \
        --case cold_first_result --output /out/native-smoke.json
    ' > "$LAB/container.log" 2>&1
test -z "$(docker ps --all --quiet --filter "name=^/${CONTAINER}$")"
docker image rm "$IMAGE"
rm -rf -- "$CTX"

Expected result: exit 0, errors: 0, server.errors: 0, server.requests: 1, default_host: true, native_provider_mode: "omitted", full_owner_scope: "adapter-lifetime" and wire_transport: "sse" in native-smoke.json. One fresh conversation, without prefill. The worker has been checking exact output, input/history hashes, actual Host/SNI, framing and joined peer cleanup. Its null sample_index has been preventing admission to a scored comparison. Container absence after exit and explicit image removal: required cleanup checks. On failure or timeout, the trap has been removing the exact container. Docker-state reconciliation: still required after build cancellation or a partial image. Logs and package inventories in LAB; deletion after review and export.

The earlier caller-owned functional smoke has been passing on Ubuntu 24.04/glibc 2.39 with CPython 3.13.16 and one native wheel: two HTTP/SSE requests, zero worker/peer errors, and joined cleanup. That proof has been covering only its caller-owned native worker, without qualifying the omitted mode, comparison controller, stable SDK, WebSockets, HTTP/2, other wheels or complete workload suite. This procedure has been retaining worker timing fields without supporting a performance or memory claim. Its Adapter-lifetime CPU endpoint has not been including process-final cache cleanup.

Fresh tool and active-reader smoke

The same image and setup have been supporting omitted-provider tool calls without a custom endpoint or transport selector. For these checks, the loop below has been replacing the single exec env ... worker.py command inside the existing docker run shell. The preceding setup, package-inventory copies, outer timeout and container/image cleanup have been remaining unchanged. This excerpt has been assuming the existing /opt/sdk, /opt/peer, /bench, /run/sdk-benchmark and mounted /out paths.

for case in oneshot_tool oneshot_tool_output_16k_1 oneshot_tool_output_16k_16 \
            oneshot_tool_output_16k_128 oneshot_tool_output_16k_128_active; do
  env SDK_BENCH_SERVER_PYTHON=/opt/peer/bin/python \
    OPENAI_AGENTS_TEST_IN_CODEX_SANDBOX=1 PYTHONHASHSEED=0 \
    /opt/sdk/bin/python -B /bench/worker.py --engine v1 \
      --default-host-setup /run/sdk-benchmark/setup.json \
      --native-transport websocket --native-provider-mode omitted \
      --case "$case" --iterations 1 --output "/out/$case.json"
done

Each selected worker has been charging one prefill plus one measured fresh conversation: two native Session IDs, four generating requests, two callbacks and two verified tool outputs. The active-reader case has been checking 128 exact text deltas per conversation, readiness before callback return, any unread terminal suffix and joined reader cleanup. The other dense cases have been checking the same final output without a public stream consumer. All workers have been requiring zero peer errors and retired sockets. No sample_index has been entering these smoke rows, so the comparison controller has not been admitting them as scored samples.

These commands have been requiring a native wheel with the public ToolContext/Turn interfaces. The native adapter has been keeping callback, reader and per-call Session cleanup inside each call; the process-owned runtime cache has been remaining outside final Adapter-close ownership. The smoke has not been supplying a performance, resource-retention or optimization claim.

Provision a reference native wheel

For the paired native command in the benchmark guide, these additional image steps have been supplying the second SDK environment. Insertion point: after the Dockerfile heredoc in Provision the image, before its first docker build. REFERENCE_WHEEL: an absolute path to the recorded reference wheel, with the same Python and platform compatibility as WHEEL. The separate /reference directory has been avoiding filename collisions between wheels.

REFERENCE_WHEEL="/absolute/path/to/exact-reference-native-wheel.whl"
sha256sum "$REFERENCE_WHEEL" > "$LAB/reference-wheel.sha256"
cp "$REFERENCE_WHEEL" "$CTX/reference.whl"
basename "$REFERENCE_WHEEL" > "$CTX/reference-wheel-name.txt"
cat >> "$CTX/Dockerfile" <<'DOCKERFILE'
COPY reference.whl reference-wheel-name.txt /reference/
RUN wheel_name="$(cat /reference/reference-wheel-name.txt)" && mv /reference/reference.whl "/reference/$wheel_name" \
    && uv venv --python /opt/python/bin/python3.13 /opt/reference \
    && uv pip install --no-build --compile-bytecode --python /opt/reference/bin/python "/reference/$wheel_name" 'pydantic==2.12.3' 'typing-extensions==4.16.0' 'jsonschema==4.26.0' 'referencing==0.37.0' 'certifi==2026.10.23' \
    && uv pip freeze --python /opt/reference/bin/python > /reference/packages.txt
DOCKERFILE

The original build command has been including this environment in the same disposable image. The paired command has been registering all three interpreters with setup.py, copying all package inventories to /out, and keeping the peer on /opt/peer. It has been declaring WSS for both SDK wheels; a wheel selecting another default route has been failing the wire checks rather than receiving a transport override. Recorded wheel hashes, source revisions and package inventories have been supporting interpretation of the comparison, without qualifying different transport or Provider lifetimes as the same operation.