Skip to content

Identify top-level agent spans #1604

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

Open
javiermtorres opened this issue May 9, 2025 · 4 comments
Open

Identify top-level agent spans #1604

javiermtorres opened this issue May 9, 2025 · 4 comments
Assignees

Comments

@javiermtorres
Copy link

Description

I would like to know if there is some way of identifying the top-level span used by an agent. With workflows and teams, it is not easy to know how many agents are intervening and when a specific agent's actions are starting.

@Jgilhuly
Copy link
Contributor

Jgilhuly commented May 9, 2025

Hey @javiermtorres - great question. Depending on your instrumentation, the agents could be shown hierarchically or sequentially in the trace, but either way you can use the same approach. You iterate through spans and follow the parent_id column to move up the trace, checking for openinference_span_kind=="AGENT" to find the root agent span.

We're doing some work on trace level evals now that requires this. I can create an example. What framework are you using for development, if any?

@javiermtorres
Copy link
Author

The issue with that approach is that chains or groups use several agents, so the top level span for some agent may not be the topmost AGENT type span, since it could be started in mid-chain. So how could I identify the start of a series of spans issued by the same agent, when taking a complete trace into account?

@axiomofjoy
Copy link
Contributor

@javiermtorres Do you have any particular framework or library you're working with?

It might make sense for us to add metadata for "agent_id": <id> to enable filtering.

@javiermtorres
Copy link
Author

True, I hadn't thought of chrono/hierarchically organizing the spans in the trace and find some distinct id or count the ids (if the underlying framework supports unique ids). Using such an attribute would definitely be a plus, since names are probably not unique in most frameworks. We're working with quite a few frameworks, so having a common key for this attribute is really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants