diff --git a/docs/models/codex.md b/docs/models/codex.md index 529b27b09d..884aa446e5 100644 --- a/docs/models/codex.md +++ b/docs/models/codex.md @@ -9,7 +9,15 @@ Pass `RunConfig(model_provider=CodexProvider())` to the Runner to use Codex Core ## Install a GitHub prerelease wheel -The experimental `feat/simple-codex` branch packages the Python SDK, the compiled Codex extension, and its execution helpers in one `openai-agents` wheel. Use standard CPython 3.10 through 3.14. After publication, find **Agents SDK v1.0.0-alpha.1** in [GitHub Releases](https://github.com/openai/openai-agents-python/releases). Expand **Assets** and copy the link to the wheel for your platform. Its filename starts with `openai_agents-1.0.0a1-`. +Use standard CPython 3.10 through 3.14. The preview wheel includes the Python SDK, Codex Core, and its execution helpers. You don't need a Codex CLI installation. + +!!! warning "Check the prerelease before installing" + + [`v1.0.0-alpha.1`](https://github.com/openai/openai-agents-python/releases/tag/v1.0.0-alpha.1) includes the provider but predates OpenTelemetry, operation tracing, native approval recovery, and Runner text redaction. For those features, wait for a tagged prerelease that lists them. Install wheels only from the SDK's GitHub Releases page. A passing CI run and its checksums do not establish release approval. + +1. Open [SDK releases](https://github.com/openai/openai-agents-python/releases) and select a tagged prerelease that supports the features you need. +2. From that release's **Assets**, download `SHA256SUMS` and the wheel for your platform. +3. Compute the wheel's SHA-256 digest with `sha256sum` on Linux, `shasum -a 256` on macOS, or `Get-FileHash` in PowerShell. Install only if the digest matches the entry for the exact filename in `SHA256SUMS`. | Platform | Wheel filename ending | | --- | --- | @@ -18,16 +26,16 @@ The experimental `feat/simple-codex` branch packages the Python SDK, the compile | macOS 11 or newer on Apple Silicon | `macosx_11_0_arm64.whl` | | Windows x64 | `win_amd64.whl` | -In an activated virtual environment, replace `WHEEL_URL` with the asset link. This installs prebuilt binaries. +For the tracing example, see **OpenTelemetry** in the English [tracing guide](../tracing.md) to install the wheel with the `opentelemetry` extra. Otherwise, activate a fresh virtual environment and replace `WHEEL_FILE` with the local path to your `.whl` file. ```sh -python -m pip install --only-binary=:all: "WHEEL_URL" +python -m pip install --only-binary=:all: "WHEEL_FILE" ``` -For repository examples, check out the preview tag. From the repository root, run `uv sync` with the extras required by the example. Then install the wheel in the project environment. +For repository examples, check out the same release tag. From the repository root, run `uv sync` with the extras required by the example. Then install the verified wheel in the project environment. ```sh -uv pip install --reinstall-package openai-agents "WHEEL_URL" +uv pip install --reinstall-package openai-agents "WHEEL_FILE" ``` Run the examples with `uv run --no-sync` to keep the wheel installed. You can also set `UV_NO_SYNC=1` in your shell and use the repository's `uv run` commands as written. Each project sync reinstalls the pure Python SDK from the checkout. @@ -134,7 +142,15 @@ The workspace sandbox protects the directory that contains the installed helpers On Windows, the preview rejects a local Codex executor configured with the legacy elevated sandbox. That sandbox needs a setup helper that Codex cannot securely locate from a Python process. If your organization requires this sandbox, use an SDK-managed executor or configure a remote executor with `include_local = false` in `environments.toml`. -Pass a [`ResumableSession`](https://github.com/openai/openai-agents-python/blob/feat/simple-codex/docs/sessions/index.md#use-your-own-storage-for-resumable-sessions) to `Runner.run(..., session=session)` to pause a built-in `exec_command` or `apply_patch` for approval. A new worker can load that session and approve or reject the original call. Both workers need the same local workspace and permissions. See the [recovery requirements for tool hooks](https://github.com/openai/openai-agents-python/blob/feat/simple-codex/native/codex/patches/02-approval-recovery.md). Other native approval requests fail the model call. +To pause a direct built-in `exec_command` or `apply_patch` for human approval, start the run with a [`ResumableSession`](https://github.com/openai/openai-agents-python/blob/feat/simple-codex/docs/sessions/index.md#use-your-own-storage-for-resumable-sessions). On the replacement worker, load the saved state, approve or reject the original request, and pass the Codex run configuration again. Protect the session store. It can contain the submitted command or patch even with tracing disabled. + +Recovery requires a single pending native call, one local environment, and the same workspace path and permissions. For edits, the affected files must still match the saved state. Other types of native approval requests fail the model call. + +Keep required security hooks enabled. Configure the same SDK `prepare_tool_input`, `prepare_tool_output`, and lifecycle hooks on both workers. A missing required hook leaves approval pending. Other native hooks or hook warnings stop recovery. See the [recovery requirements for tool hooks](https://github.com/openai/openai-agents-python/blob/feat/simple-codex/native/codex/patches/02-approval-recovery.md#use-a-scrubber-with-approvals). + +Codex selects the sandbox for the first attempt. After a sandbox denial, Codex can retry an edit outside the sandbox only if the policy permits it without another approval and no edits have been committed. A partial edit stops recovery and leaves earlier writes on disk. After a partial edit or worker crash, inspect the workspace and reconcile any effects before retrying. See the [recovery limits](https://github.com/openai/openai-agents-python/blob/feat/simple-codex/native/codex/patches/02-approval-recovery.md#safety-limits). + +In a container, check that the worker can start the sandbox helper. On a hard timeout, terminate the worker's commands and their child processes as well. For a non-interactive read-only workflow, disable approval prompts. @@ -148,20 +164,70 @@ Commands that require more permission fail under this configuration. SDK tool ap A `SandboxAgent`, `ShellTool`, or `ApplyPatchTool` uses the SDK's executor or editor instead. The provider disables competing native workspace tools for these runs. Disable inherited Codex MCP servers when using isolated SDK execution tools; otherwise the provider rejects the configuration. SDK-managed MCP tools remain available through the SDK's own connection and approval policy. See [MCP](../mcp.md). +!!! warning "When a tool requires a policy check" + + If the native hook relay cannot deliver a decision, Codex may run the tool with its original arguments. If a failed check must always stop execution, enforce the check inside an SDK-managed tool and disable the corresponding native tool. Raw stream events and provider-managed history can still contain the original arguments. + Input guardrails with `run_in_parallel=False` finish before model execution. Cancellation and output guardrails do not roll back native commands or tool side effects. Inspect the workspace before retrying a failed operation. ## Streaming, history, and cancellation -Reuse a `CodexProvider` across calls in the same workspace. The provider shares a native thread manager and starts a fresh, ephemeral Codex thread for each model call. The SDK supplies the instructions, messages, tool results, and schemas for that call. Keep conversation history in an [SDK session](../sessions/index.md) or pass `result.to_input_list()` to the next run. When your application finishes using the provider, call `await provider.aclose()` to release its shared resources. +Reuse a `CodexProvider` across calls in the same workspace. The provider shares a native thread manager and starts a fresh, ephemeral Codex thread for each request from the Runner. One request can include several model calls and native tool executions. The SDK supplies the instructions, messages, tool results, and schemas for the request. Keep conversation history in an [SDK session](../sessions/index.md) or pass `result.to_input_list()` to the next run. When your application finishes using the provider, call `await provider.aclose()` to release its shared resources. Use `Runner.run_streamed()` and consume `result.stream_events()` as with the default provider. Text deltas arrive during generation. When the model supplies a requested reasoning summary, the stream also includes `response.reasoning_summary_text.delta` events. SDK function calls supply their complete JSON arguments in one update, rather than an argument-by-argument stream. -Call `result.cancel()` to stop a streaming run immediately, or `result.cancel(mode="after_turn")` to stop after the current turn. Continue consuming the stream to observe completion. For a non-streaming async run, cancel its asyncio task. The provider closes the ephemeral thread when the model call ends. +Call `result.cancel()` to stop a streaming run immediately, or `result.cancel(mode="after_turn")` to stop after the current turn. Continue consuming the stream to observe completion. For a non-streaming async run, cancel its asyncio task. The provider has been closing the ephemeral thread at the end of each Runner request. Strict structured output uses Codex's output schema. With `strict_json_schema=False`, the provider puts the schema in the instructions and the SDK validates the final JSON. The latter does not constrain generation on the server. `OpenAIResponsesCompactionSession` can compact full input history and replay the encrypted result into Codex. It calls the separate OpenAI compact endpoint and needs an OpenAI client or credentials. `compaction_mode="previous_response_id"` cannot use Codex's local turn IDs as stored Responses IDs. See [session compaction](../sessions/index.md). +## Operation tracing + +The SDK preview uses two [Codex patches](https://github.com/openai/openai-agents-python/tree/feat/simple-codex/native/codex/patches) for operation tracing and approval recovery in the embedded Core. Installing the wheel leaves any separate Codex CLI unchanged. Runner text redaction runs in Python. + +Use the same SDK trace processors for Responses and embedded Codex. See **OpenTelemetry** in the English [tracing guide](../tracing.md) for a runnable example with a console exporter or collector. To capture metadata for a Codex run, pass this configuration to the Runner. + +```python +from agents import RunConfig +from agents.models.codex import CodexProvider + +config = RunConfig( + model_provider=CodexProvider(), + tracing={"operation_detail": "metadata"}, + trace_include_sensitive_data=False, +) +``` + +One Runner turn can contain several model calls and native tool executions. For example, if Codex reads a file, calls a Python tool, and then answers, look for three model spans and two execution spans across two Runner turns. A retry adds an event to the same model span. Python tools appear once, when the Runner executes them. + +Nested native tool executions in the active Codex thread get their own spans. Tracing does not follow independently running Codex subagents onto other threads. + +With `trace_include_sensitive_data=True`, SDK processors receive the following fields for each Runner request to Codex. + +| `operation_detail` | Model spans | Native tool spans | +| --- | --- | --- | +| Omitted | Caller input on the first span (`.input`) and the raw returned response on the last successful span (`.response`). No `.output` or paused approval response. | Metadata | +| `"metadata"` | Metadata | Metadata | +| `"content"` | Bounded submitted messages (`.input`) and completed visible output items (`.output`) per call, without a raw `.response` | Bounded arguments and available results | + +With detail omitted, native tool results such as file contents can reach SDK processors through the returned response or replayed history. OpenTelemetry exports payloads only in `"content"` mode. Set `trace_include_sensitive_data=False` to suppress payloads in all three modes. + +`RunConfig.redact_text` restricts automatic traces to metadata even in content mode. Work inside Codex and native logs are outside its scope. See **Runner text redaction** in the English [tracing guide](../tracing.md). + +In content mode, model spans include completed output items and omit deltas from unfinished items. Native tool spans use the result Codex accepts after output hooks. The SDK excludes paused approval responses and their private recovery checkpoints from model spans. + +If a trace looks incomplete, check the following fields. + +| Signal | Meaning | +| --- | --- | +| `reason="output_unavailable"` in tool content | The tool finished, but the SDK received no accepted result. | +| `reason="unsupported_or_oversized_content"` | The SDK omitted an unsupported value or one that exceeded the capture limit. | +| `outcome="interrupted"` and `estimated_end=True` | Python estimated the end of an operation without a completion timestamp. | +| `codex.tracing.coverage` with `coverage="partial"` | Check `reason`. For example, `missing_operations` means no model observations arrived, and `dropped_operations` can indicate a full queue. In OpenTelemetry, use `openai.agents.operation.coverage` and `openai.agents.operation.reason`. | + +Set `RunConfig(tracing_disabled=True)` to disable SDK tracing for the run. + ## Supported features and limits Switching providers changes the model backend. It does not make every Responses API feature available through Codex. diff --git a/docs/ref/extensions/tracing/opentelemetry.md b/docs/ref/extensions/tracing/opentelemetry.md new file mode 100644 index 0000000000..104dc49f27 --- /dev/null +++ b/docs/ref/extensions/tracing/opentelemetry.md @@ -0,0 +1,3 @@ +# `OpenTelemetry` + +::: agents.extensions.tracing.opentelemetry diff --git a/docs/tracing.md b/docs/tracing.md index 7da50e985a..5ed7955ae3 100644 --- a/docs/tracing.md +++ b/docs/tracing.md @@ -34,7 +34,7 @@ By default, the SDK traces the following: - Each runner invocation is wrapped in a `task_span()`. - Each model turn is wrapped in a `turn_span()`. - Each time an agent runs, it is wrapped in `agent_span()` -- LLM generations are wrapped in `generation_span()` +- The Responses and embedded Codex providers use one `response_span()` per logical model call, including retries. Chat Completions uses `generation_span()`. - Function tool calls are each wrapped in `function_span()` - Guardrails are wrapped in `guardrail_span()` - Handoffs are wrapped in `handoff_span()` @@ -144,7 +144,7 @@ Certain spans may capture potentially sensitive data. The `generation_span()` stores the inputs/outputs of the LLM generation, and `function_span()` stores the inputs/outputs of function calls. These may contain sensitive data, so you can disable capturing that data via [`RunConfig.trace_include_sensitive_data`][agents.run.RunConfig.trace_include_sensitive_data]. -For an approval-gated function tool, a span that pauses for approval does not store the SDK's internal result wrapper as tool output. If the application rejects the call with a custom rejection message, the function span stores that message as output and error text only when `trace_include_sensitive_data` is `True`. When the setting is `False`, the span omits the output and uses the generic error text `Tool execution rejected`. +With `operation_detail` omitted, a function span that pauses for approval does not store the SDK's internal result wrapper as tool output. If the application rejects the call with a custom rejection message, the function span stores that message as output and error text only when `trace_include_sensitive_data` is `True`. When the setting is `False`, the span omits the output and uses the generic error text `Tool execution rejected`. For detailed tracing, see [Payload capture](#payload-capture). Similarly, Audio spans include base64-encoded PCM data for input and output audio by default. You can disable capturing this audio data by configuring [`VoicePipelineConfig.trace_include_sensitive_audio_data`][agents.voice.pipeline_config.VoicePipelineConfig.trace_include_sensitive_audio_data]. @@ -152,6 +152,51 @@ By default, `trace_include_sensitive_data` is `True`. You can set the default wi When `trace_include_sensitive_data` is `False`, Responses model spans omit the request input and response output. For calls to an official OpenAI endpoint, the spans still include the Responses API `response_id` as correlation metadata. The SDK omits that identifier from redacted spans for custom endpoints. +### Runner text redaction + +Use [`RunConfig.redact_text`][agents.run.RunConfig.redact_text] with either provider to remove known secrets from run inputs, model replies, and SDK tool arguments and results. Replacements change what the model and Python tools receive. Supply a synchronous function that returns the same string for the same input and leaves sanitized text unchanged. Never log its input. + +This example requires a [tagged SDK prerelease with Runner text redaction](models/codex.md#install-a-github-prerelease-wheel). The `v1.0.0-alpha.1` wheel lacks this feature. Once a compatible release is available, run the example offline. The scripted model deliberately returns the same test value that the caller supplied. + +```python +import asyncio + +from agents import Agent, RunConfig, Runner +from agents.testing import ScriptedModel, assistant_message + + +async def main(): + private_value = "example-private-ticket" + + def redact(text: str) -> str: + return text.replace(private_value, "[redacted]") + + agent = Agent( + name="Support", + model=ScriptedModel([[assistant_message(f"Ticket: {private_value}")]]), + ) + result = await Runner.run( + agent, + f"Check ticket {private_value}", + run_config=RunConfig(redact_text=redact, tracing_disabled=True), + ) + assert private_value not in result.final_output + print(result.final_output) # Ticket: [redacted] + + +asyncio.run(main()) +``` + +With the callback active, the Runner limits automatic traces to metadata, even in content mode. It mutes the `openai.agents` and `openai.agents.tracing` loggers and withholds raw stream events, including text deltas. You can still consume completed run items. If the Runner can't safely inspect a value, validate a checkpoint, or preserve the action submitted for approval, it stops the run. Error messages may omit details. + +For a worker that saves or resumes runs, take these steps. + +1. Upgrade readers before writers. This preview writes `RunState` schema 1.24 even without redaction. Protected `ResumableSession` checkpoints use version 2. Older workers can't read these formats. +2. Pass the same redaction policy to every nested and resumed run. The SDK records the requirement in the checkpoint and keeps the function in memory only. Resume a restored protected state with the callback before exporting it again. +3. Use a session or replay the messages. Protected runs reject caller-supplied `conversation_id` and `previous_response_id` because the Runner can't inspect the remote history. Allow only one writer at a time per session. Each append checks available history for text split across turns. + +Test the policy against your own data. Keep secrets out of static instructions, identifiers, configuration, and application metadata. The callback covers only the text your function recognizes. It can't scrub existing records, binary media, application or provider logs, or operations inside Codex. + ## Custom tracing processors The high level architecture for tracing is: @@ -174,6 +219,170 @@ The [trace redaction example](https://github.com/openai/openai-agents-python/blo The redactor and destination are trusted application code. They must not independently log or send the original data. The batch processor can invoke the exporter during background export, explicit flush, or shutdown, so callbacks must be safe to use from those execution contexts. A failed batch is dropped; subsequent batches can still be exported. Replacement affects future processor callbacks and does not erase data already buffered by a previously registered processor. Configure the replacement before creating traces or running agents. +## OpenTelemetry + +Use [`OpenTelemetryTracingProcessor`](ref/extensions/tracing/opentelemetry.md) to send SDK spans to your application's OpenTelemetry (OTel) tracer provider. Register it once for both the default Responses provider and the [embedded Codex provider](models/codex.md#operation-tracing). + +The `v1.0.0-alpha.1` wheel predates this integration. Once a tagged SDK prerelease includes OpenTelemetry and operation tracing, [download and verify its wheel](models/codex.md#install-a-github-prerelease-wheel). In a fresh virtual environment, replace `WHEEL_FILE` with the local path to the verified `.whl` file. Keep the `[opentelemetry]` extra after the filename. + +```sh +python -m pip install --only-binary=:all: "WHEEL_FILE[opentelemetry]" "opentelemetry-sdk>=1.45,<2" +python -c "from agents.extensions.tracing import OpenTelemetryTracingProcessor" +``` + +### One setup for both providers + +Save this script as `otel_agent.py`. Set `OPENAI_API_KEY` for Responses. For Codex, set `CODEX_API_KEY` or [use your saved login](models/codex.md#authenticate). Both runs make model requests. By default, the example prints trace metadata and the agent's answer to the console. + +```python +import argparse +import asyncio +import os + +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor + +from agents import Agent, ModelSettings, RunConfig, Runner, set_trace_processors +from agents.decorators import tool +from agents.extensions.tracing import OpenTelemetryTracingProcessor +from agents.models.codex import CodexProvider + +parser = argparse.ArgumentParser() +parser.add_argument("--codex", action="store_true") +parser.add_argument("--model") +parser.add_argument("--content", action="store_true") +args = parser.parse_args() + +tracer_provider = TracerProvider() +tracer_provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter())) +tracer = tracer_provider.get_tracer("example") +set_trace_processors([OpenTelemetryTracingProcessor(tracer_provider=tracer_provider)]) + + +@tool +def square(value: int) -> int: + """Return the square of an integer.""" + with tracer.start_as_current_span("square.calculate"): + return value * value + + +agent = Agent( + name="Calculator", + instructions="Use square once, then reply with the result.", + tools=[square], + model_settings=ModelSettings(tool_choice="required"), +) +config = RunConfig( + model=args.model, + tracing={"operation_detail": "content" if args.content else "metadata"}, + trace_include_sensitive_data=args.content, +) +if args.codex: + config.model_provider = CodexProvider(api_key=os.environ.get("CODEX_API_KEY")) + + +async def main(): + try: + with tracer.start_as_current_span("calculator.request"): + result = await Runner.run(agent, "What is the square of 12?", run_config=config) + print(result.final_output) + finally: + await config.model_provider.aclose() + + +try: + asyncio.run(main()) +finally: + tracer_provider.shutdown() +``` + +Run the script with each provider. Use `--model` to select a model that supports tool calls. + +```sh +python otel_agent.py +python otel_agent.py --codex +``` + +Check for an answer of `144` in either mode. In the console trace, look for `square.calculate` beneath `execute_tool square`. + +```text +calculator.request + invoke_runner Agent workflow + invoke_agent Calculator + openai.agents.turn + chat + execute_tool square + square.calculate + openai.agents.turn + chat +``` + +### Send spans to a collector + +If your application already configures an OTel tracer provider, pass it to `OpenTelemetryTracingProcessor`. Use `set_trace_processors()` for OTel alone or `add_trace_processor()` to keep the existing SDK processors, including the default OpenAI exporter. Configure sampling, batching, and delivery on the OTel provider. In a long-running worker, call `tracer_provider.force_flush()` when needed and `tracer_provider.shutdown()` when the worker exits. The SDK's `flush_traces()` does not flush the OTel provider. + +To send the example's spans over OTLP/HTTP, install the [Python exporter](https://opentelemetry.io/docs/languages/python/exporters/). + +```sh +python -m pip install "opentelemetry-exporter-otlp-proto-http>=1.45,<2" +``` + +Set [`OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/) to the collector's full trace URL, for example `http://127.0.0.1:4318/v1/traces` for a local collector. In `otel_agent.py`, replace the console exporter import and the `add_span_processor(...)` line with these imports and registration. + +```python +from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter +from opentelemetry.sdk.trace.export import BatchSpanProcessor + +tracer_provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter())) +``` + +Run the script again and look for `calculator.request` in your tracing backend. In a worker, call `Runner.run()` or start and consume `Runner.run_streamed()` under the current request span. Across processes, [extract the caller's trace context](https://opentelemetry.io/docs/languages/python/propagation/) before starting that span. Without a parent, the worker starts a new trace. The processor does not inject trace headers into model gateway requests. + +### Read the worker trace + +Group spans by `gen_ai.operation.name`. By default, each step of the Runner's agent loop has an `openai.agents.turn` span. One Codex step can contain several `chat` and `execute_tool` spans. A Python callback has one execution span. Instrumented calls inside the callback appear beneath it. + +For approvals, look for `openai.agents.tool_approval` with `openai.agents.operation.outcome` set to `paused` or `rejected`. An approved tool's execution time excludes the wait for a decision. On the replacement worker, start the resumed run under its current caller. If the tool has a call ID, match the decision and execution by `gen_ai.tool.call.id` within the same job. + +Use `gen_ai.request.model` and `gen_ai.response.model` when available. Model spans report token totals as `gen_ai.usage.input_tokens` and `gen_ai.usage.output_tokens`. Nonzero counts can also appear as `gen_ai.usage.cache_read.input_tokens`, `gen_ai.usage.cache_write.input_tokens`, and `gen_ai.usage.reasoning.output_tokens`. For billed cost, consult your gateway or provider. + +Each logical model call includes the time spent waiting between retries. After a tool result, the next inference starts a new model span. Use the following fields to inspect retries observed by the SDK. + +| Retry field or event | Role | Limit | +| --- | --- | --- | +| `span.span_data.operation.retry_timestamps` | ISO 8601 retry observation times | Up to 128 times per model span | +| OTel `openai.agents.model.retry` | One event per retained time, without request content | Subject to the tracer provider's event limits | +| `openai.agents.model.attempt` | Attempt number on the event | Starts at `2` for the first retry | + +For Runner retries, the timestamp marks the start of the next attempt. If a transport reports only a retry count, those events share the time the SDK received the count. Retries internal to a gateway may be invisible to the worker. + +### Payload capture + +For Responses and Codex, `RunConfig.tracing["operation_detail"]` controls payload capture. The same calls, approvals, and retries appear in every mode. Set `trace_include_sensitive_data=False` to suppress model and tool payloads even with `"content"` selected. + +The table applies when `redact_text` is unset. With [Runner text redaction](#runner-text-redaction), automatic traces contain only metadata in every row. + +| `operation_detail` | `trace_include_sensitive_data` | SDK model and tool payload fields | OTel payload attributes | +| --- | --- | --- | --- | +| Omitted | `True`, the default | Legacy model `.input` and `.response`, SDK function input/output, native tool metadata | None | +| Omitted | `False` | None | None | +| `"metadata"` | Either value | None | None | +| `"content"` | `True` | Bounded model and tool content | Bounded permitted content | +| `"content"` | `False` | None | None | + +Both explicit detail settings omit inputs and outputs from approval decision spans. + +!!! warning "Trace settings do not redact stored data" + + Use `"metadata"` on every run, including nested and resumed runs, to keep automatic model and tool payloads out of SDK processors. With detail omitted, other processors can receive file contents even when OTel exports only metadata. Keep secrets out of span names, IDs, and custom data. + + Protect logs, conversation history, and saved approvals separately. A session checkpoint can contain a tool's arguments even when its trace contains only metadata. In content mode, the model span can capture the original arguments before `prepare_tool_input` rewrites them for an SDK function tool. + +Pass `--content` only if every registered processor and destination may receive the text. Look for `gen_ai.input.messages`, `gen_ai.system_instructions`, `gen_ai.output.messages`, `gen_ai.tool.call.arguments`, and `gen_ai.tool.call.result`. On a continuation, the submitted messages may contain only new items. Use `openai.response.previous_response_id`, when available, to find the earlier call. See [Sensitive data](#sensitive-data) for response ID handling. + +In content mode, each operation has separate 32 KiB limits for input and output, measured as UTF-8 JSON. Look for truncation and omission markers for large values, binary media, hidden reasoning, and known credential fields. For example, an oversized JSON string can produce `reason="capture_budget"` in Python. Free text can still contain secrets. + +For the SDK fields available on each Codex call, see [Codex operation tracing](models/codex.md#operation-tracing). ## Tracing with non-OpenAI models diff --git a/mkdocs.yml b/mkdocs.yml index 1f8d493674..f98880710e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -189,6 +189,7 @@ plugins: - Extensions: - Handoff filters: ref/extensions/handoff_filters.md - Handoff prompt: ref/extensions/handoff_prompt.md + - OpenTelemetry tracing: ref/extensions/tracing/opentelemetry.md - Third-party adapters: - Any-LLM model: ref/extensions/models/any_llm_model.md - Any-LLM provider: ref/extensions/models/any_llm_provider.md