Skip to content

Conversation

@alexmojaki
Copy link
Contributor

@alexmojaki alexmojaki commented Mar 11, 2025

assert len(spans) == 12 is a very weak assertion. This PR asserts the exported traces and spans more precisely in a readable tree format. And when the format of an exported trace/span changes (e.g. a new key is added to every span), you can use pytest --inline-snapshot=fix to update all relevant tests automatically. See https://15r10nk.github.io/inline-snapshot/latest/ for more info.

@alexmojaki
Copy link
Contributor Author

There are more places where this can be done (I just did a find and replace on spans = fetch_ordered_spans()), and the simpler testing logic can be cleaned up, but this demonstrates the idea.

@rm-openai
Copy link
Collaborator

This is a great PR, thank you - hadn't seen this library before. Looks like there are some test failures/typecheck failures. I'm happy to take over and send out an updated PR, or let me know if you feel like updating things.

@rm-openai rm-openai merged commit 3a97b15 into openai:main Mar 17, 2025
5 checks passed
rm-openai added a commit that referenced this pull request Mar 21, 2025
Following up on #25, this removes uses of `fetch_traces` and `fetch_ordered_spans` where there's already a stronger assertion using `fetch_normalized_spans`. This is to help move towards the stronger style as much as possible, since people are still adding weaker assertions such as [this](https://github.com/openai/openai-agents-python/blob/7a0ca7930e31e5d12f7785dfcb0a2f123739b21a/tests/test_concurrency.py#L59-L61) in #91. The next step will be to find remaining uses of `fetch_ordered_spans` that can be replaced.
dev203934 added a commit to dev203934/openai-agents-python that referenced this pull request Mar 31, 2025
Following up on openai/openai-agents-python#25, this removes uses of `fetch_traces` and `fetch_ordered_spans` where there's already a stronger assertion using `fetch_normalized_spans`. This is to help move towards the stronger style as much as possible, since people are still adding weaker assertions such as [this](https://github.com/openai/openai-agents-python/blob/7a0ca7930e31e5d12f7785dfcb0a2f123739b21a/tests/test_concurrency.py#L59-L61) in openai/openai-agents-python#91. The next step will be to find remaining uses of `fetch_ordered_spans` that can be replaced.
gold-crow-997 added a commit to gold-crow-997/open-ai-agent that referenced this pull request Sep 11, 2025
Following up on openai/openai-agents-python#25, this removes uses of `fetch_traces` and `fetch_ordered_spans` where there's already a stronger assertion using `fetch_normalized_spans`. This is to help move towards the stronger style as much as possible, since people are still adding weaker assertions such as [this](https://github.com/openai/openai-agents-python/blob/7a0ca7930e31e5d12f7785dfcb0a2f123739b21a/tests/test_concurrency.py#L59-L61) in openai/openai-agents-python#91. The next step will be to find remaining uses of `fetch_ordered_spans` that can be replaced.
vmayoral pushed a commit to aliasrobotics/cai that referenced this pull request Oct 14, 2025
Following up on openai/openai-agents-python#25, this removes uses of `fetch_traces` and `fetch_ordered_spans` where there's already a stronger assertion using `fetch_normalized_spans`. This is to help move towards the stronger style as much as possible, since people are still adding weaker assertions such as [this](https://github.com/openai/openai-agents-python/blob/7a0ca7930e31e5d12f7785dfcb0a2f123739b21a/tests/test_concurrency.py#L59-L61) in openai/openai-agents-python#91. The next step will be to find remaining uses of `fetch_ordered_spans` that can be replaced.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants