Skip to content

Conversation

@OiPunk
Copy link
Contributor

@OiPunk OiPunk commented Feb 10, 2026

Summary

Fixes #260 by making OpenAI tracing sanitization fail-safe for oversized span_data.input / span_data.output payloads.

What changed

  • Extended _sanitize_for_openai_tracing_api to also sanitize input and output fields (not just generation usage keys).
  • Added byte-size based truncation helpers:
    • Strings are truncated with a stable suffix (... [truncated]) while staying under the ingest limit.
    • Non-string oversized payloads are replaced with a compact metadata object (truncated, original_type, preview).
  • Kept behavior endpoint-aware: sanitization is only applied for the OpenAI tracing ingest endpoint, existing custom endpoint behavior is unchanged.

Tests

  • uv run ruff check src/agents/tracing/processors.py tests/test_trace_processor.py
  • uv run mypy src/agents/tracing/processors.py tests/test_trace_processor.py
  • uv run pytest tests/test_trace_processor.py -q
  • make format-check

Added test coverage for:

  • large string truncation
  • large non-string replacement
  • custom endpoint passthrough
  • unchanged small input path
  • helper edge-cases (within limit, suffix too large)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Truncate span input when input is too large

1 participant