Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Agents SDK instrumentation. #854

Merged
merged 73 commits into from
Mar 24, 2025
Merged

Refactor Agents SDK instrumentation. #854

merged 73 commits into from
Mar 24, 2025

Conversation

tcdent
Copy link
Contributor

@tcdent tcdent commented Mar 15, 2025

Thus implementation demonstrates a sustainable pattern for all instrumentation that gets included in AgentOps.

  • Uses semantic conventions exclusively.
  • All pertinent data is exported, including workflow input/output, tool use, and completions.
  • Spans nest under the parent trace and are opened/closed in a lifecycle that is compatible with agent's built-in tracing module.
  • Tooling for generating test data from Response objects from openai-agents and completions & responses from openai
  • Example code that uses handoffs.
  • Better span_names
    • agents.function should be something like agents.tool.<tool_name>
    • agents.response should have the agent name
  • Agent span is closing early? Should include the tool and llm calls within it's start/end times.
  • Completion data is getting merged with the agent. We should have separate spans for the agent making the action and then the llm call as a child span. This appears to be a limitation of the way openai_agents hands off to tracing; lots of things get categorized as response, but it works much better now.
  • instrumentation.openai is incomplete. I created it to be able to instrument responses api calls, but ended up incorporating that into the instrumentation.openai_agents. This will be applied in a new PR.
  • Attributes have tests, but the exporter/processor does not.

@tcdent tcdent requested a review from teocns March 15, 2025 09:05
Copy link
Member

@the-praxs the-praxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tcdent for the PR! This is helpful in moving towards a more stable instrumentation for the OpenAI provider and Agents framework.

I have requested some changes primarily on the semantic conventions being used to record the attributes. This would prevent duplication of data and provide an ordered structure of extracting data from queries in the backend.

@tcdent tcdent marked this pull request as draft March 15, 2025 17:40
@tcdent
Copy link
Contributor Author

tcdent commented Mar 15, 2025

@the-praxs Did you run this? Post your script and output below.

@the-praxs
Copy link
Member

@the-praxs Did you run this? Post your script and output below.

https://gist.github.com/the-praxs/73fe232afb46c6cccb110dd4de9db0ba

@tcdent tcdent marked this pull request as ready for review March 24, 2025 19:51
@the-praxs the-praxs self-requested a review March 24, 2025 19:59
@the-praxs
Copy link
Member

@the-praxs
Copy link
Member

Tested streaming with examples/agents-examples/basic/stream_text.py and it works as expected.

Copy link
Member

@the-praxs the-praxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM AND YOLO

tcdent and others added 3 commits March 24, 2025 16:29
* Log deeplink to trace on AgentOps dashboard.

* Test coverage, type checking.

* Get app_url from config.

* Don't format trace_id in the URL as a UUID, just a hex string.
@the-praxs the-praxs merged commit c1a4015 into main Mar 24, 2025
7 of 10 checks passed
@the-praxs the-praxs deleted the serialization-fix-test branch March 24, 2025 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Agents SDK to correctly export spans
2 participants