Skip to content

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

Merged
seratch merged 1 commit intoopenai:mainfrom
weiguangli-io:codex/openai-agents-2470-voice-trace-nesting
Feb 18, 2026
Merged

fix(voice): keep trace active until pipeline processing completes#2472
seratch merged 1 commit intoopenai:mainfrom
weiguangli-io:codex/openai-agents-2470-voice-trace-nesting

Conversation

@weiguangli-io
Copy link
Copy Markdown
Contributor

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

@seratch seratch added this to the 0.9.x milestone Feb 18, 2026
@seratch seratch merged commit 3589b6b into openai:main Feb 18, 2026
10 checks passed
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

2 participants