Skip to content

fix(voice): keep trace active until pipeline processing completes#2472

Open
OiPunk wants to merge 1 commit intoopenai:mainfrom
OiPunk:codex/openai-agents-2470-voice-trace-nesting
Open

fix(voice): keep trace active until pipeline processing completes#2472
OiPunk wants to merge 1 commit intoopenai:mainfrom
OiPunk:codex/openai-agents-2470-voice-trace-nesting

Conversation

@OiPunk
Copy link
Contributor

@OiPunk OiPunk commented Feb 13, 2026

Summary

  • move TraceCtxManager scope into the background tasks for both single-turn and multi-turn voice pipeline execution so the trace stays open for the full async lifecycle
  • avoid canceling the producer task immediately after session_ended; wait for graceful producer completion first so trace_end can be emitted reliably
  • add voice pipeline regression tests for:
    • trace not finishing early in single-turn mode
    • trace ending after multi-turn processing
    • on_start() intro/exception path continuing without aborting the session

Root Cause

VoicePipeline previously entered TraceCtxManager only around task creation, then returned immediately. This ended the trace before async processing finished, causing subsequent spans to be emitted after trace closure.

Testing

  • uv run ruff check src/agents/voice/pipeline.py src/agents/voice/result.py tests/voice/test_pipeline.py
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --extra voice pytest tests/voice/test_pipeline.py -q
  • env -u ALL_PROXY -u all_proxy -u HTTPS_PROXY -u https_proxy -u HTTP_PROXY -u http_proxy -u NO_PROXY -u no_proxy uv run --extra voice coverage run -m pytest tests/voice/test_pipeline.py -q
  • changed-line coverage check: src/agents/voice/pipeline.py and src/agents/voice/result.py are both 100%

Fixes #2470

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.

Voice agent traces finish early and subsequent spans are not correctly nested

1 participant