Keep OpenAI Agents traces connected across Temporal execution - #1856
Open
1fanwang wants to merge 3 commits into
Open
Keep OpenAI Agents traces connected across Temporal execution#18561fanwang wants to merge 3 commits into
1fanwang wants to merge 3 commits into
Conversation
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
OpenAI Agents traces keep their root metadata and parent links when a workflow and its activities share a worker. Workers use remote parent context instead of recording caller-span replicas. Callbacks finish in their starting Context, and trace completion restores the caller's context.
Why?
Previously, workers could replace the caller's spans and leave missing parents. Callbacks also logged
Failed to detach contextand left finished spans current, so later work could attach to the wrong parent. Child-workflow command ordering stays unchanged.Checklist
After the documented SDK build, start the server and run the test in another terminal. The before run applies this PR's tests to unchanged main; the after run uses this PR.
temporal server start-dev --ip 127.0.0.1 --port 17352 --headless env -u OPENAI_API_KEY PYTHONUNBUFFERED=1 uv run --no-sync python -m pytest tests/contrib/openai_agents/test_openai_tracing.py -k 'otel_remote_context_preserves_root or otel_callback_spans_restore_context' -E 127.0.0.1:17352 -q -s --tb=short --color=noRaw logs
Before:
After: