Skip to content

Conversation

@shivmohith
Copy link
Contributor

@shivmohith shivmohith commented Dec 12, 2025

Summary

This PR includes two changes to the Agno instrumentation:

  1. Feature: Add agent.name attribute to Agent and Team spans
  2. Bug Fix: Fix Team span attributes being overwritten by member Agent attributes

Changes

1. Add agent.name attribute

Added SpanAttributes.AGENT_NAME to both Agent and Team spans to properly identify the agent/team name in traces. This attribute is now set alongside GRAPH_NODE_NAME for better trace visibility.

Files changed:

  • _runs_wrapper.py: Added yield SpanAttributes.AGENT_NAME, agent.name for both Team and Agent cases
  • Test files: Added assertions to verify agent.name attribute is present

2. Bug Fix: Team span attributes overwritten by members

Problem:
When a Team span was created, the _agent_run_attributes function was recursively calling itself for each member Agent. This caused member Agent attributes (including GRAPH_NODE_NAME and AGENT_NAME) to be added to the Team's span attribute dictionary. Since dictionaries cannot have duplicate keys, the last member's attributes would overwrite the Team's attributes, resulting in incorrect Team span attributes.

Root Cause:
The recursive call yield from _agent_run_attributes(member, f".{member.name}") on line 142 was adding member attributes to the Team's span. Member Agents should have their own spans when they execute, not have their attributes added to the Team's span.

Solution:
Removed the recursive call that added member attributes to the Team's span. Member Agents will now correctly have their own spans with their own attributes when they run, and the Team's span will retain the correct Team attributes.

Files changed:

  • _runs_wrapper.py: Removed the loop that recursively called _agent_run_attributes for Team members

Testing

  • Updated existing tests to verify agent.name attribute is present on Agent and Team spans
  • Verified that Team spans now correctly retain Team attributes instead of being overwritten by member attributes
  • All existing tests pass

Impact

  • Breaking: None
  • Behavior: Team spans now correctly show Team attributes instead of being overwritten by member Agent attributes
  • New Feature: agent.name attribute is now available on all Agent and Team spans for better trace identification

Note

Add agent.name to Agent/Team spans and prevent Team span attributes from being overwritten by member agents; update tests accordingly.

  • Instrumentation (_runs_wrapper.py):
    • Emit SpanAttributes.AGENT_NAME alongside GRAPH_NODE_NAME for both Agent and Team spans.
    • Remove recursive member attribute emission from Team to prevent overwriting Team span attributes.
  • Tests:
    • Update tests/test_instrumentor.py and tests/test_workflow_instrumentation.py to assert agent.name on relevant spans and validate graph relationships (Team root, agents as children).

Written by Cursor Bugbot for commit 31b1dbc. This will update automatically on new commits. Configure here.

Added the agent name as a span attribute (SpanAttributes.AGENT_NAME) for both team and agent nodes in _agent_run_attributes. Updated related tests to assert the presence and correctness of the agent name attribute in generated spans.
@shivmohith shivmohith requested a review from a team as a code owner December 12, 2025 14:05
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Dec 12, 2025
@fehmisener
Copy link

fehmisener commented Dec 15, 2025

Hello is this PR covers this #2533 and this ticket agno-agi/agno#5712?

@fehmisener
Copy link

Hi @kausmeows, can you also check this ticket? Maybe you already fixed it with previously closed PR or this can also be an actual bug we need to consider

@shivmohith
Copy link
Contributor Author

Hello is this PR covers this #2533 and this ticket agno-agi/agno#5712?

I believe that PR solves a different issue. Here, the Team agent's attributes are being overwritten by its sub-agents. Additionally, I added the "agent.name" span attribute, which I believe the other PR does not include.

@shivmohith
Copy link
Contributor Author

@fehmisener @kausmeows can this be merged or any modifications to be done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants