Skip to content

fix: preserve unsafe integers in OpenAI trace payloads#3438

Closed
pragnyanramtha wants to merge 1 commit into
openai:mainfrom
pragnyanramtha:pragnyan/fix-trace-unsafe-integers
Closed

fix: preserve unsafe integers in OpenAI trace payloads#3438
pragnyanramtha wants to merge 1 commit into
openai:mainfrom
pragnyanramtha:pragnyan/fix-trace-unsafe-integers

Conversation

@pragnyanramtha
Copy link
Copy Markdown

@pragnyanramtha pragnyanramtha commented May 17, 2026

Summary

Fixes #2094 by normalizing trace input/output fields sent to the default OpenAI tracing ingest endpoint so integers outside JavaScript's safe integer range are stringified before browser-based trace viewers can round them. Runtime tool inputs and custom tracing endpoints are unchanged.

Root cause: function trace inputs can contain JSON strings or structured payloads with Python integers larger than Number.MAX_SAFE_INTEGER. Those values are valid JSON numbers, but browser JSON viewers can lose precision when parsing/displaying them.

Change:

  • Add OpenAI-endpoint-only trace field sanitization for unsafe integers in JSON strings and structured input/output payloads.
  • Preserve safe integers, booleans, original payload objects, and custom endpoint behavior.
  • Keep existing trace field truncation behavior after the numeric normalization step.

Test plan

  • uv run pytest tests/test_trace_processor.py -k 'unsafe_integers or keeps_unsafe_integers or truncates_oversized_output or keeps_small_input'
  • uv run pytest tests/test_trace_processor.py -m 'not serial'
  • uv run ruff format --check src/agents/tracing/processors.py tests/test_trace_processor.py
  • uv run ruff check src/agents/tracing/processors.py tests/test_trace_processor.py
  • git diff --check

Not run to completion:

  • uv run pytest tests/test_trace_processor.py because existing serial test test_tracing_atexit_cleanup_timeout_preserves_process_exit_code_on_504 timed out; rerunning that single test also timed out.
  • uv run mypy src/agents/tracing/processors.py tests/test_trace_processor.py because it produced no output for several minutes and was stopped.

Issue number

Fixes #2094

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

Notes: no docs were needed for this internal tracing-export normalization. I ran focused ruff format/lint checks on the touched files rather than full make lint/make format.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 00:20
Copilot AI review requested due to automatic review settings May 17, 2026 00:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@seratch seratch added the wontfix This will not be worked on label May 17, 2026
@seratch seratch closed this May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Traces dashboard shows big integer arguments incorrectly in tool calling traces

3 participants